MPQC  2.3.1
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
sc::StateOut Class Reference

Serializes objects that derive from SavableState. More...

#include <stateout.h>

Inheritance diagram for sc::StateOut:
Inheritance graph
[legend]
Collaboration diagram for sc::StateOut:
Collaboration graph
[legend]

Public Member Functions

virtual void put_header ()
 Write out header information.
 
virtual int putstring (const char *)
 This is like put except the length of the char array is determined by interpreting the character array as a character string.
 
virtual int put (const std::string &)
 Write out a std::string object.
 
virtual int put (char r)
 Write the given datum.
 
virtual int put (unsigned int r)
 
virtual int put (int r)
 
virtual int put (bool r)
 
virtual int put (unsigned long r)
 
virtual int put (float r)
 
virtual int put (double r)
 
virtual int put (const char *, int)
 Write the given array data. More...
 
virtual int put (const unsigned int *, int)
 
virtual int put (const int *, int)
 
virtual int put (const float *, int)
 
virtual int put (const double *, int)
 
virtual int put_array_char (const char *p, int size)
 Put arrays of data. More...
 
virtual int put_array_uint (const unsigned int *p, int size)
 
virtual int put_array_int (const int *p, int size)
 
virtual int put_array_float (const float *p, int size)
 
virtual int put_array_double (const double *p, int size)
 
template<class T >
int put (typename std::vector< T > &v)
 Write an STL vector of data.
 
void forget_references ()
 Don't keep track of pointers to objects. More...
 
void copy_references ()
 If a reference to an object that has already been written is encountered, copy it instead of generating a reference to the first object. More...
 
virtual int use_directory ()
 Returns true if this object uses a directory.
 
virtual void flush ()
 Flush out any remaining data.
 
int node_to_node () const
 True if this is a node to node save/restore. More...
 
virtual int tell ()
 Returns the current position in the file. More...
 
virtual void seek (int loc)
 Set the current position in the file. More...
 
virtual int seekable ()
 Return non-zero if tell and seek do anything sensible. More...
 
- Public Member Functions inherited from sc::DescribedClass
 DescribedClass (const DescribedClass &)
 
DescribedClassoperator= (const DescribedClass &)
 
ClassDescclass_desc () const throw ()
 This returns the unique pointer to the ClassDesc corresponding to the given type_info object. More...
 
const char * class_name () const
 Return the name of the object's exact type.
 
int class_version () const
 Return the version of the class.
 
virtual void print (std::ostream &=ExEnv::out0()) const
 Print the object.
 
- Public Member Functions inherited from sc::RefCount
int lock_ptr () const
 Lock this object.
 
int unlock_ptr () const
 Unlock this object.
 
void use_locks (bool inVal)
 start and stop using locks on this object
 
refcount_t nreference () const
 Return the reference count.
 
refcount_t reference ()
 Increment the reference count and return the new count.
 
refcount_t dereference ()
 Decrement the reference count and return the new count.
 
int managed () const
 
void unmanage ()
 Turn off the reference counting mechanism for this object. More...
 
int managed () const
 Return 1 if the object is managed. Otherwise return 0.
 
- Public Member Functions inherited from sc::Identity
Identifier identifier ()
 Return the Identifier for this argument. More...
 

Protected Member Functions

virtual int put_array_void (const void *, int)
 
virtual int putparents (const ClassDesc *)
 
void put_directory ()
 
void have_classdesc ()
 
int need_classdesc ()
 
virtual int putobject (const Ref< SavableState > &)
 This will prepare StateOut to output a pointer to data. More...
 
virtual int put (const ClassDesc *)
 Write out information about the given ClassDesc.
 
- Protected Member Functions inherited from sc::RefCount
 RefCount (const RefCount &)
 
RefCountoperator= (const RefCount &)
 

Protected Attributes

int dir_loc_loc_
 
TranslateDataOuttranslate_
 
int copy_references_
 
int next_object_number_
 
std::map< Ref< SavableState >, StateOutDataps_
 
std::map< ClassDescP, int > classidmap_
 
int nextclassid_
 
int node_to_node_
 

Friends

class SavableState
 
class TranslateDataOut
 

Detailed Description

Serializes objects that derive from SavableState.

StateOut keeps track of pointers to data so that two references to the same piece of data do not result in that data being sent to the output device two times.

Member Function Documentation

◆ copy_references()

void sc::StateOut::copy_references ( )

If a reference to an object that has already been written is encountered, copy it instead of generating a reference to the first object.

The directory will not be updated with new objects.

◆ forget_references()

void sc::StateOut::forget_references ( )

Don't keep track of pointers to objects.

Calling this causes duplicated references to objects to be copied. The directory will not contain the forgotten objects.

◆ node_to_node()

int sc::StateOut::node_to_node ( ) const
inline

True if this is a node to node save/restore.

This is necessary for classes that try to avoid saving databases to files that can otherwise be read in, but want to avoid reading the database from disk on all nodes.

◆ put()

virtual int sc::StateOut::put ( const char *  ,
int   
)
virtual

Write the given array data.

Size information is also saved. The data is allocated and read by the get(T*&) routines.

Reimplemented in sc::MsgStateSend, and sc::StateOutText.

◆ put_array_char()

virtual int sc::StateOut::put_array_char ( const char *  p,
int  size 
)
virtual

Put arrays of data.

No size information is stored. This data is read by the get_array_T routines.

Reimplemented in sc::StateOutText.

◆ putobject()

virtual int sc::StateOut::putobject ( const Ref< SavableState > &  )
protectedvirtual

This will prepare StateOut to output a pointer to data.

It first checks to see if the data has already been saved. If it has, then a reference to this data is saved. Otherwise the object is written out.

Reimplemented in sc::StateOutText.

◆ seek()

virtual void sc::StateOut::seek ( int  loc)
virtual

Set the current position in the file.

The default implementation does nothing.

Reimplemented in sc::StateOutBin.

◆ seekable()

virtual int sc::StateOut::seekable ( )
virtual

Return non-zero if tell and seek do anything sensible.

The default implementation returns 0.

Reimplemented in sc::StateOutBin.

◆ tell()

virtual int sc::StateOut::tell ( )
virtual

Returns the current position in the file.

The default implementation returns 0.

Reimplemented in sc::StateOutBin.


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

Generated at Sun Jan 26 2020 23:33:09 for MPQC 2.3.1 using the documentation package Doxygen 1.8.16.