Changeset 12060 for source/services/ariba_dht/messages
- Timestamp:
- Jun 19, 2013, 11:05:49 AM (11 years ago)
- Location:
- source/services/ariba_dht/messages
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/services/ariba_dht/messages/DhtMessage.cpp
r10700 r12060 10 10 DhtMessage::DhtMessage() : 11 11 ttl( 0 ), 12 replace( false ) 12 replace( false ), 13 sourceNode(NodeID::UNSPECIFIED) 13 14 {} 14 15 15 DhtMessage::DhtMessage( DhtMessageType type, const std::string& key ) :16 DhtMessage::DhtMessage( DhtMessageType type, const std::string& key, const NodeID& sourceNodeID ) : 16 17 type( static_cast<uint8_t>(type) ), 17 18 ttl( 0 ), 18 19 replace( false ), 19 key( key ) 20 key( key ), 21 sourceNode(sourceNodeID) 22 20 23 {} 21 24 22 25 DhtMessage::DhtMessage( DhtMessageType type, const std::string& key, 23 const std::string& value, uint16_t ttl ) :26 const std::string& value, uint16_t ttl, const NodeID& sourceNodeID ) : 24 27 type( static_cast<uint8_t>(type) ), 25 28 ttl( ttl ), 26 29 replace( false ), 27 30 key( key ), 28 values(1, value) 31 values(1, value), 32 sourceNode(sourceNodeID) 29 33 {} 30 34 31 35 DhtMessage::DhtMessage( DhtMessageType type, const std::string& key, 32 const vector<string>& values, uint16_t ttl ) :36 const vector<string>& values, uint16_t ttl, const NodeID& sourceNodeID ) : 33 37 type( static_cast<uint8_t>(type) ), 34 38 ttl( ttl ), 35 39 replace( false ), 36 key( key ) 40 key( key ), 41 sourceNode(sourceNodeID) 37 42 { 38 43 // preallocate enough room so we don't need to copy a lot … … 46 51 } 47 52 53 string DhtMessage::DhtMessageTypeToString(DhtMessageType type) { 54 string temp; 55 switch (type) 56 { 57 case DhtMessage::DhtInvalid: 58 { 59 temp = "DhtInvalid"; 60 break; 61 } 62 63 case DhtMessage::DhtGet: 64 { 65 temp = "DhtGet"; 66 break; 67 } 68 69 case DhtMessage::DhtPut: 70 { 71 temp = "DhtPut"; 72 break; 73 } 74 75 case DhtMessage::DhtPutAndGet: 76 { 77 temp = "DhtPutAndGet"; 78 break; 79 } 80 81 case DhtMessage::DhtRemove: 82 { 83 temp = "DhtRemove"; 84 break; 85 } 86 87 case DhtMessage::DhtRepublish: 88 { 89 temp = "DhtRepublish"; 90 break; 91 } 92 93 case DhtMessage::DhtAnswer: 94 { 95 temp = "DhtAnswer"; 96 break; 97 } 98 99 case DhtMessage::DhtReplica: 100 { 101 temp = "DhtReplica"; 102 break; 103 } 104 } 105 106 return temp; 107 } 108 48 109 }} -
source/services/ariba_dht/messages/DhtMessage.h
r10700 r12060 3 3 4 4 #include "ariba/utility/messages.h" 5 #include "ariba/utility/types/NodeID.h" 5 6 #include "ariba/utility/serialization.h" 6 7 #include "ariba/Name.h" … … 10 11 11 12 using ariba::utility::Message; 13 using ariba::utility::NodeID; 12 14 using_serialization; 13 15 … … 21 23 DhtRemove = 4, 22 24 DhtRepublish = 5, 23 DhtAnswer = 8 25 DhtAnswer = 8, 26 DhtReplica = 9 24 27 } DhtMessageType; 25 28 26 29 DhtMessage(); 27 DhtMessage( DhtMessageType type, const std::string& key 30 DhtMessage( DhtMessageType type, const std::string& key, const NodeID& sourceNodeID = NodeID::UNSPECIFIED); 28 31 DhtMessage( DhtMessageType type, const std::string& key, 29 const std::string& value, uint16_t ttl = 0 );32 const std::string& value, uint16_t ttl = 0, const NodeID& sourceNodeID = NodeID::UNSPECIFIED ); 30 33 31 34 DhtMessage( DhtMessageType type, const std::string& key, 32 const vector<std::string>& values, uint16_t ttl = 0 );35 const vector<std::string>& values, uint16_t ttl = 0, const NodeID& sourceNodeID = NodeID::UNSPECIFIED ); 33 36 34 37 virtual ~DhtMessage(); … … 77 80 } 78 81 82 NodeID getSourceNode() const { 83 return sourceNode; 84 } 85 79 86 bool doReplace() const { 80 87 return replace; 81 88 } 82 89 90 static string DhtMessageTypeToString(DhtMessageType type); 83 91 84 pr ivate:92 protected: 85 93 uint8_t type; 86 94 uint16_t ttl; … … 88 96 std::string key; 89 97 vector<std::string> values; 98 NodeID sourceNode; 99 100 private: 90 101 }; 91 102 … … 100 111 // key serialization 101 112 X && T(key); 113 114 X && &sourceNode; 102 115 103 116 // store number of values
Note:
See TracChangeset
for help on using the changeset viewer.