00001 #ifndef IO_MANAGER_H_IS_INCLUDED
00002 #define IO_MANAGER_H_IS_INCLUDED
00003
00004 #include "disp/gel.H"
00005
00006
00007
00008
00009 class IOManager : public SAVEobs, public LOADobs, public DATA_ITEM {
00010 public:
00011
00012 enum state_t {
00013 STATE_IDLE = 0,
00014 STATE_SCENE_LOAD,
00015 STATE_PARTIAL_LOAD,
00016 STATE_SCENE_SAVE,
00017 STATE_PARTIAL_SAVE
00018 };
00019
00020
00021 IOManager();
00022 virtual ~IOManager();
00023
00024
00025 static void init() { instance(); }
00026
00027 static IOManager* instance() {
00028 if (!_instance)
00029 _instance = new IOManager;
00030 return _instance;
00031 }
00032
00033 static state_t state() { return instance()->state_(); }
00034 static str_ptr basename() { return instance()->basename_(); }
00035 static str_ptr cwd() { return instance()->cwd_(); }
00036 static str_ptr cached_prefix() { return instance()->cached_prefix_(); }
00037 static str_ptr current_prefix() { return instance()->current_prefix_(); }
00038 static str_ptr load_prefix() { return instance()->load_prefix_(); }
00039 static str_ptr save_prefix() { return instance()->save_prefix_(); }
00040
00041
00042 virtual void notify_preload (NetStream &, load_status_t &, bool, bool);
00043 virtual void notify_postload(NetStream &, load_status_t &, bool, bool);
00044
00045
00046 virtual void notify_presave (NetStream &, save_status_t &, bool, bool);
00047 virtual void notify_postsave(NetStream &, save_status_t &, bool, bool);
00048
00049
00050 DEFINE_RTTI_METHODS_BASE("IOManager", CDATA_ITEM*);
00051 virtual DATA_ITEM* dup() const { return new IOManager; }
00052 virtual CTAGlist& tags() const;
00053
00054 protected:
00055
00056 ARRAY<state_t> _state;
00057
00058 str_ptr _basename;
00059 str_ptr _cached_cwd_plus_basename;
00060
00061 str_ptr _old_cwd;
00062 str_ptr _old_basename;
00063
00064
00065 static TAGlist* _io_tags;
00066 static IOManager* _instance;
00067
00068
00069 bool split_filename(Cstr_ptr &, str_ptr &, str_ptr &, str_ptr &);
00070
00071
00072
00073 state_t state_() const { assert(_state.num()>0); return _state.last(); }
00074
00075 str_ptr basename_() { return _basename; }
00076
00077 str_ptr cwd_();
00078
00079 str_ptr cached_prefix_();
00080 str_ptr current_prefix_();
00081
00082 str_ptr load_prefix_();
00083 str_ptr save_prefix_();
00084
00085
00086 virtual void get_basename(TAGformat &d);
00087 virtual void put_basename(TAGformat &d) const;
00088 };
00089
00090 #endif // IO_MANAGER_H_IS_INCLUDED
00091
00092
00093