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 class StateOutData {
00040   public:
00041     int num;
00042     int size;
00043     int type;
00044     int offset;
00045 
00046     StateOutData(): num(0), size(0), type(0), offset(0) {}
00047 };
00048 
00056 class StateOut: public DescribedClass {
00057     friend class SavableState;
00058     friend class TranslateDataOut;
00059   private:
00060     // do not allow copy constructor or assignment
00061     StateOut(const StateOut&);
00062     void operator=(const StateOut&);
00063     int have_cd_;
00064   protected:
00065     int dir_loc_loc_;
00066     TranslateDataOut *translate_;
00067     int copy_references_;
00068     int next_object_number_;
00069     AVLMap<Ref<SavableState>,StateOutData> ps_;
00070     AVLMap<ClassDescP,int> classidmap_;
00071     int nextclassid_;
00072     int node_to_node_;
00073     virtual int put_array_void(const void*,int);
00074     virtual int putparents(const ClassDesc*);
00075 
00076     void put_directory();
00077 
00078     // The following members are called by friend SavableState
00079 
00080     void have_classdesc() { have_cd_ = 1; }
00081     int need_classdesc() { int tmp = have_cd_; have_cd_ = 0; return !tmp; }
00082 
00087     virtual int putobject(const Ref<SavableState> &);
00088 
00090     virtual int put(const ClassDesc*);
00091   public:
00092     StateOut();
00093     virtual ~StateOut();
00094 
00096     virtual void put_header();
00097 
00100     virtual int putstring(const char*);
00101 
00103     virtual int put(char r);
00104     virtual int put(unsigned int r);
00105     virtual int put(int r);
00106     virtual int put(float r);
00107     virtual int put(double r);
00110     virtual int put(const char*,int);
00111     virtual int put(const unsigned int*,int);
00112     virtual int put(const int*,int);
00113     virtual int put(const float*,int);
00114     virtual int put(const double*,int);
00117     virtual int put_array_char(const char*p,int size);
00118     virtual int put_array_uint(const unsigned int*p,int size);
00119     virtual int put_array_int(const int*p,int size);
00120     virtual int put_array_float(const float*p,int size);
00121     virtual int put_array_double(const double*p,int size);
00122 
00126     void forget_references();
00131     void copy_references();
00132 
00134     virtual int use_directory();
00135 
00137     virtual void flush();
00138 
00143     int node_to_node() const { return node_to_node_; }
00144 
00147     virtual int tell();
00150     virtual void seek(int loc);
00153     virtual int seekable();
00154   };
00155 
00156 
00157 #endif
00158 
00159 // Local Variables:
00160 // mode: c++
00161 // c-file-style: "CLJ"
00162 // End:

Generated at Thu Oct 4 18:08:47 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.