00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _PROPHET_STORE_H_
00018 #define _PROPHET_STORE_H_
00019
00020 #include <oasys/debug/DebugUtils.h>
00021 #include <oasys/serialize/TypeShims.h>
00022 #include <oasys/storage/InternalKeyDurableTable.h>
00023 #include <oasys/util/Singleton.h>
00024 #include <oasys/storage/StorageConfig.h>
00025 #include "naming/EndpointID.h"
00026 #include "routing/ProphetNode.h"
00027
00028 namespace dtn {
00029
00030 class EndpointIDShim : public EndpointID,
00031 public oasys::Formatter {
00032 public:
00033 EndpointIDShim()
00034 : oasys::Formatter() {}
00035 EndpointIDShim(EndpointID eid)
00036 : EndpointID(eid),
00037 oasys::Formatter() {}
00038 virtual ~EndpointIDShim() {}
00039
00040 int format(char *buf, size_t sz) const {
00041 return snprintf(buf, sz, "%s", c_str());
00042 }
00043
00044 EndpointID value() const { return *this; }
00045 };
00046
00047 class ProphetStore : public oasys::Singleton<ProphetStore, false> {
00048 public:
00049 typedef oasys::InternalKeyDurableTable<
00050 EndpointIDShim,EndpointID,ProphetNode> ProphetDurableTable;
00051 typedef ProphetDurableTable::iterator iterator;
00052
00056 static int init(const oasys::StorageConfig& cfg,
00057 oasys::DurableStore* store);
00058
00062 ProphetStore(const oasys::StorageConfig& cfg);
00063
00065 bool add(ProphetNode* node);
00066
00068 ProphetNode* get(const EndpointID& remote_eid);
00069
00071 bool update(ProphetNode* node);
00072
00074 bool del(ProphetNode* node);
00075
00077 iterator* new_iterator();
00078
00080 void close();
00081
00082 protected:
00083
00084 const oasys::StorageConfig& cfg_;
00085 ProphetDurableTable nodes_;
00086 };
00087
00088 }
00089
00090 #endif // _PROPHET_STORE_H_