Next: NDataBlockT
Up: Module SysTools
Previous: Module SysTools
  Contents
  Index
SOPHYA persistence
Figure 1:
partial class diagram for classes handling persistence in Sophya
![\begin{figure}
\framebox [40mm][c]{\mbox{\rule[-1mm]{0mm}{5mm} \bf PPersist} }\...
...ox [40mm][c]{\mbox{\rule[-1mm]{0mm}{5mm} \bf POutPersist} }\\ [2mm]
\end{figure}](img5.gif) |
A simple persistence mechanism is defined in SOPHYA. Its main
features are:
- Portable file format, containing the description of the data structures
and object hierarchy.
PPF Portable Persistence file Format.
- Handling of read/write for multiply referenced objects.
- All write operations are carried using sequential access only. This
holds also for read operations, unless positional tags are used.
SOPHYA persistence services can thus be used to transfer objects
through network links.
- The serialisation (reading/writing) for objects for a given class
is implemented through a handler object. The handler class inherits
from PPersist class.
- A run time registration mechanism is used in conjunction with
RTTI (Run Time Type Identification) for identifying handler classes
when reading PInPersist streams, or for associating handlers
with data objects AnyDataObject for write operations.
A complete description of SOPHYA persistence mechanism and guidelines
for writing delegate classes for handling object persistence is beyond
the scope of this document. The most useful methods for using Sophya
persistence are listed below:
- POutPersist::PutObject(AnyDataObj & o)
Writes the data object o to the output stream.
- POutPersist::PutObject(AnyDataObj & o, string tagname)
Writes the data object o to the output stream, associated with an
identification tag tagname.
- PInPersist::GetObject(AnyDataObj & o)
Reads the next object in stream into o. An exception is
generated for incompatible object types.
- PInPersist::GetObject(AnyDataObj & o, string tagname)
Reads the object associated with the tag tagname into o.
An exception is generated for incompatible object types.
The operators operator << (POutPersist ...) and
operator >> (PInPersist ...) are often overloaded
to perform PutObject() and GetObject() operations,
as illustrated in the example below:
// Creating and filling a histogram
Histo hw(0.,10.,100);
...
// Writing histogram to a PPF stream
POutPersist os("hw.ppf");
os << hw;
// Reading a histogram from a PPF stream
PInPersist is("hr.ppf");
is >> hr;
The scanppf program can be used to list the content of a PPF file.
csh> scanppf -h
SOPHYA Version 1.1 Revision 0 (V_Fev2001) -- Feb 28 2001 11:19:17 cxx
Usage: scanppf filename [s/n/a0/a1/a2/a3]
s[=default} : Sequential reading of objects
n : Object reading at NameTags
a0...a3 : Tag List with PInPersist.AnalyseTags(0...3)
Next: NDataBlockT
Up: Module SysTools
Previous: Module SysTools
  Contents
  Index
Reza Ansari
2001-03-07