BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
BALL::TextPersistenceManager Class Reference

#include <BALL/CONCEPT/textPersistenceManager.h>

Inheritance diagram for BALL::TextPersistenceManager:
BALL::PersistenceManager

Public Member Functions

Constructors and Destructors
 TextPersistenceManager ()
 
 TextPersistenceManager (std::istream &is)
 
 TextPersistenceManager (std::ostream &os)
 
 TextPersistenceManager (std::istream &is, std::ostream &os)
 
Layer 0 methods
virtual void writeHeader (const char *type_name, const char *name, LongSize ptr)
 
virtual bool checkHeader (const char *type_name, const char *name, LongSize &ptr)
 
virtual void writeTrailer (const char *name=0)
 
virtual bool checkTrailer (const char *name=0)
 
virtual void writeStreamHeader ()
 
virtual void writeStreamTrailer ()
 
virtual bool checkStreamHeader ()
 
virtual bool checkStreamTrailer ()
 
virtual bool getObjectHeader (String &type_name, LongSize &ptr)
 
virtual void writeName (const char *name)
 
virtual bool checkName (const char *name)
 
virtual void writeStorableHeader (const char *type_name, const char *name)
 
virtual bool checkStorableHeader (const char *type_name, const char *name)
 
virtual void writePrimitiveHeader (const char *type_name, const char *name)
 
virtual bool checkPrimitiveHeader (const char *type_name, const char *name)
 
virtual void writeStorableTrailer ()
 
virtual bool checkStorableTrailer ()
 
virtual void writePrimitiveTrailer ()
 
virtual bool checkPrimitiveTrailer ()
 
virtual void writeObjectPointerHeader (const char *type_name, const char *name)
 
virtual bool checkObjectPointerHeader (const char *type_name, const char *name)
 
virtual void writeObjectReferenceHeader (const char *type_name, const char *name)
 
virtual bool checkObjectReferenceHeader (const char *type_name, const char *name)
 
virtual void writeObjectPointerArrayHeader (const char *type_name, const char *name, Size size)
 
virtual bool checkObjectPointerArrayHeader (const char *type_name, const char *name, Size &size)
 
virtual void writeObjectPointerArrayTrailer ()
 
virtual bool checkObjectPointerArrayTrailer ()
 
Put methods for primitive data types.
virtual void put (const char c)
 
virtual void put (const Byte c)
 
virtual void put (const Index s)
 
virtual void put (const Size s)
 
virtual void put (const bool b)
 
virtual void put (const Real f)
 
virtual void put (const DoubleReal d)
 
virtual void put (const string &s)
 
virtual void put (const LongSize p)
 
Get methods for primitive data types.
virtual void get (char &c)
 
virtual void get (Byte &b)
 
virtual void get (Index &i)
 
virtual void get (Size &s)
 
virtual void get (bool &b)
 
virtual void get (Real &f)
 
virtual void get (DoubleReal &d)
 
virtual void get (string &s)
 
virtual void get (LongSize &p)
 
- Public Member Functions inherited from BALL::PersistenceManager
 PersistenceManager ()
 
 PersistenceManager (const PersistenceManager &pm)
 
 PersistenceManager (::std::istream &is)
 
 PersistenceManager (::std::ostream &os)
 
 PersistenceManager (::std::istream &is,::std::ostream &os)
 
virtual ~PersistenceManager ()
 
virtual void registerClass (String signature, const CreateMethod m)
 
virtual void * createObject (String signature) const
 
virtual Size getNumberOfClasses () const
 
virtual void setOstream (::std::ostream &s)
 
virtual void setIstream (::std::istream &s)
 
void startOutput ()
 
void endOutput ()
 
PersistentObjectreadObject ()
 
PersistenceManageroperator<< (const PersistentObject &object)
 
PersistenceManageroperator>> (PersistentObject *&object_ptr)
 
template<typename T >
bool checkObjectHeader (const T &, const char *name=0)
 
bool checkObjectHeader (const char *type_name)
 
template<typename T >
void writeObjectHeader (const T *object, const char *name=0)
 
void writeObjectTrailer (const char *name=0)
 
bool checkObjectTrailer (const char *name=0)
 
template<typename T >
void writePrimitive (const T &t, const char *name)
 
template<typename T >
bool readPrimitive (T &t, const char *name)
 
template<typename T >
void writeStorableObject (const T &t, const char *name)
 
template<typename T >
bool readStorableObject (T &t, const char *name)
 
template<typename T >
void writeObjectPointer (const T *object, const char *name)
 
