Changeset 5284 for source/ariba/communication/EndpointDescriptor.h
- Timestamp:
- Jul 24, 2009, 3:23:11 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/communication/EndpointDescriptor.h
r4986 r5284 40 40 #define ENDPOINTDESCRIPTOR_H_ 41 41 42 // deprecated 43 //#include "ariba/communication/modules/network/ip/IPv4Locator.h" 44 45 // deprecated 46 //using ariba::utility::Locator; 47 //using ariba::communication::IPv4Locator; 48 49 // typical types 42 50 #include "ariba/utility/types.h" 43 51 #include "ariba/utility/serialization.h" 44 #include "ariba/communication/modules/network/ip/IPv4Locator.h" 52 53 // new addressing and transport 54 #include "ariba/utility/addressing/addressing.hpp" 55 #include "ariba/utility/transport/transport.hpp" 56 57 // stdlibc++ 45 58 #include <string> 46 59 #include <set> 47 48 using std::string;49 using std::set;50 using ariba::utility::Locator;51 using ariba::communication::IPv4Locator;52 60 53 61 namespace ariba { … … 55 63 56 64 using_serialization; 65 using namespace std; 66 using namespace ariba::addressing; 57 67 58 class EndpointDescriptor : public VSerializeable { 59 VSERIALIZEABLE; 60 68 class EndpointDescriptor: public VSerializeable { VSERIALIZEABLE 61 69 friend class BaseCommunication; 62 70 63 71 public: 64 /** 65 * The default constructor. 66 */ 67 EndpointDescriptor(); 72 /// the unspecified endpoint descriptor 73 static const EndpointDescriptor UNSPECIFIED; 68 74 69 EndpointDescriptor(const EndpointDescriptor& rh);70 EndpointDescriptor( const Locator* _locator);71 EndpointDescriptor(const string str);75 /// creates an empty endpoint descriptor with zero endpoints 76 EndpointDescriptor() : endpoints() { 77 } 72 78 73 /** 74 * The destructor. 75 */ 79 /// destructor. 76 80 virtual ~EndpointDescriptor(); 77 81 78 / **79 * An unspecified end-point80 */81 static const EndpointDescriptor UNSPECIFIED;82 /// copy constructor 83 EndpointDescriptor(const EndpointDescriptor& rh) : 84 endpoints(rh.endpoints) { 85 } 82 86 83 /** 84 * Returns true, if the descriptor is unspecified. 85 * 86 * @return True, if the descriptor is unspecified. 87 */ 88 bool isUnspecified() const; 87 /// construct end-points from an endpoint set 88 EndpointDescriptor(const endpoint_set& endpoints ) : 89 endpoints(endpoints) { 90 } 89 91 90 virtual string toString() const; 91 static EndpointDescriptor* fromString( string str ); 92 /// construct end-points from a string 93 EndpointDescriptor(const string& str) : endpoints(str) { 94 } 92 95 93 bool operator==( const EndpointDescriptor& rh ) const; 94 bool operator!=( const EndpointDescriptor& rh ) const; 96 /// convert end-points to string 97 string toString() const { 98 return endpoints.to_string(); 99 } 100 101 /// returns true, if this object is the unspecified object 102 bool isUnspecified() const { 103 return this == &UNSPECIFIED; 104 } 105 106 /// create endpoint 107 static EndpointDescriptor* fromString(string str) { 108 return new EndpointDescriptor(str); 109 } 110 111 bool operator==(const EndpointDescriptor& rh) const { 112 if (rh.isUnspecified() && isUnspecified()) return true; 113 return false; 114 } 115 116 bool operator!=(const EndpointDescriptor& rh) const { 117 if (!rh.isUnspecified() && !isUnspecified()) return true; 118 return false; 119 } 120 121 EndpointDescriptor& operator=( const EndpointDescriptor& rhs) { 122 endpoints = rhs.endpoints; 123 } 124 125 /// returns the end-points of this descriptor 126 endpoint_set& getEndpoints() { 127 return endpoints; 128 } 129 130 /// returns the end-points of this descriptor 131 const endpoint_set& getEndpoints() const { 132 return endpoints; 133 } 95 134 96 135 private: 97 bool isUnspec; 98 IPv4Locator* locator; 136 endpoint_set endpoints; 99 137 }; 100 138 101 139 }} // namespace ariba, communication 102 140 103 sznBeginDefault( ariba::communication::EndpointDescriptor, X ) { 104 uint8_t unspec = isUnspec; 105 106 X && unspec && VO(locator); 107 108 // when deserializing reset unspec flag 109 if (X.isDeserializer()) isUnspec = unspec; 110 } sznEnd(); 141 sznBeginDefault( ariba::communication::EndpointDescriptor, X ){ 142 // serialize endpoints 143 uint16_t len = endpoints.to_bytes_size(); 144 X && len; 145 uint8_t* buffer = X.bytes( len ); 146 if (buffer!=NULL) { 147 if (X.isDeserializer()) endpoints.assign(buffer,len); 148 else endpoints.to_bytes(buffer); 149 } 150 }sznEnd(); 111 151 112 152 #endif /*ENDPOINTDESCRIPTOR_H_*/
Note:
See TracChangeset
for help on using the changeset viewer.