GlobalStore.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
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 // forward decl
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 } // namespace dtn
00130 
00131 #endif /* _GLOBAL_STORE_H_ */

Generated on Thu Jun 7 12:54:27 2007 for DTN Reference Implementation by  doxygen 1.5.1