OverSim
NodeHandle.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
25 #ifndef __NODEHANDLE_H_
26 #define __NODEHANDLE_H_
27 
28 //#include <stdint.h>
29 //#include <oversim_mapset.h>
30 
31 #include <omnetpp.h>
32 
33 #include <OverlayKey.h>
34 #include <TransportAddress.h>
35 
36 //class hashFcn;
37 class IPvXAddress;
38 
51 {
52 public://collection typedefs
53  //typedef UNORDERED_SET<NodeHandle, hashFcn> Set; /**< a hash_set of NodeHandles */
54 
55 protected://fields
58 public://construction
59 
63  NodeHandle( );
64 
68  virtual ~NodeHandle( ) {};
69 
75  NodeHandle( const NodeHandle& handle );
76 
84  NodeHandle( const OverlayKey& key,
85  const IPvXAddress& ip,
86  int port);
87 
94  NodeHandle( const TransportAddress& ta );
95 
103  NodeHandle( const OverlayKey& key, const TransportAddress& ta );
104 
105 public://static fields
106 
109 public://methods: delegates to OverlayKey and IPvXAddress
110 
117  bool operator==(const NodeHandle& rhs) const;
118 
125  bool operator!=(const NodeHandle& rhs) const;
126 
133  bool operator< (const NodeHandle& rhs) const;
134 
141  bool operator> (const NodeHandle& rhs) const;
142 
149  bool operator<=(const NodeHandle& rhs) const;
150 
157  bool operator>=(const NodeHandle& rhs) const;
158 
159 public://methods: operators
160 
167  NodeHandle& operator=(const NodeHandle& rhs);
168 
169 public://methods: setters and getters
170 
176  void setKey( const OverlayKey& key );
177 
183  const OverlayKey& getKey() const;
184 
190  bool isUnspecified() const;
191 
192 public://methods: c++ streaming
193 
202  friend std::ostream& operator<<(std::ostream& os, const NodeHandle& n);
203 
204 private://methods:
205 
211  void assertUnspecified( const NodeHandle& handle ) const;
212 
213 public:
214 
220  virtual void netPack(cCommBuffer *b);
221 
227  virtual void netUnpack(cCommBuffer *b);
228 
234  virtual TransportAddress* dup() const;
235 };
236 
243 inline void doPacking(cCommBuffer *b, NodeHandle& obj) {obj.netPack(b);}
244 
251 inline void doUnpacking(cCommBuffer *b, NodeHandle& obj) {obj.netUnpack(b);}
252 
253 #endif