ALBA
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
albaStorage Class Referenceabstract

#include <albaStorage.h>

Inheritance diagram for albaStorage:
Inheritance graph
[legend]
Collaboration diagram for albaStorage:
Collaboration graph
[legend]

Public Types

enum  STORAGE_IO_ERRORS { IO_OK =0 , IO_GENERIC_ERROR , IO_WRONG_OBJECT_TYPE , IO_LAST_ERROR }
 

Public Member Functions

 albaAbstractTypeMacro (albaStorage, albaObject)
 
 albaStorage ()
 
virtual ~albaStorage ()
 
virtual void SetURL (const char *name)
 
void ForceParserURL ()
 
const char * GetURL ()
 
const char * GetPareserURL ()
 
int Store ()
 
int Restore ()
 
void SetDocument (albaStorable *doc)
 
albaStorableGetDocument ()
 
virtual int ResolveInputURL (const char *url, albaString &filename, albaObserver *observer=NULL)=0
 
virtual int StoreToURL (const char *filename, const char *url=NULL)=0
 
virtual int ReleaseURL (const char *url)=0
 
virtual void GetTmpFile (albaString &filename)
 
void ReleaseTmpFile (const char *filename)
 
bool IsFileInDirectory (const char *filename)
 
virtual void SetTmpFolder (const char *folder)
 
virtual const char * GetTmpFolder ()
 
void SetErrorCode (int err)
 
int GetErrorCode ()
 
bool NeedsUpgrade ()
 
- Public Member Functions inherited from albaObject
 albaObject ()
 
virtual ~albaObject ()
 
virtual void Delete ()
 
virtual const char * GetTypeName () const
 
virtual bool IsA (const char *type_name) const
 
virtual bool IsA (const albaTypeID &type_id) const
 
virtual albaObjectNewObjectInstance () const =0
 
virtual const albaTypeIDGetTypeId () const
 
virtual void Print (std::ostream &os, const int indent=0) const
 
 albaObject (const albaObject &c)
 

Protected Member Functions

virtual int InternalStore ()=0
 
virtual int InternalRestore ()=0
 
virtual int OpenDirectory (const char *dir_name)=0
 

Protected Attributes

bool m_NeedsUpgrade
 
albaStorablem_Document
 
albaStorageElementm_DocumentElement
 
albaString m_URL
 
albaString m_ParserURL
 
albaID m_TmpFileId
 
albaString m_TmpFolder
 
std::set< albaStringm_TmpFileNames
 
std::set< albaStringm_FilesDictionary
 
int m_ErrorCode
 
- Protected Attributes inherited from albaObject
bool m_HeapFlag
 

Additional Inherited Members

- Static Public Member Functions inherited from albaObject
static const char * GetStaticTypeName ()
 
static bool IsStaticType (const char *type_name)
 
static bool IsStaticType (const albaTypeID &type_id)
 
static const albaTypeIDGetStaticTypeId ()
 
static albaObjectSafeDownCast (albaObject *o)
 

Detailed Description

Abstract class for an abject mastering the storing/restoring of objects This is an abstract class providing defining APIs for objects mastering storing/restoring of storing and restoring of albaStorable objects.

Concrete implementation will define a concrete encoding. The basic idea of storing and restoring is the creation of a parallel tree, with all information to be stored or restored. The tree is made of albaStorageElement nodes (or better, concrete classes inherited from it). The storage class provides an access to the document element and defines a couple of functions InternalStore and InternalRestore for implementing the concrete mechanisms. Users of this kind of object should provide an URL of the document to be opened/saved, and than call Store() or Restore(). In case of Restoring, the Document element is automatically created by the storage class, while when storing it must be set (or can have be created during a previous restoring). This class will also provide a high level mechanism for resolving URLs, that will try to copy locally remote or zipped files and allow a simple file access to I/O classes.

See also
albaStorageElement albaStorable
Todo:
  • implement packing (single file)
  • remote files (URL access)
  • improve tmp files management

Definition at line 47 of file albaStorage.h.

Member Enumeration Documentation

◆ STORAGE_IO_ERRORS

Enumerator
IO_OK 
IO_GENERIC_ERROR 
IO_WRONG_OBJECT_TYPE 
IO_LAST_ERROR 

Definition at line 52 of file albaStorage.h.

Constructor & Destructor Documentation

◆ albaStorage()

albaStorage::albaStorage ( )

◆ ~albaStorage()

virtual albaStorage::~albaStorage ( )
inlinevirtual

Definition at line 55 of file albaStorage.h.

Member Function Documentation

◆ albaAbstractTypeMacro()

albaStorage::albaAbstractTypeMacro ( albaStorage  ,
albaObject   
)

◆ SetURL()

virtual void albaStorage::SetURL ( const char *  name)
virtual

Set the URL of the document to be read or written.

Reimplemented in albaVMEStorage, and albaXMLStorage.

◆ ForceParserURL()

void albaStorage::ForceParserURL ( )

Force Copy storage URL to parser URL (used by the ALBA1.x importer)

◆ GetURL()

const char * albaStorage::GetURL ( )

Return the URL of the document to be read or written.

◆ GetPareserURL()

