1 // ServerNodeID.h 2 3 #ifndef NET_FS_SERVER_NODE_ID_H 4 #define NET_FS_SERVER_NODE_ID_H 5 6 #include <SupportDefs.h> 7 8 #include "Request.h" 9 10 // NodeID 11 struct NodeID { 12 NodeID() 13 : volumeID(-1), 14 nodeID(-1) 15 { 16 } 17 18 NodeID(dev_t volumeID, ino_t nodeID) 19 : volumeID(volumeID), 20 nodeID(nodeID) 21 { 22 } 23 24 NodeID(const NodeID& other) 25 : volumeID(other.volumeID), 26 nodeID(other.nodeID) 27 { 28 } 29 30 uint32 GetHashCode() const 31 { 32 uint64 v = (uint64)nodeID; 33 return (uint32)(v >> 32) ^ (uint32)v ^ (uint32)volumeID; 34 } 35 36 NodeID& operator=(const NodeID& other) 37 { 38 volumeID = other.volumeID; 39 nodeID = other.nodeID; 40 return *this; 41 } 42 43 bool operator==(const NodeID& other) const 44 { 45 return (volumeID == other.volumeID && nodeID == other.nodeID); 46 } 47 48 bool operator!=(const NodeID& other) const 49 { 50 return !(*this == other); 51 } 52 53 dev_t volumeID; 54 ino_t nodeID; 55 }; 56 57 // ServerNodeID 58 struct ServerNodeID : RequestMember, NodeID { 59 ServerNodeID(); 60 ServerNodeID(dev_t volumeID, ino_t nodeID); 61 virtual ~ServerNodeID(); 62 63 virtual void ShowAround(RequestMemberVisitor* visitor); 64 65 inline ServerNodeID& operator=(const NodeID& other); 66 }; 67 68 // = 69 inline 70 ServerNodeID& 71 ServerNodeID::operator=(const NodeID& other) 72 { 73 NodeID::operator=(other); 74 return *this; 75 } 76 77 #endif // NET_FS_SERVER_NODE_ID_H 78