Namespaces | Classes
Persistence concept

Common interfaces and implementations for file based persistence and general object serialization. More...

Namespaces

 iser
 Contains general persistence mechanism with basic archives implementations.
 

Classes

class  ifile::CAutoPersistenceComp
 The component for automatic object persistence. More...
 
class  ifile::CCompactXmlFileReadArchive
 Qt-based implementation of archive reading from XML file. More...
 
class  ifile::CCompactXmlFileWriteArchive
 Qt-based implementation of archive for writing in compact XML format. More...
 
class  ifile::CComposedFileMetaInfoProviderComp
 
class  ifile::CComposedFilePersistenceComp
 Loader component, which delegates the persistence functionality to its slave loaders. More...
 
class  ifile::CCompressedXmlFileReadArchive
 Qt-based implementation of archive reading from XML file. More...
 
class  ifile::CCompressedXmlFileWriteArchive
 Qt-based implementation of archive for writing in compact XML format. More...
 
class  ifile::CFileArchiveInfo
 Basic implementation of interface ifile::IFileArchiveInfo. More...
 
class  ifile::CFileReadArchive
 Simple implementation of archive reading from own ACF format binary file. More...
 
class  ifile::CFileSerializerCompBase
 Base implementation of file serializer. More...
 
class  ifile::CFileTypeInfoComp
 Simple implementation of ifile::IFileTypeInfo using user defined extension list and descriptions. More...
 
class  ifile::CFileWriteArchive
 Simple implementation of archive writing to own ACF format binary file. More...
 
class  ifile::CSimpleXmlFileReadArchive
 Simple implementation of archive reading from XML file. More...
 
class  ifile::CSimpleXmlFileWriteArchive
 Simple implementation of archive for writing in XML format. More...
 
class  ifile::IFileArchiveInfo
 Simple informative interface allowing to get access to current processed file by file archives. More...
 
class  ifile::IFilePersistence
 Interface providing loading and saving of data objects. More...
 
class  ifile::IFilePersistenceInfo
 Provide some information about file loader state. More...
 
class  ifile::IFileTypeInfo
 Provide loading and saving of objects. More...
 
class  ifile::TFileSerializerComp< ReadArchive, WriteArchive >
 Template implementation of file serializer using loading and storing archive implementation. More...
 
class  ifile::TXmlFileSerializerComp< ReadArchive, WriteArchive >
 Template implementation of file serializer using loading and storing archive implementation. More...
 
class  iqt::CClipboardSerializerComp
 A clipboard serializer component. More...
 
class  iqt::CNetworkWriteArchive
 A write archive working over network connection. More...
 
class  iqt::CSettingsArchiveBase
 Basic implementation for an archive used Qt settings implementation as persistence medium. More...
 
class  iqt::CSettingsReadArchive
 The read archive used global system settings mechansim (by example Windows registry or INI file) as medium. More...
 
class  iqt::CSettingsSerializerComp
 Store and load parameter as global settings. More...
 
class  iqt::CSettingsWriteArchive
 Write archive implementation for serialization based on QSettings. More...
 
class  iser::CArchiveHeaderInfo
 Represents functions related to ACF header. More...
 
class  iser::CArchiveTag
 Process tag used to group data in archive stream. More...
 
class  iser::CBitMemoryReadArchive
 This class provides bitwise access to the byte data. More...
 
class  iser::CBitMemoryWriteArchive
 This is an archive implementation which provides bitwise write of data. More...
 
class  iser::CCompactXmlMemReadArchive
 Qt-based implementation of archive reading from XML file. More...
 
class  iser::CCompactXmlMemWriteArchive
 Qt-based implementation of archive for writing in XML format. More...
 
class  iser::CCompactXmlReadArchiveBase
 Qt-based implementation of archive reading from XML file. More...
 
class  iser::CMemoryReadArchive
 Implementation of archive using memory buffer to read the persistent objects. More...
 
class  iser::CMemoryWriteArchive
 Implementation of archive using memory buffer to store the persistent objects. More...
 
class  iser::CMinimalVersionInfo
 Implementation of interface iser::IVersionInfo using information about minimal needed version from interface iser::ISerializable. More...
 
class  iser::CWriteArchiveBase
 Basic implementation of an abstract archive for data writting. More...
 
class  iser::CXmlStringReadArchive
 Simple implementation for reading of a XML from a string. More...
 
class  iser::CXmlStringWriteArchive
 Simple implementation of archive for writing of XML given as a string. More...
 
class  iser::IArchive
 Represent input/output persistence archive. More...
 
class  iser::IObject
 Common interface for factorisable model objects. More...
 
class  iser::ISerializable
 Common class for all classes which objects can be archived or restored from archive. More...
 
class  iser::IVersionInfo
 Provides access to version information. More...
 

Detailed Description

Common interfaces and implementations for file based persistence and general object serialization.

Archive-based object serialization

Objects that provide serialization must implement the iser::ISerializable interface. The most important method of this interface is Serialize(). Serialize method becomes as input an so called archive (iser::IArchive). An archive provides an abstract low level read/write access to a data medium. By example an archive can represent a file, a memory block, a database or a network resource, but the concrete kind of the archive is completely hidden from data object's point of view. Thus, we create a complete separation between the data model and the medium on which it is to be made persistent. Following archive types are provided by ACF core libraries:

We demonstrate the implementation of object serialization on example of CPerson class introduced in the Data model section. First of all we have to change the CPerson class to be inherited from iser::ISerializable. Because iser::ISerializable is already derived from istd::IChangeable, we have nothing else to change in this aspect. Also we rewrite:

class CPerson: virtual public iser::ISerializable
{
public:
// reimplemented (iser::ISerializable)
virtual bool Serialize(iser::IArchive& archive);
private:
QString m_firstName;
QString m_lastName;
};
// reimplemented (iser::ISerializable)
bool CPerson::Serialize(iser::IArchive& archive)
{
bool retVal = true;
// Use data model change notification only if the object will be reading from archive:
istd::CChangeNotifier notifier(archive.IsStoring()? NULL: this);
// Serialize object using tags:
// Serialize first name of the person:
static iser::CArchiveTag firstNameTag("FirstName", "First name of the person");
retVal = retVal && archive.BeginTag(firstNameTag); // Begin tag
retVal = retVal && archive.Process(m_firstName); // Process first name by archive
retVal = retVal && archive.EndTag(firstNameTag); // Close tag
// Serialize last name of the person:
static iser::CArchiveTag lastNameTag("LastName", "Last name of the person");
retVal = retVal && archive.BeginTag(lastNameTag);
retVal = retVal && archive.Process(m_lastName);
retVal = retVal && archive.EndTag(lastNameTag);
return retVal;
}

File-based persistence

Serialization is a low-level persistence mechanism, in which the structure of the archived data on the medium depends on Serialize method implementation inside of the data object. But often you will offer persistence functionality, that is not depending on concrete object implementation. A such situation is the supporting of known data formats (for example reading or writing of PNG images, OpenOffice documents and so on). For such persistence implementations ACF provides ifile::IFilePersistence interface.

See Also
Data model

© 2007-2017 Witold Gantzke and Kirill Lepskiy