const char * albaStorage::GetPareserURL ( )

Return the name of the last read file, this is internally used when writing to a new file to read and copy information between the old and new file.

◆ Store()

int albaStorage::Store ( )

perform storing.

the argument is the tag of the document node

◆ Restore()

int albaStorage::Restore ( )

perform restoring.

the argument is the tag of the document node

◆ SetDocument()

void albaStorage::SetDocument ( albaStorable doc)

set the document element to be stored

◆ GetDocument()

albaStorable * albaStorage::GetDocument ( )

return the document object restored

◆ ResolveInputURL()

virtual int albaStorage::ResolveInputURL ( const char *  url,
albaString filename,
albaObserver observer = NULL 
)
pure virtual

resolve an URL and provide local filename to be used as input

Implemented in albaXMLStorage.

◆ StoreToURL()

virtual int albaStorage::StoreToURL ( const char *  filename,
const char *  url = NULL 
)
pure virtual

resolve an URL and provide a local filename to be used as output

store a file to an URL. This API transfer a tmp local file to URL. If no URL is specified use the storage URL as a base URL.

Implemented in albaXMLStorage.

◆ ReleaseURL()

virtual int albaStorage::ReleaseURL ( const char *  url)
pure virtual

Remove a file from the specified URL.

Used when a file in the storage is no more necessary. If the specified URL is a local file name try to prepend the storage URL as a base URL name.

Implemented in albaXMLStorage.

◆ GetTmpFile()

virtual void albaStorage::GetTmpFile ( albaString filename)
virtual

Return a name of file to be used as tmp file during store/restore.

This is usually located insed the MSF file directory

◆ ReleaseTmpFile()

void albaStorage::ReleaseTmpFile ( const char *  filename)

remove the tmp file

◆ IsFileInDirectory()

bool albaStorage::IsFileInDirectory ( const char *  filename)

Check if a file is present in the storage directory.

The directory list is open when Store() is called and directory data is updated at that time.

◆ SetTmpFolder()

virtual void albaStorage::SetTmpFolder ( const char *  folder)
inlinevirtual

Set the folder where to store tmp files.

If not specified the storage will automatically use a default folder, like the current directory or the storage file folder.

Definition at line 117 of file albaStorage.h.

◆ GetTmpFolder()

virtual const char * albaStorage::GetTmpFolder ( )
inlinevirtual

return the folder where tmp files are stored

Reimplemented in albaXMLStorage.

Definition at line 120 of file albaStorage.h.

◆ SetErrorCode()

void albaStorage::SetErrorCode ( int  err)
inline

Definition at line 122 of file albaStorage.h.

◆ GetErrorCode()

int albaStorage::GetErrorCode ( )
inline

Definition at line 123 of file albaStorage.h.

◆ NeedsUpgrade()

bool albaStorage::NeedsUpgrade ( )
inline

Definition at line 125 of file albaStorage.h.

◆ InternalStore()

virtual int albaStorage::InternalStore ( )
protectedpure virtual

This is called by Store() and must be reimplemented by subclasses.

Implemented in albaXMLStorage.

◆ InternalRestore()

virtual int albaStorage::InternalRestore ( )
protectedpure virtual

This is called by Restore() and must be reimplemented by subclasses.

Implemented in albaXMLStorage.

◆ OpenDirectory()

virtual int albaStorage::OpenDirectory ( const char *  dir_name)
protectedpure virtual

populate the list of files in the storage folder

Implemented in albaXMLStorage.

Member Data Documentation

◆ m_NeedsUpgrade

bool albaStorage::m_NeedsUpgrade
protected

Flag used to enable or not the upgrade mechanism.

Definition at line 137 of file albaStorage.h.

◆ m_Document

albaStorable* albaStorage::m_Document
protected

document object to be stored, or being restored

Definition at line 138 of file albaStorage.h.

◆ m_DocumentElement

albaStorageElement* albaStorage::m_DocumentElement
protected

document stored element

Definition at line 139 of file albaStorage.h.

◆ m_URL

albaString albaStorage::m_URL
protected

name of the file being accessed

Definition at line 141 of file albaStorage.h.

◆ m_ParserURL

albaString albaStorage::m_ParserURL
protected

name of the last parsed file (used for SaveAs)

Definition at line 142 of file albaStorage.h.

◆ m_TmpFileId

albaID albaStorage::m_TmpFileId
protected

counter for unique tmp file naming

Definition at line 143 of file albaStorage.h.

◆ m_TmpFolder

albaString albaStorage::m_TmpFolder
protected

folder where to store tmp files

Definition at line 144 of file albaStorage.h.

◆ m_TmpFileNames

std::set<albaString> albaStorage::m_TmpFileNames
protected

name of tmp files in the MSF dir

Definition at line 146 of file albaStorage.h.

◆ m_FilesDictionary

std::set<albaString> albaStorage::m_FilesDictionary
protected

list of files in the storage folder: to be populated by OpenDirectory()

Definition at line 147 of file albaStorage.h.

◆ m_ErrorCode

int albaStorage::m_ErrorCode
protected

the error code 0==OK

Definition at line 148 of file albaStorage.h.


The documentation for this class was generated from the following file: