00001 #ifndef GEL_OBS_H_HAS_BEEN_INCLUDED
00002 #define GEL_OBS_H_HAS_BEEN_INCLUDED
00003
00004 #include "disp/gel.H"
00005
00006 #define CGELdistobs_list const GELdistobs_list
00007 #define CGELdistobs const GELdistobs
00008 class GELdistobs;
00009 typedef ARRAY<GELdistobs *> GELdistobs_list;
00010
00011
00012
00013
00014
00015 class GELdistobs {
00016 protected:
00017
00018 static GELdistobs_list *_dist_obs;
00019 static GELdistobs_list *distobs_list() { if (!_dist_obs)
00020 _dist_obs = new GELdistobs_list; return _dist_obs; }
00021 public:
00022 virtual ~GELdistobs() {}
00023 static void notify_distrib_obs(STDdstream &d, CGELptr &gel) {
00024 for (int i=0; i<distobs_list()->num(); i++)
00025 (*_dist_obs)[i]->notify_distrib(d,gel); }
00026 virtual void notify_distrib (STDdstream &d, CGELptr &gel) = 0;
00027
00028 void distrib_obs () { distobs_list()->add_uniquely(this);}
00029 void unobs_distrib() { distobs_list()->rem (this);}
00030 };
00031
00032
00033 #define CEXISTobs_list const EXISTobs_list
00034 #define CEXISTobs const EXISTobs
00035 class EXISTobs;
00036 typedef ARRAYptrs<EXISTobs*> EXISTobs_list;
00037
00038
00039
00040
00041
00042 class EXISTobs {
00043 protected :
00044 static GELlist _created;
00045
00046 static EXISTobs_list *_exist_obs;
00047 static EXISTobs_list *existobs_list() { if (!_exist_obs)
00048 _exist_obs = new EXISTobs_list;
00049 return _exist_obs; }
00050 public:
00051 virtual ~EXISTobs() {}
00052 static void notify_exist_obs(CGELptr &o, int f){
00053 if (!_exist_obs) return; int i;
00054 for (i=0;i<existobs_list()->num();i++)
00055 (*_exist_obs)[i]->notify_exist(o,f); }
00056 virtual void notify_exist (CGELptr &, int flag) = 0;
00057
00058 void exist_obs() { existobs_list()->add_uniquely(this); }
00059 void unobs_exist() { existobs_list()->rem (this); }
00060 };
00061
00062 #define CDISPobs_list const DISPobs_list
00063 #define CDISPobs const DISPobs
00064 class DISPobs;
00065 typedef ARRAYptrs<DISPobs*> DISPobs_list;
00066
00067
00068
00069
00070
00071 class DISPobs {
00072 static HASH _hash_disp;
00073 static int _suspend_disp;
00074 static DISPobs_list _all_disp;
00075 public:
00076 virtual ~DISPobs() {}
00077 virtual void notify(CGELptr &g, int) = 0;
00078
00079 static void notify_disp_obs(CGELptr &g, int disp);
00080
00081
00082 void disp_obs (CGELptr &g) { disp_obs_list(g).add_uniquely(this);}
00083 void unobs_display(CGELptr &g) { disp_obs_list(g).rem(this); }
00084 void disp_obs () { _all_disp.add_uniquely(this); }
00085 void unobs_display() { _all_disp.rem(this); }
00086 static void suspend_disp_obs() { _suspend_disp = 1; }
00087 static void activate_disp_obs() { _suspend_disp = 0; }
00088 protected :
00089 static DISPobs_list &disp_obs_list(CGELptr &g) {
00090 DISPobs_list *list = (DISPobs_list *) _hash_disp.find((long ) &*g);
00091 if (!list)
00092 _hash_disp.add((long)&* g, (void *)(list = new DISPobs_list));
00093 return *list;
00094 }
00095 };
00096
00097 #define CDUPobs_list const DUPobs_list
00098 #define CDUPobs const DUPobs
00099 class DUPobs;
00100 typedef ARRAYptrs<DUPobs*> DUPobs_list;
00101
00102
00103
00104
00105
00106 class DUPobs {
00107 protected :
00108
00109 static DUPobs_list *_dup_obs;
00110 DUPobs_list *dupobs_list() { if (!_dup_obs) _dup_obs = new DUPobs_list;
00111 return _dup_obs; }
00112 public:
00113 virtual ~DUPobs() {}
00114 static void notify_dup_obs(CGELptr &o, CGELptr &newg)
00115 {if (!_dup_obs) return;
00116 for (int i=0;i<_dup_obs->num();i++) (*_dup_obs)[i]->notify_dup(o,newg);}
00117 virtual void notify_dup (CGELptr &old, CGELptr &newg) = 0;
00118
00119 void dup_obs() { dupobs_list()->add_uniquely(this); }
00120 void unobs_dup() { dupobs_list()->rem (this); }
00121 };
00122
00123
00124 #define CGRABobs_list const GRABobs_list
00125 #define CGRABobs const GRABobs
00126 class GRABobs;
00127 typedef ARRAYptrs<GRABobs*> GRABobs_list;
00128
00129
00130
00131
00132
00133 class GRABobs {
00134 static GRABobs_list *_grab_obs;
00135 static GRABobs_list *grabobs_list() { if (!_grab_obs)
00136 _grab_obs=new GRABobs_list;
00137 return _grab_obs; }
00138 public:
00139 virtual ~GRABobs() {}
00140 virtual void notify_grab (CGELptr &, int flag) = 0;
00141 static void notify_grab_obs(CGELptr &g, int flag) {
00142 if (!_grab_obs) return; int i;
00143 for (i=0; i<grabobs_list()->num(); i++)
00144 (*_grab_obs)[i]->notify_grab(g,flag);}
00145
00146
00147 void grab_obs () { grabobs_list()->add_uniquely(this); }
00148 void unobs_grab() { grabobs_list()->rem(this); }
00149 };
00150
00151
00152 #define CSAVEobs_list const SAVEobs_list
00153 #define CSAVEobs const SAVEobs
00154 class SAVEobs;
00155 typedef ARRAYptrs<SAVEobs*> SAVEobs_list;
00156
00157
00158
00159
00160
00161 class SAVEobs {
00162 public:
00163 enum save_status_t {
00164 SAVE_ERROR_NONE=0,
00165 SAVE_ERROR_STREAM,
00166 SAVE_ERROR_WRITE,
00167 SAVE_ERROR_CWD
00168 };
00169
00170 protected:
00171 static SAVEobs_list *_save_obs;
00172 static SAVEobs_list *_presave_obs;
00173 static SAVEobs_list *_postsave_obs;
00174
00175 static SAVEobs_list *saveobs_list() { if (!_save_obs) _save_obs=new SAVEobs_list; return _save_obs; }
00176 static SAVEobs_list *presaveobs_list() { if (!_presave_obs) _presave_obs=new SAVEobs_list; return _presave_obs; }
00177 static SAVEobs_list *postsaveobs_list(){ if (!_postsave_obs) _postsave_obs=new SAVEobs_list; return _postsave_obs; }
00178 public:
00179 virtual ~SAVEobs() {}
00180 virtual void notify_presave (NetStream &s, save_status_t &status, bool to_file, bool full_scene) {}
00181 virtual void notify_postsave(NetStream &s, save_status_t &status, bool to_file, bool full_scene) {}
00182 virtual void notify_save (NetStream &s, save_status_t &status, bool to_file, bool full_scene) {}
00183
00184 static void notify_save_obs(NetStream &s, save_status_t &status, bool to_file, bool full_scene);
00185
00186
00187 void presave_obs () { presaveobs_list()->add_uniquely(this); }
00188 void postsave_obs () { postsaveobs_list()->add_uniquely(this); }
00189 void save_obs () { saveobs_list()->add_uniquely(this); }
00190 void unobs_save() { saveobs_list()->rem(this); }
00191 void unobs_presave() { presaveobs_list()->rem(this); }
00192 void unobs_postsave() { postsaveobs_list()->rem(this); }
00193 };
00194
00195
00196 #define CLOADobs_list const LOADobs_list
00197 #define CLOADobs const LOADobs
00198 class LOADobs;
00199 typedef ARRAYptrs<LOADobs*> LOADobs_list;
00200
00201
00202
00203
00204
00205 class LOADobs {
00206 public:
00207 enum load_status_t {
00208 LOAD_ERROR_NONE= 0,
00209 LOAD_ERROR_STREAM,
00210 LOAD_ERROR_JOT,
00211 LOAD_ERROR_CWD,
00212 LOAD_ERROR_AUX,
00213 LOAD_ERROR_READ
00214 };
00215 protected:
00216 static LOADobs_list *_load_obs;
00217 static LOADobs_list *_preload_obs;
00218 static LOADobs_list *_postload_obs;
00219
00220 static LOADobs_list *loadobs_list() { if (!_load_obs) _load_obs=new LOADobs_list; return _load_obs; }
00221 static LOADobs_list *preloadobs_list() { if (!_preload_obs) _preload_obs=new LOADobs_list; return _preload_obs; }
00222 static LOADobs_list *postloadobs_list(){ if (!_postload_obs) _postload_obs=new LOADobs_list; return _postload_obs; }
00223 public:
00224 virtual ~LOADobs() {}
00225 virtual void notify_preload (NetStream &s, load_status_t &status, bool from_file, bool full_scene) {}
00226 virtual void notify_postload(NetStream &s, load_status_t &status, bool from_file, bool full_scene) {}
00227 virtual void notify_load (NetStream &s, load_status_t &status, bool from_file, bool full_scene) {}
00228
00229 static void notify_load_obs(NetStream &s, load_status_t &status, bool to_file, bool full_scene);
00230
00231
00232 void preload_obs () { preloadobs_list()->add_uniquely(this); }
00233 void postload_obs() { postloadobs_list()->add_uniquely(this); }
00234 void load_obs () { loadobs_list()->add_uniquely(this); }
00235 void unobs_load () { loadobs_list()->rem(this); }
00236 void unobs_preload() { preloadobs_list()->rem(this); }
00237 void unobs_postload() { postloadobs_list()->rem(this); }
00238 };
00239
00240 #endif // GEL_OBS_H_HAS_BEEN_INCLUDED
00241
00242