Main Page | Class Hierarchy | Class List | File List | Class 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 <string> 00036 #include <vector> 00037 #include <map> 00038 00039 #include <util/class/class.h> 00040 #include <util/state/state.h> 00041 00042 namespace sc { 00043 00044 class StateOutData { 00045 public: 00046 int num; 00047 int size; 00048 int type; 00049 int offset; 00050 00051 StateOutData(): num(0), size(0), type(0), offset(0) {} 00052 }; 00053 00061 class StateOut: public DescribedClass { 00062 friend class SavableState; 00063 friend class TranslateDataOut; 00064 private: 00065 // do not allow copy constructor or assignment 00066 StateOut(const StateOut&); 00067 void operator=(const StateOut&); 00068 int have_cd_; 00069 protected: 00070 int dir_loc_loc_; 00071 TranslateDataOut *translate_; 00072 int copy_references_; 00073 int next_object_number_; 00074 std::map<Ref<SavableState>,StateOutData> ps_; 00075 std::map<ClassDescP,int> classidmap_; 00076 int nextclassid_; 00077 int node_to_node_; 00078 virtual int put_array_void(const void*,int); 00079 virtual int putparents(const ClassDesc*); 00080 00081 void put_directory(); 00082 00083 // The following members are called by friend SavableState 00084 00085 void have_classdesc() { have_cd_ = 1; } 00086 int need_classdesc() { int tmp = have_cd_; have_cd_ = 0; return !tmp; } 00087 00092 virtual int putobject(const Ref<SavableState> &); 00093 00095 virtual int put(const ClassDesc*); 00096 public: 00097 StateOut(); 00098 virtual ~StateOut(); 00099 00101 virtual void put_header(); 00102 00105 virtual int putstring(const char*); 00106 00108 virtual int put(const std::string &); 00109 00111 virtual int put(char r); 00112 virtual int put(unsigned int r); 00113 virtual int put(int r); 00114 virtual int put(unsigned long r); 00115 virtual int put(float r); 00116 virtual int put(double r); 00119 virtual int put(const char*,int); 00120 virtual int put(const unsigned int*,int); 00121 virtual int put(const int*,int); 00122 virtual int put(const float*,int); 00123 virtual int put(const double*,int); 00126 virtual int put_array_char(const char*p,int size); 00127 virtual int put_array_uint(const unsigned int*p,int size); 00128 virtual int put_array_int(const int*p,int size); 00129 virtual int put_array_float(const float*p,int size); 00130 virtual int put_array_double(const double*p,int size); 00131 00133 template <class T> 00134 int put(typename std::vector<T> &v) { 00135 int l = v.size(); 00136 int r = put(l); 00137 if (l) { for (int i=0; i<l; i++) r += put(v[i]); } 00138 return r; 00139 } 00140 00144 void forget_references(); 00149 void copy_references(); 00150 00152 virtual int use_directory(); 00153 00155 virtual void flush(); 00156 00161 int node_to_node() const { return node_to_node_; } 00162 00165 virtual int tell(); 00168 virtual void seek(int loc); 00171 virtual int seekable(); 00172 }; 00173 00174 } 00175 00176 #endif 00177 00178 // Local Variables: 00179 // mode: c++ 00180 // c-file-style: "CLJ" 00181 // End:

Generated at Sat Aug 7 00:04:22 2004 for MPQC 2.2.2 using the documentation package Doxygen 1.3.8.