Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

stateout.h

00001 //
00002 // stateout.h
00003 //
00004 // Copyright (C) 1998 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00028 #ifndef _util_state_stateout_h
00029 #define _util_state_stateout_h
00030 
00031 #ifdef __GNUC__
00032 #pragma interface
00033 #endif
00034 
00035 #include <util/class/class.h>
00036 #include <util/state/state.h>
00037 #include <util/container/avlmap.h>
00038 
00039 namespace sc {
00040 
00041 class StateOutData {
00042   public:
00043     int num;
00044     int size;
00045     int type;
00046     int offset;
00047 
00048     StateOutData(): num(0), size(0), type(0), offset(0) {}
00049 };
00050 
00058 class StateOut: public DescribedClass {
00059     friend class SavableState;
00060     friend class TranslateDataOut;
00061   private:
00062     // do not allow copy constructor or assignment
00063     StateOut(const StateOut&);
00064     void operator=(const StateOut&);
00065     int have_cd_;
00066   protected:
00067     int dir_loc_loc_;
00068     TranslateDataOut *translate_;
00069     int copy_references_;
00070     int next_object_number_;
00071     AVLMap<Ref<SavableState>,StateOutData> ps_;
00072     AVLMap<ClassDescP,int> classidmap_;
00073     int nextclassid_;
00074     int node_to_node_;
00075     virtual int put_array_void(const void*,int);
00076     virtual int putparents(const ClassDesc*);
00077 
00078     void put_directory();
00079 
00080     // The following members are called by friend SavableState
00081 
00082     void have_classdesc() { have_cd_ = 1; }
00083     int need_classdesc() { int tmp = have_cd_; have_cd_ = 0; return !tmp; }
00084 
00089     virtual int putobject(const Ref<SavableState> &);
00090 
00092     virtual int put(const ClassDesc*);
00093   public:
00094     StateOut();
00095     virtual ~StateOut();
00096 
00098     virtual void put_header();
00099 
00102     virtual int putstring(const char*);
00103 
00105     virtual int put(char r);
00106     virtual int put(unsigned int r);
00107     virtual int put(int r);
00108     virtual int put(float r);
00109     virtual int put(double r);
00112     virtual int put(const char*,int);
00113     virtual int put(const unsigned int*,int);
00114     virtual int put(const int*,int);
00115     virtual int put(const float*,int);
00116     virtual int put(const double*,int);
00119     virtual int put_array_char(const char*p,int size);
00120     virtual int put_array_uint(const unsigned int*p,int size);
00121     virtual int put_array_int(const int*p,int size);
00122     virtual int put_array_float(const float*p,int size);
00123     virtual int put_array_double(const double*p,int size);
00124 
00128     void forget_references();
00133     void copy_references();
00134 
00136     virtual int use_directory();
00137 
00139     virtual void flush();
00140 
00145     int node_to_node() const { return node_to_node_; }
00146 
00149     virtual int tell();
00152     virtual void seek(int loc);
00155     virtual int seekable();
00156   };
00157 
00158 }
00159 
00160 #endif
00161 
00162 // Local Variables:
00163 // mode: c++
00164 // c-file-style: "CLJ"
00165 // End:

Generated at Fri Jan 10 08:14:10 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14.