MPQC  3.0.0-alpha
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
sc::StateOut Class Reference

Serializes objects that derive from SavableState. More...

#include <util/state/stateout.h>

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

List of all members.

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.
void forget_references ()
 Don't keep track of pointers to objects.
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.
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.
virtual int tell ()
 Returns the current position in the file.
virtual void seek (int loc)
 Set the current position in the file.
virtual int seekable ()
 Return non-zero if tell and seek do anything sensible.
StateOut::put(datum)

Write the given datum.

virtual int put (const std::string &)
virtual int put (char r)
virtual int put (unsigned int r)
virtual int put (int r)
virtual int put (unsigned long r)
virtual int put (long r)
virtual int put (bool r)
virtual int put (float r)
virtual int put (double r)
StateOut::put(array)

Write the given array data.

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

virtual int put (const char *, int)
virtual int put (const unsigned int *, int)
virtual int put (const int *, int)
virtual int put (const unsigned long *, int)
virtual int put (const long *, int)
virtual int put (const float *, int)
virtual int put (const double *, int)
StateOut::put_array()

Put arrays of data.

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

virtual int put_array_char (const char *p, int size)
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_ulong (const unsigned long *p, int size)
virtual int put_array_long (const long *p, int size)
virtual int put_array_float (const float *p, int size)
virtual int put_array_double (const double *p, int size)
StateOut::put(std::container)

Write standard C++ library containers.

All methods work with value (and/or key) type either a Ref to a SavableState or one of built-in types.

template<template< typename, typename > class Container, class T , class A >
int put (const Container< T, A > &v)
 Write a Container that could be a standard (non-associative) C++ container such as std::vector or std::list.
template<typename Key , typename Compare , typename Alloc >
int put (const std::set< Key, Compare, Alloc > &s)
 Write an std::set. This also works if Key or Value is a Ref to a SavableState.
template<typename Key , typename Value >
int put (const std::map< Key, Value > &map)
 Write an std::map. This also works if Key or Value is a Ref to a SavableState.
template<typename L , typename R >
int put (const std::pair< L, R > &v)
 Write an std::pair.

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.
virtual int put (const ClassDesc *)
 Write out information about the given ClassDesc.

Protected Attributes

int dir_loc_loc_
TranslateDataOuttranslate_
int copy_references_
int next_object_number_
std::map< Ref< SavableState >
, StateOutData
ps_
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

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.

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.

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.

virtual int sc::StateOut::putobject ( const Ref< SavableState > &  ) [protected, virtual]

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.

virtual int sc::StateOut::putstring ( const char *  ) [virtual]

This is like put except the length of the char array is determined by interpreting the character array as a character string.

Reimplemented in sc::StateOutText.

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

Set the current position in the file.

The default implementation does nothing.

Reimplemented in sc::StateOutBin.

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.

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 Sat Jul 7 2012 11:53:01 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.0.