DHTDataStorage.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef __DHTDATASTORAGE_H_
00025 #define __DHTDATASTORAGE_H_
00026
00027 #include <set>
00028 #include <vector>
00029 #include <map>
00030 #include <sstream>
00031
00032 #include <omnetpp.h>
00033
00034 #include <NodeHandle.h>
00035 #include <InitStages.h>
00036 #include <BinaryValue.h>
00037
00038 #include <CommonMessages_m.h>
00039
00050 struct DhtDataEntry
00051 {
00052 BinaryValue value;
00053 uint32_t kind;
00054 uint32_t id;
00055 cMessage* ttlMessage;
00056 bool is_modifiable;
00057 NodeHandle sourceNode;
00058 bool responsible;
00059 friend std::ostream& operator<<(std::ostream& Stream, const DhtDataEntry entry);
00060 };
00061
00062 typedef std::vector<std::pair<OverlayKey, DhtDataEntry> > DhtDataVector;
00063 typedef std::vector<DhtDumpEntry> DhtDumpVector;
00064 typedef std::multimap<OverlayKey, DhtDataEntry> DhtDataMap;
00065
00066 class DHTDataStorage : public cSimpleModule
00067 {
00068 public:
00069
00070 virtual int numInitStages() const
00071 {
00072 return MAX_STAGE_APP + 1;
00073 }
00074 virtual void initialize(int stage);
00075 virtual void handleMessage(cMessage* msg);
00076
00082 virtual uint32_t getSize();
00083
00087 virtual void clear();
00088
00098 DhtDataEntry* getDataEntry(const OverlayKey& key,
00099 uint32_t kind, uint32_t id);
00100
00101
00111 virtual DhtDataVector* getDataVector(const OverlayKey& key,
00112 uint32_t kind = 0,
00113 uint32_t id = 0);
00114
00124 virtual const NodeHandle& getSourceNode(const OverlayKey& key,
00125 uint32_t kind, uint32_t id);
00126
00135 virtual const bool isModifiable(const OverlayKey& key,
00136 uint32_t kind, uint32_t id);
00137
00143 virtual const DhtDataMap::iterator begin();
00144
00157 virtual void addData(const OverlayKey& key, uint32_t kind, uint32_t id,
00158 BinaryValue value, cMessage* ttlMessage,
00159 bool is_modifiable=true,
00160 NodeHandle sourceNode=NodeHandle::UNSPECIFIED_NODE,
00161 bool responsible=true);
00162
00171 virtual void removeData(const OverlayKey& key, uint32_t kind, uint32_t id);
00172
00173 void display();
00174
00184 DhtDumpVector* dumpDht(const OverlayKey& key = OverlayKey::UNSPECIFIED_KEY,
00185 uint32_t kind = 0, uint32_t id = 0);
00186
00187 protected:
00188 DhtDataMap dataMap;
00193 void updateDisplayString();
00194
00198 void updateTooltip();
00199 };
00200
00201 #endif