template<typename T >
bool readObjectPointer (T *&object, const char *name)
 
template<typename T >
bool readObjectSmartPointer (boost::shared_ptr< T > &s_ptr, const char *name)
 
template<typename T >
void writeObjectReference (const T &object, const char *name)
 
template<typename T >
bool readObjectReference (T &object, const char *name)
 
template<typename T >
void writeObjectArray (const T *array, const char *name, Size size)
 
template<typename T >
bool readObjectArray (const T *array, const char *name, Size &size)
 
template<typename T >
void writeObjectPointerArray (T **arr, const char *name, const Size size)
 
template<typename T >
bool readObjectPointerArray (T **array, const char *name, Size &size)
 
virtual void initializeOutputStream ()
 
virtual void finalizeOutputStream ()
 
virtual void initializeInputStream ()
 
virtual void finalizeInputStream ()
 

Protected Member Functions

virtual bool expect (const String &value)
 
virtual const char * indent ()
 
- Protected Member Functions inherited from BALL::PersistenceManager
void registerKernelClasses_ ()
 
void addPointerPair_ (LongSize old_ptr, void *new_ptr)
 
void addNeededObjects_ ()
 
bool updatePointers_ ()
 

Private Attributes

Size indent_depth_
 

Static Private Attributes

static const char * INDENT_STRING
 
static const Size MAX_INDENT
 

Additional Inherited Members

- Public Types inherited from BALL::PersistenceManager
typedef void *(* CreateMethod )()
 
- Protected Types inherited from BALL::PersistenceManager
typedef HashSet< const
PersistentObject * > 
ObjectSet
 
typedef std::list< const
PersistentObject * > 
ObjectList
 
typedef HashMap< LongSize, void * > PointerMap
 
typedef std::list< std::pair
< void **, LongSize > > 
PointerList
 
typedef std::list< std::pair
< boost::shared_ptr
< PersistentObject >
*, LongSize > > 
SmartPointerList
 
- Protected Attributes inherited from BALL::PersistenceManager
StringHashMap< CreateMethodcreate_methods_
 
ObjectSet object_out_
 
ObjectList object_out_needed_
 
PointerMap pointer_map_
 
PointerList pointer_list_
 
SmartPointerList smart_pointer_list_
 
ObjectList object_in_
 
::std::ostream * ostr_
 
::std::istream * istr_
 

Detailed Description

Text-format-based persistence manager. This class implements a persistnece manager that reads and writes its objects in a human-readable text format. This is slow and objects get huge , but the format is clear and comprehensible - the ideal format to debug persistence-related programs. For production use, the XDRPersistenceManager is preferred.

See Also
XDRPersistenceManager

Definition at line 27 of file textPersistenceManager.h.

Constructor & Destructor Documentation

BALL::TextPersistenceManager::TextPersistenceManager ( )

Default constructor. Initializes just an internal variable.

BALL::TextPersistenceManager::TextPersistenceManager ( std::istream &  is)

Detailed constructor with an input stream.

BALL::TextPersistenceManager::TextPersistenceManager ( std::ostream &  os)

Detailed constructor with an output stream.

BALL::TextPersistenceManager::TextPersistenceManager ( std::istream &  is,
std::ostream &  os 
)

Detailed constructor with an input stream and an output stream.

Member Function Documentation

virtual bool BALL::TextPersistenceManager::checkHeader ( const char *  type_name,
const char *  name,
LongSize ptr 
)
virtual

Check for an an object header.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkName ( const char *  name)
virtual

Check for variable/member name.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkObjectPointerArrayHeader ( const char *  type_name,
const char *  name,
Size size 
)
virtual

Check for header for an array of pointers to PersistentObjects.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkObjectPointerArrayTrailer ( )
virtual

Check for trailer for an array of pointers to PersistentObjects.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkObjectPointerHeader ( const char *  type_name,
const char *  name 
)
virtual

Check for header for a pointer to a PersistentObject.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkObjectReferenceHeader ( const char *  type_name,
const char *  name 
)
virtual

Check for header for a reference to a PersistentObject.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkPrimitiveHeader ( const char *  type_name,
const char *  name 
)
virtual

Check for a type header and name for a primitive type.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkPrimitiveTrailer ( )
virtual

Check the trailer of a primitive type.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkStorableHeader ( const char *  type_name,
const char *  name 
)
virtual

Check for storable object header.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkStorableTrailer ( )
virtual

Check for storable object trailer.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkStreamHeader ( )
virtual

Check for the start marker in the input stream.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkStreamTrailer ( )
virtual

