eoState Class Reference

eoState can be used to register derivants of eoPersistent. More...

#include <eoState.h>

Inheritance diagram for eoState:

eoFunctorStore

List of all members.

Public Member Functions

void registerObject (eoPersistent &registrant)
 Object registration function, note that it does not take ownership!
template<class T>
T & takeOwnership (const T &persistent)
 Copies the object (MUST be derived from eoPersistent) and returns a reference to the owned object.
std::string getCommentString (void) const
void load (const std::string &_filename)
 Reads the file specified.
void load (std::istream &is)
 Reads the file specified.
void save (const std::string &_filename) const
 Saves the state in file specified.
void save (std::ostream &os) const
 Saves the state in file specified.

Private Types

typedef std::map< std::string,
eoPersistent * > 
ObjectMap

Private Member Functions

std::string createObjectName (eoObject *obj)
 eoState (const eoState &)
eoStateoperator= (const eoState &)

Private Attributes

ObjectMap objectMap
std::vector< ObjectMap::iterator > creationOrder
std::vector< eoPersistent * > ownedObjects

Classes

struct  loading_error
 Loading error thrown when nothing seems to work. More...


Detailed Description

eoState can be used to register derivants of eoPersistent.

It will then in turn implement the persistence framework through members load and save, that will call readFrom and printOn for the registrated objects.

It is derived from eoFunctorStore, so that it also serves as a place where all those nifty eo functors can be stored. This is useful in the case you want to use one of the make_* functions. These functions generally take as their last argument an eoFunctorStore (or a state) which is used to hold all dynamically generated data. Note however, that unlike with eoPersistent derived classes, eoFunctorBase derived classes are not saved or loaded. To govern the creation of functors, command-line parameters (which can be stored) are needed.

Definition at line 54 of file eoState.h.


Member Function Documentation

template<class T>
T& eoState::takeOwnership ( const T &  persistent  )  [inline]

Copies the object (MUST be derived from eoPersistent) and returns a reference to the owned object.

Note: it does not register the object, this must be done afterwards!

Definition at line 73 of file eoState.h.

void eoState::load ( const std::string &  _filename  ) 

Reads the file specified.

Parameters:
_filename the name of the file to load from

void eoState::load ( std::istream &  is  ) 

Reads the file specified.

Parameters:
is the stream to load from

Definition at line 87 of file eoState.cpp.

void eoState::save ( const std::string &  _filename  )  const

Saves the state in file specified.

Parameters:
_filename the name of the file to save into

Referenced by eoTimedStateSaver::operator()().

void eoState::save ( std::ostream &  os  )  const

Saves the state in file specified.

Parameters:
os the stream to save into

Definition at line 161 of file eoState.cpp.


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

Generated on Thu Jan 1 23:19:51 2009 for EvolvingObjects by  doxygen 1.5.5