|
statein.h00001 // 00002 // statein.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_statein_h 00029 #define _util_state_statein_h 00030 00031 #ifdef __GNUC__ 00032 #pragma interface 00033 #endif 00034 00035 #include <util/state/state.h> 00036 #include <util/container/avlmap.h> 00037 #include <util/keyval/keyval.h> 00038 00039 namespace sc { 00040 00041 class StateInData { 00042 public: 00043 Ref<SavableState> ptr; 00044 int size; 00045 int type; 00046 int offset; 00047 00048 StateInData(): size(0), type(0), offset(0) {} 00049 }; 00050 00051 class StateClassData { 00052 public: 00053 int version; 00054 char *name; 00055 const ClassDesc *classdesc; 00056 int ninstance; 00057 public: 00058 StateClassData(int v=-1, const ClassDesc *c=0, char *name=0): 00059 version(v), name(name), classdesc(c), ninstance(0) {} 00060 StateClassData(const StateClassData &d) { operator=(d); } 00061 ~StateClassData(); 00062 StateClassData &operator=(const StateClassData &d); 00063 }; 00064 00067 class StateIn: public DescribedClass { 00068 friend class SavableState; 00069 friend class TranslateDataIn; 00070 private: 00071 // do not allow copy constructor or assignment 00072 StateIn(const StateIn&); 00073 void operator=(const StateIn&); 00074 int have_cd_; 00075 int dir_loc_; 00076 char key_[KeyVal::MaxKeywordLength]; 00077 int keylength_; 00078 protected: 00079 Ref<KeyVal> override_; 00080 TranslateDataIn *translate_; 00081 AVLMap<int,StateInData> ps_; 00082 int expected_object_num_; 00083 AVLMap<ClassDescP,int> classidmap_; 00084 AVLMap<int,StateClassData> classdatamap_; 00085 int nextclassid_; 00086 int node_to_node_; 00087 int version_; 00088 int date_; 00089 char userid_[9]; 00090 char format_; 00091 virtual int get_array_void(void*,int); 00092 00093 int push_key(const char *key); 00094 void pop_key(int n) { key_[n] = '\0'; keylength_ = n; } 00095 const char *key() { return key_; } 00096 00097 void get_directory(); 00098 int directory_location() const { return dir_loc_; } 00099 void find_and_get_directory(); 00100 00101 // The following members are called by friend SavableState 00102 00108 virtual int getobject(Ref<SavableState> &); 00109 00111 virtual int dir_getobject(Ref<SavableState> &, const char *name); 00112 00117 virtual void haveobject(int,const Ref<SavableState> &); 00118 00121 virtual void nextobject(int); 00122 virtual void haveobject(const Ref<SavableState> &); 00123 00124 void have_classdesc() { have_cd_ = 1; } 00125 int need_classdesc() { int tmp = have_cd_; have_cd_ = 0; return !tmp; } 00126 00131 virtual int get(const ClassDesc**); 00132 public: 00133 StateIn(); 00134 virtual ~StateIn(); 00135 00138 virtual void get_header(); 00139 00142 virtual int version(const ClassDesc*); 00143 00145 virtual int getstring(char*&); 00146 00148 virtual int get(char&r, const char *keyword = 0); 00149 virtual int get(unsigned int&r, const char *keyword = 0); 00150 virtual int get(int&r, const char *keyword = 0); 00151 virtual int get(float&r, const char *keyword = 0); 00152 virtual int get(double&r, const char *keyword = 0); 00155 virtual int get(char*&); 00156 virtual int get(unsigned int*&); 00157 virtual int get(int*&); 00158 virtual int get(float*&); 00159 virtual int get(double*&); 00162 virtual int get_array_char(char*p,int size); 00163 virtual int get_array_uint(unsigned int*p,int size); 00164 virtual int get_array_int(int*p,int size); 00165 virtual int get_array_float(float*p,int size); 00166 virtual int get_array_double(double*p,int size); 00167 00172 int node_to_node() const { return node_to_node_; } 00173 00175 virtual int use_directory(); 00176 00178 virtual int tell(); 00181 virtual void seek(int); 00184 virtual int seekable(); 00185 int has_directory() const { return dir_loc_ != 0; } 00186 00189 virtual void list_objects(std::ostream& = ExEnv::out0()); 00190 00193 void set_override(const Ref<KeyVal>&kv) { override_ = kv; } 00195 const Ref<KeyVal> &override() const { return override_; } 00196 }; 00197 00198 } 00199 00200 #endif 00201 00202 // Local Variables: 00203 // mode: c++ 00204 // c-file-style: "CLJ" 00205 // End: Generated at Fri Jan 10 08:14:09 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14. |