Check for the end marker in the output stream.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::checkTrailer ( const char *  name = 0)
virtual

Check an object trailer. This method checks the trailer of an object.

Parameters
namethe name of the object
Returns
true if the trailer was correct

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::expect ( const String value)
protectedvirtual

Check whether the streams contains a given string. This method reads the next string from the persistence manager's istream and compares it to the value given. If both strings are equal, true is returned.

Parameters
valuethe expected string
Returns
bool, true if the expected string was found, false otherwise
virtual void BALL::TextPersistenceManager::get ( char &  c)
virtual

Read a signed char from the input stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::get ( Byte b)
virtual

Read an unsigned char from the input stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::get ( Index i)
virtual

Read an Index from the input stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::get ( Size s)
virtual

Read a Size or a Position from the input stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::get ( bool b)
virtual

Read a boolean value from the input stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::get ( Real f)
virtual

Read a single precision floating point number from the input stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::get ( DoubleReal d)
virtual

Read a double precision floating point number from the input stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::get ( string &  s)
virtual

Read a string from the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::get ( LongSize p)
virtual

Read a pointer from the input stream.

Implements BALL::PersistenceManager.

virtual bool BALL::TextPersistenceManager::getObjectHeader ( String type_name,
LongSize ptr 
)
virtual

Get an (unknown) object header.

Implements BALL::PersistenceManager.

virtual const char* BALL::TextPersistenceManager::indent ( )
protectedvirtual

Return a string for the current indentation level.

virtual void BALL::TextPersistenceManager::put ( const char  c)
virtual

Write a signed char to the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::put ( const Byte  c)
virtual

Write an unsigned char to the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::put ( const Index  s)
virtual

Write an Index to the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::put ( const Size  s)
virtual

Write a Size or a Position to the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::put ( const bool  b)
virtual

Write a boolean value to the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::put ( const Real  f)
virtual

Write a single precision floating point number to the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::put ( const DoubleReal  d)
virtual

Write a double precision floating point number to the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::put ( const string &  s)
virtual

Write a string to the output.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::put ( const LongSize  p)
virtual

Write a 64-bit pointer to the output.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeHeader ( const char *  type_name,
const char *  name,
LongSize  ptr 
)
virtual

Write an object header. This method write an object header. It starts with the current number of spaces needed for a correct indentation. If name is a null pointer, the object is a base object of the current object. This method then writes the string BASEOBJECT. If name is a name or an empty string, OBJECT is written.

Then, the object's type_name is written, followed by a blank, the character "@" to indicate an address and then the object's this pointer in decimal format. The last string in the line is either "-" (for a base object or an object without name) or the object's name.
The indentation level is incremented. Example for a base object: BASEOBJECT BALL::Composite @ 1145254238 - Example for a member object: BASEOBJECT BALL::Bond @ 2334208924 bond_

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeName ( const char *  name)
virtual

Write a variable/member name.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeObjectPointerArrayHeader ( const char *  type_name,
const char *  name,
Size  size 
)
virtual

Write header for an array of pointers to PersistentObjects.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeObjectPointerArrayTrailer ( )
virtual

Write trailer for an array of pointers to PersistentObjects.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeObjectPointerHeader ( const char *  type_name,
const char *  name 
)
virtual

Write header for a pointer to a PersistentObject.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeObjectReferenceHeader ( const char *  type_name,
const char *  name 
)
virtual

Write header for a reference to a PersistentObject.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writePrimitiveHeader ( const char *  type_name,
const char *  name 
)
virtual

Write type header and name for a primitive type.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writePrimitiveTrailer ( )
virtual

Write the trailer for a primitive type.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeStorableHeader ( const char *  type_name,
const char *  name 
)
virtual

Write storable object header.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeStorableTrailer ( )
virtual

Write storable object trailer.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeStreamHeader ( )
virtual

Write a start marker to the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeStreamTrailer ( )
virtual

Write a end marker to the output stream.

Implements BALL::PersistenceManager.

virtual void BALL::TextPersistenceManager::writeTrailer ( const char *  name = 0)
virtual

Write the trailer for an object.

Parameters
namethe name of the object

Implements BALL::PersistenceManager.

Member Data Documentation

Size BALL::TextPersistenceManager::indent_depth_
private

Definition at line 284 of file textPersistenceManager.h.

const char* BALL::TextPersistenceManager::INDENT_STRING
staticprivate

Definition at line 281 of file textPersistenceManager.h.

const Size BALL::TextPersistenceManager::MAX_INDENT
staticprivate

Definition at line 282 of file textPersistenceManager.h.