#include <PersistentOStream.h>
Public Types | |
typedef ThePEG::Ptr < PersistentBase >::pointer | BPtr |
Alias for a reference counted pointer to PersistentBase . | |
typedef ThePEG::Ptr < PersistentBase > ::const_pointer | cBPtr |
Alias for a reference counted pointer to a const PersistentBase . | |
typedef ThePEG::Ptr < PersistentBase > ::transient_pointer | tBPtr |
Alias for a transient pointer to PersistentBase . | |
typedef ThePEG::Ptr < PersistentBase > ::transient_const_pointer | tcBPtr |
Alias for a transient pointer to a const PersistentBase . | |
typedef map< cBPtr, int, less < cBPtr > > | ObjectMap |
A map of objects indexed by integers. | |
typedef map< const ClassDescriptionBase *, int, less< const ClassDescriptionBase * > > | ClassMap |
A map relating class descriptions to integers. | |
typedef ClassDescriptionBase::DescriptionVector | DescriptionVector |
A vector of bare pointers to InputDescription objects. | |
Public Member Functions | |
PersistentOStream (ostream &, const vector< string > &libs=vector< string >()) | |
Constuctor giving an output stream. | |
PersistentOStream (string, const vector< string > &libs=vector< string >()) | |
Constuctor giving a file name to read. | |
~PersistentOStream () | |
The destructor. | |
template<typename T> | |
PersistentOStream & | operator<< (const RCPtr< T > &p) |
Operator for writing persistent objects to the stream. | |
template<typename T> | |
PersistentOStream & | operator<< (const ConstRCPtr< T > &p) |
Operator for writing persistent objects to the stream. | |
template<typename T> | |
PersistentOStream & | operator<< (const TransientRCPtr< T > &p) |
Operator for writing persistent objects to the stream. | |
template<typename T> | |
PersistentOStream & | operator<< (const TransientConstRCPtr< T > &p) |
Operator for writing persistent objects to the stream. | |
template<typename Container> | |
void | putContainer (const Container &c) |
Output of containers of streamable objects. | |
PersistentOStream & | outputPointer (tcBPtr) |
Write out a persistent object given a pointer to it. | |
void | putObjectPart (tcBPtr obj, const ClassDescriptionBase *cd) |
For a given object, write the member variables corresponding to a given ClassDescriptionBase object. | |
PersistentOStream & | flush () |
Remove all objects that have been written, except those which are to be saved, from the list of written objects. | |
PersistentOStream & | push () |
Instuct the stream to save the following objects (protecting them from being flushed). | |
PersistentOStream & | pop () |
Instuct the stream not to save the following objects. | |
bool | good () const |
Check the state of the stream. | |
operator bool () const | |
Check the state of the stream. | |
bool | operator! () const |
Check the state of the stream. | |
Operators for extracting built-in types from the stream. | |
PersistentOStream & | operator<< (string s) |
Write a character string. | |
PersistentOStream & | operator<< (char c) |
Write a character. | |
PersistentOStream & | operator<< (signed char c) |
Write a signed character. | |
PersistentOStream & | operator<< (unsigned char c) |
Write an unsigned character. | |
PersistentOStream & | operator<< (int i) |
Write an integer. | |
PersistentOStream & | operator<< (unsigned int i) |
Write an unsigned integer. | |
PersistentOStream & | operator<< (long i) |
Write a long integer. | |
PersistentOStream & | operator<< (unsigned long i) |
Write an unsigned long integer. | |
PersistentOStream & | operator<< (short i) |
Write a short integer. | |
PersistentOStream & | operator<< (unsigned short i) |
Write an unsigned short integer. | |
PersistentOStream & | operator<< (double d) |
Write a double. | |
PersistentOStream & | operator<< (float f) |
Write a float. | |
PersistentOStream & | operator<< (bool t) |
Write a boolean. | |
PersistentOStream & | operator<< (const char *s) |
Write a c-style character string (to be read in as a std::string). | |
PersistentOStream & | operator<< (Complex z) |
Write a Complex. | |
Private Member Functions | |
bool | isToken (char c) const |
Return true if the given character is aspecial marker character. | |
void | setBadState () |
Set the stream in a bad state. | |
void | checkState () |
Check if the state is ok. | |
const ClassDescriptionBase * | writeClassId (tcBPtr) |
Write out class information to the associated ostream. | |
void | writeClassDescription (const ClassDescriptionBase *) |
write out class information to the associated ostream. | |
void | beginObject () |
Put a "begin object" marker on the associated ostream. | |
void | endObject () |
Put a "end of object" marker on the associated ostream. | |
void | endBase () |
Put an "next base class" marker on the associated ostream. | |
void | put (char c) |
Put a character on the associated ostream. | |
void | escape (char c) |
Put a character on the associated ostream but escape it if it is a token. | |
ostream & | os () |
Return a reference to the associated ostream. | |
const ostream & | os () const |
Return a const reference to the associated ostream. | |
void | init (const vector< string > &libs) |
Write out initial metainfo on the stream. | |
PersistentOStream () | |
Standard ctors and assignment are private and not implemented. | |
PersistentOStream (const PersistentOStream &) | |
Standard ctors and assignment are private and not implemented. | |
PersistentOStream & | operator= (const PersistentOStream &) |
Standard ctors and assignment are private and not implemented. | |
Private Attributes | |
ObjectMap | writtenObjects |
List of written objects. | |
stack< int > | lastSavedObject |
List of written objects that are to be saved. | |
ClassMap | writtenClasses |
List of written classes. | |
ostream * | theOStream |
A pointer to the associated ostream. | |
bool | badState |
True if no errors has occurred. | |
bool | allocStream |
True if the associated ostream should be deleted in the destructor. | |
Static Private Attributes | |
static const int | version = 0 |
The version of this PersistentOStream implementation. | |
static const int | subVersion = 3 |
The subversion of this PersistentOStream implementation. | |
Special marker characters | |
static const char | tBegin = '{' |
The special marker character indicating the beginning of an object. | |
static const char | tEnd = '}' |
The special marker character indicating the end of an object. | |
static const char | tNext = '|' |
The marker character indicating the beginning of the next base class in case of multiple inheritance. | |
static const char | tNull = '\\' |
The special marker character indicating an escaped marker character. | |
static const char | tSep = '\n' |
The special marker character indicating the end of a value. | |
static const char | tNoSep = 'n' |
The special marker character used to avoid confusion with escaped tSep markers. | |
static const char | tYes = 'y' |
The special marker character indicating a true boolean value. | |
static const char | tNo = 'n' |
The special marker character indicating a false boolean value. |
Pointers to objects of classes derived from PersistentBase
may be written out if a static ClassDescription object is present for the class. Also basic types may be written to the stream, as well as containers of pointers to persistent objects and basic types.
The PersistentOStream
keeps a list of all pointers to written persistent objects, so that if several pointers to the smame object is written, the object will only be written once.
Each base class of a given object will be asked to write its members to the stream starting from the least derived class going to the most derived one. Members may be pointers to other persistent objects or basic types or containers of these. The output for each object part should be implemented by specializing the ClassTraits<T>::output method, which otherwise will call the non-virtual persistentOutput
function of the class. Note that for diamond-shaped multiple inheritance structures, the virtual base classes will be written out several times for the same object.
Definition at line 49 of file PersistentOStream.h.
typedef ThePEG::Ptr< PersistentBase >::pointer ThePEG::PersistentOStream::BPtr |
Alias for a reference counted pointer to PersistentBase .
Definition at line 53 of file PersistentOStream.h.
typedef ThePEG::Ptr< PersistentBase >::const_pointer ThePEG::PersistentOStream::cBPtr |
Alias for a reference counted pointer to a const PersistentBase .
Definition at line 53 of file PersistentOStream.h.
typedef ThePEG::Ptr< PersistentBase >::transient_pointer ThePEG::PersistentOStream::tBPtr |
Alias for a transient pointer to PersistentBase .
Definition at line 53 of file PersistentOStream.h.
typedef ThePEG::Ptr< PersistentBase >::transient_const_pointer ThePEG::PersistentOStream::tcBPtr |
Alias for a transient pointer to a const PersistentBase .
Definition at line 53 of file PersistentOStream.h.
typedef map< cBPtr , int , less< cBPtr > > ThePEG::PersistentOStream::ObjectMap |
A map of objects indexed by integers.
A map of int indexed by cBPtr .
Definition at line 56 of file PersistentOStream.h.
typedef map< const ClassDescriptionBase * , int , less< const ClassDescriptionBase * > > ThePEG::PersistentOStream::ClassMap |
A map relating class descriptions to integers.
A map of int indexed by const ClassDescriptionBase * .
Definition at line 59 of file PersistentOStream.h.
A vector of bare pointers to InputDescription objects.
Definition at line 62 of file PersistentOStream.h.
ThePEG::PersistentOStream::PersistentOStream | ( | ostream & | , | |
const vector< string > & | libs = vector< string >() | |||
) |
Constuctor giving an output stream.
Optionally a vector of libraries to be loaded before the resulting file can be read in again can be given in libs.
ThePEG::PersistentOStream::PersistentOStream | ( | string | , | |
const vector< string > & | libs = vector< string >() | |||
) |
Constuctor giving a file name to read.
If the first character in the string is a '|', the corresponding program is run and its standard input is used instead. If the filename ends in ".gz" the file is compressed with gzip. Optionally a vector of libraries to be loaded before the resulting file can be read in again can be given in libs.
PersistentOStream& ThePEG::PersistentOStream::operator<< | ( | const RCPtr< T > & | p | ) | [inline] |
Operator for writing persistent objects to the stream.
p | a pointer to the object to be written. |
Definition at line 94 of file PersistentOStream.h.
References outputPointer().
PersistentOStream& ThePEG::PersistentOStream::operator<< | ( | const ConstRCPtr< T > & | p | ) | [inline] |
Operator for writing persistent objects to the stream.
p | a pointer to the object to be written. |
Definition at line 104 of file PersistentOStream.h.
References outputPointer().
PersistentOStream& ThePEG::PersistentOStream::operator<< | ( | const TransientRCPtr< T > & | p | ) | [inline] |
Operator for writing persistent objects to the stream.
p | a pointer to the object to be written. |
Definition at line 114 of file PersistentOStream.h.
References outputPointer().
PersistentOStream& ThePEG::PersistentOStream::operator<< | ( | const TransientConstRCPtr< T > & | p | ) | [inline] |
Operator for writing persistent objects to the stream.
p | a pointer to the object to be written. |
Definition at line 124 of file PersistentOStream.h.
References outputPointer().
void ThePEG::PersistentOStream::putObjectPart | ( | tcBPtr | obj, | |
const ClassDescriptionBase * | cd | |||
) |
For a given object, write the member variables corresponding to a given ClassDescriptionBase object.
obj | the object to be written. | |
cd | a pointer to a ClassDescriptionBase describing the (sub)class to written. |
const char ThePEG::PersistentOStream::tNext = '|' [static, private] |
The marker character indicating the beginning of the next base class in case of multiple inheritance.
The special marker character indicating an escaped marker character.
Definition at line 367 of file PersistentOStream.h.