00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _GLOBAL_STORE_H_
00018 #define _GLOBAL_STORE_H_
00019
00020 #include <oasys/debug/DebugUtils.h>
00021 #include <oasys/debug/Log.h>
00022 #include <oasys/serialize/Serialize.h>
00023
00024
00025 namespace oasys {
00026 template<typename _Type> class SingleTypeDurableTable;
00027 class DurableStore;
00028 class Mutex;
00029 class StorageConfig;
00030 }
00031
00032 namespace dtn {
00033
00034 class Globals;
00035
00042 class GlobalStore : public oasys::Logger {
00043 public:
00044 static const u_int32_t CURRENT_VERSION;
00045
00049 static GlobalStore* instance() {
00050 if (instance_ == NULL) {
00051 PANIC("GlobalStore::init not called yet");
00052 }
00053 return instance_;
00054 }
00055
00060 static int init(const oasys::StorageConfig& cfg,
00061 oasys::DurableStore* store);
00062
00066 GlobalStore();
00067
00071 int do_init(const oasys::StorageConfig& cfg,
00072 oasys::DurableStore* store);
00073
00077 static bool initialized() { return (instance_ != NULL); }
00078
00082 ~GlobalStore();
00083
00089 u_int32_t next_bundleid();
00090
00098 u_int32_t next_regid();
00099
00103 bool load();
00104
00108 void close();
00109
00110 protected:
00114 void update();
00115
00119 void calc_digest(u_char* digest);
00120
00121 bool loaded_;
00122 Globals* globals_;
00123 oasys::SingleTypeDurableTable<Globals>* store_;
00124
00125 oasys::Mutex* lock_;
00126
00127 static GlobalStore* instance_;
00128 };
00129 }
00130
00131 #endif