MPQC  3.0.0-alpha
sc::StateIn Class Reference

#include <util/state/statein.h>

Inheritance diagram for sc::StateIn:
sc::DescribedClass sc::RefCount sc::MsgStateBufRecv sc::StateInFile sc::BcastStateInBin sc::MsgStateRecv sc::StateInBin sc::StateInText sc::BcastStateRecv sc::StateRecv

Public Member Functions

virtual void get_header ()
 Read in the header information. More...
 
virtual int version (const ClassDesc *)
 Returns the version of the ClassDesc in the persistent object or -1 if info on the ClassDesc doesn't exist.
 
virtual int getstring (char *&)
 This restores strings saved with StateOut::putstring.
 
int node_to_node () const
 True if this is a node to node save/restore. More...
 
virtual int use_directory ()
 Returns true of this object uses a directory.
 
virtual int tell ()
 Return the current position in the file.
 
virtual void seek (int)
 Set the current position in the file. More...
 
virtual int seekable ()
 Return non-zero if seek does anything sensible. More...
 
int has_directory () const
 
virtual void list_objects (std::ostream &=ExEnv::out0())
 List all the objects to the stream. More...
 
void set_override (const Ref< KeyVal > &kv)
 Give this StateIn a KeyVal object that is used to override values.
 
const Ref< KeyVal > & override () const
 Return the KeyVal used to override values.
 
StateIn::get(datum)

These restore data saved with StateOut's put.

members.

virtual int get (std::string &)
 
virtual int get (char &r, const char *keyword=0)
 
virtual int get (unsigned int &r, const char *keyword=0)
 
virtual int get (int &r, const char *keyword=0)
 
virtual int get (unsigned long int &r, const char *keyword=0)
 
virtual int get (long int &r, const char *keyword=0)
 
virtual int get (bool &r, const char *keyword=0)
 
virtual int get (float &r, const char *keyword=0)
 
virtual int get (double &r, const char *keyword=0)
 
StateIn::get(array)

These restore data saved with StateOut's put() members.

The data is allocated by StateIn using new[].

virtual int get (char *&)
 
virtual int get (unsigned int *&)
 
virtual int get (int *&)
 
virtual int get (unsigned long int *&)
 
virtual int get (long int *&)
 
virtual int get (float *&)
 
virtual int get (double *&)
 
StateIn::get_array()

These restore data saved with StateOut's put() members.

The data must be preallocated by the user.

virtual int get_array_char (char *p, int size)
 
virtual int get_array_uint (unsigned int *p, int size)
 
virtual int get_array_int (int *p, int size)
 
virtual int get_array_ulong (unsigned long *p, int size)
 
virtual int get_array_long (long *p, int size)
 
virtual int get_array_float (float *p, int size)
 
virtual int get_array_double (double *p, int size)
 
StateIn::get(std::container)

Read 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 get (Container< T, A > &v)
 Read a Container that could be a standard (non-associative) C++ container such as std::vector or std::list.
 
template<class T , class A >
int get (std::vector< T, A > &v)
 "Specialization" of the above get() to an std::vector
 
template<typename Key , typename Compare , typename Alloc >
int get (std::set< Key, Compare, Alloc > &s)
 Read an std::set. This also works if Key or Value is a Ref to a SavableState.
 
template<typename Key , typename Value >
int get (std::map< Key, Value > &map)
 Read an std::map. This also works if Key or Value is a Ref to a SavableState.
 
template<typename L , typename R >
int get (std::pair< L, R > &v)
 Read an std::pair.
 
- Public Member Functions inherited from sc::DescribedClass
 DescribedClass (const DescribedClass &)
 
DescribedClassoperator= (const DescribedClass &)
 
ClassDescclass_desc () const MPQC__NOEXCEPT
 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.
 
Ref< DescribedClassref ()
 Return this object wrapped up in a Ref smart pointer. More...
 
- Public Member Functions inherited from sc::RefCount
size_t identifier () const
 Return the unique identifier for this object that can be compared for different objects of different types. More...
 
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...
 

Protected Member Functions

virtual int get_array_void (void *, int)
 
int push_key (const char *key)
 
void pop_key (int n)
 
const char * key ()
 
void get_directory ()
 
int directory_location () const
 
void find_and_get_directory ()
 
virtual int getobject (Ref< SavableState > &)
 This is used to restore an object. More...
 
virtual int dir_getobject (Ref< SavableState > &, const char *name)
 This restores objects that are listed in the directory.
 
virtual void haveobject (int, const Ref< SavableState > &)
 When storage has been allocated during object restoration, this routine is called with the object reference number and the pointer to the new storage so getpointer can find the data if it is referenced again.
 
virtual void nextobject (int)
 A call to nextobject followed by havepointer(int) is equiv to havepointer(int,void**);.
 
virtual void haveobject (const Ref< SavableState > &)
 
void have_classdesc ()
 
int need_classdesc ()
 
virtual int get (const ClassDesc **)
 This restores ClassDesc's. More...
 
- Protected Member Functions inherited from sc::RefCount
 RefCount (const RefCount &)
 
RefCountoperator= (const RefCount &)
 

Protected Attributes

Ref< KeyValoverride_
 
TranslateDataIntranslate_
 
std::map< int, StateInDataps_
 
int expected_object_num_
 
std::map< ClassDescP, int > classidmap_
 
std::map< int, StateClassDataclassdatamap_
 
int nextclassid_
 
int node_to_node_
 
int version_
 
int date_
 
char userid_ [9]
 
char format_
 

Friends

class SavableState
 
class TranslateDataIn
 

Detailed Description

Restores fundamental and user-defined types from images created with StateOut.

See also
StateOut

Member Function Documentation

◆ get()

virtual int sc::StateIn::get ( const ClassDesc **  )
protectedvirtual

This restores ClassDesc's.

It will set the pointer to the address of the static ClassDesc for the class which has the same name as the class that had the ClassDesc that was saved by put(const ClassDesc*).

Reimplemented in sc::MsgStateRecv, and sc::StateInText.

Referenced by sc::FromStateIn(), and get().

◆ get_header()

virtual void sc::StateIn::get_header ( )
virtual

Read in the header information.

Changes the translation scheme if necessary.

◆ getobject()

virtual int sc::StateIn::getobject ( Ref< SavableState > &  )
protectedvirtual

This is used to restore an object.

It is called with the reference to the reference being restored. If the data being restored has previously been restored, then the pointer being restored is set to a reference to the previously restored object.

Reimplemented in sc::StateInText.

◆ list_objects()

virtual void sc::StateIn::list_objects ( std::ostream &  = ExEnv::out0())
virtual

List all the objects to the stream.

Only StateIn specializations with directories can list objects.

◆ node_to_node()

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

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

This is 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.

◆ seek()

virtual void sc::StateIn::seek ( int  )
virtual

Set the current position in the file.

The default implementation does nothing.

Reimplemented in sc::BcastStateInBin, and sc::StateInBin.

◆ seekable()

virtual int sc::StateIn::seekable ( )
virtual

Return non-zero if seek does anything sensible.

The default implementation returns 0.

Reimplemented in sc::BcastStateInBin, and sc::StateInBin.


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

Generated at Sun Jan 26 2020 23:24:12 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.