00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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 class StateInData {
00040 public:
00041 Ref<SavableState> ptr;
00042 int size;
00043 int type;
00044 int offset;
00045
00046 StateInData(): size(0), type(0), offset(0) {}
00047 };
00048
00049 class StateClassData {
00050 public:
00051 int version;
00052 char *name;
00053 const ClassDesc *classdesc;
00054 int ninstance;
00055 public:
00056 StateClassData(int v=-1, const ClassDesc *c=0, char *name=0):
00057 version(v), name(name), classdesc(c), ninstance(0) {}
00058 StateClassData(const StateClassData &d) { operator=(d); }
00059 ~StateClassData();
00060 StateClassData &operator=(const StateClassData &d);
00061 };
00062
00065 class StateIn: public DescribedClass {
00066 friend class SavableState;
00067 friend class TranslateDataIn;
00068 private:
00069
00070 StateIn(const StateIn&);
00071 void operator=(const StateIn&);
00072 int have_cd_;
00073 int dir_loc_;
00074 char key_[KeyVal::MaxKeywordLength];
00075 int keylength_;
00076 protected:
00077 Ref<KeyVal> override_;
00078 TranslateDataIn *translate_;
00079 AVLMap<int,StateInData> ps_;
00080 int expected_object_num_;
00081 AVLMap<ClassDescP,int> classidmap_;
00082 AVLMap<int,StateClassData> classdatamap_;
00083 int nextclassid_;
00084 int node_to_node_;
00085 int version_;
00086 int date_;
00087 char userid_[9];
00088 char format_;
00089 virtual int get_array_void(void*,int);
00090
00091 int push_key(const char *key);
00092 void pop_key(int n) { key_[n] = '\0'; keylength_ = n; }
00093 const char *key() { return key_; }
00094
00095 void get_directory();
00096 int directory_location() const { return dir_loc_; }
00097 void find_and_get_directory();
00098
00099
00100
00106 virtual int getobject(Ref<SavableState> &);
00107
00109 virtual int dir_getobject(Ref<SavableState> &, const char *name);
00110
00115 virtual void haveobject(int,const Ref<SavableState> &);
00116
00119 virtual void nextobject(int);
00120 virtual void haveobject(const Ref<SavableState> &);
00121
00122 void have_classdesc() { have_cd_ = 1; }
00123 int need_classdesc() { int tmp = have_cd_; have_cd_ = 0; return !tmp; }
00124
00129 virtual int get(const ClassDesc**);
00130 public:
00131 StateIn();
00132 virtual ~StateIn();
00133
00136 virtual void get_header();
00137
00140 virtual int version(const ClassDesc*);
00141
00143 virtual int getstring(char*&);
00144
00146 virtual int get(char&r, const char *keyword = 0);
00147 virtual int get(unsigned int&r, const char *keyword = 0);
00148 virtual int get(int&r, const char *keyword = 0);
00149 virtual int get(float&r, const char *keyword = 0);
00150 virtual int get(double&r, const char *keyword = 0);
00153 virtual int get(char*&);
00154 virtual int get(unsigned int*&);
00155 virtual int get(int*&);
00156 virtual int get(float*&);
00157 virtual int get(double*&);
00160 virtual int get_array_char(char*p,int size);
00161 virtual int get_array_uint(unsigned int*p,int size);
00162 virtual int get_array_int(int*p,int size);
00163 virtual int get_array_float(float*p,int size);
00164 virtual int get_array_double(double*p,int size);
00165
00170 int node_to_node() const { return node_to_node_; }
00171
00173 virtual int use_directory();
00174
00176 virtual int tell();
00179 virtual void seek(int);
00182 virtual int seekable();
00183 int has_directory() const { return dir_loc_ != 0; }
00184
00187 virtual void list_objects(std::ostream& = ExEnv::out());
00188
00191 void set_override(const Ref<KeyVal>&kv) { override_ = kv; }
00193 const Ref<KeyVal> &override() const { return override_; }
00194 };
00195
00196
00197 #endif
00198
00199
00200
00201
00202