00001 // 00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH) 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU General Public License 00006 // as published by the Free Software Foundation; either version 2 00007 // of the License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 // 00018 00025 #ifndef __NODEHANDLE_H_ 00026 #define __NODEHANDLE_H_ 00027 00028 //#include <stdint.h> 00029 #include <oversim_mapset.h> 00030 00031 #include <omnetpp.h> 00032 00033 #include <OverlayKey.h> 00034 #include <TransportAddress.h> 00035 00036 class hashFcn; 00037 class IPvXAddress; 00038 00050 class NodeHandle : public TransportAddress 00051 { 00052 public://collection typedefs 00053 typedef UNORDERED_SET<NodeHandle, hashFcn> Set; 00055 public://fields 00056 OverlayKey key; 00058 public://construction 00059 00063 NodeHandle( ); 00064 00068 virtual ~NodeHandle( ) {}; 00069 00075 NodeHandle( const NodeHandle& handle ); 00076 00084 NodeHandle( const OverlayKey& key, 00085 const IPvXAddress& ip, 00086 int port); 00087 00094 NodeHandle( const TransportAddress& ta ); 00095 00096 public://static fields 00097 00098 static const NodeHandle UNSPECIFIED_NODE; 00100 public://methods: delegates to OverlayKey and IPvXAddress 00101 00108 bool operator==(const NodeHandle& rhs) const; 00109 00116 bool operator!=(const NodeHandle& rhs) const; 00117 00124 bool operator< (const NodeHandle& rhs) const; 00125 00132 bool operator> (const NodeHandle& rhs) const; 00133 00140 bool operator<=(const NodeHandle& rhs) const; 00141 00148 bool operator>=(const NodeHandle& rhs) const; 00149 00150 public://methods: operators 00151 00158 NodeHandle& operator=(const NodeHandle& rhs); 00159 00160 public://methods: setters and getters 00161 00167 void setKey( const OverlayKey& key ); 00168 00174 const OverlayKey& getKey() const; 00175 00181 bool isUnspecified() const; 00182 00183 public://methods: c++ streaming 00184 00193 friend std::ostream& operator<<(std::ostream& os, const NodeHandle& n); 00194 00195 private://methods: 00196 00202 void assertUnspecified( const NodeHandle& handle ) const; 00203 00204 public: 00205 00211 virtual void netPack(cCommBuffer *b); 00212 00218 virtual void netUnpack(cCommBuffer *b); 00219 00225 virtual TransportAddress* dup() const; 00226 }; 00227 00234 inline void doPacking(cCommBuffer *b, NodeHandle& obj) {obj.netPack(b);} 00235 00242 inline void doUnpacking(cCommBuffer *b, NodeHandle& obj) {obj.netUnpack(b);} 00243 00244 #endif
1.5.5