NodeHandle.h

Go to the documentation of this file.
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 protected://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 
00103     NodeHandle( const OverlayKey& key, const TransportAddress& ta );
00104 
00105 public://static fields
00106 
00107     static const NodeHandle UNSPECIFIED_NODE; 
00109 public://methods: delegates to OverlayKey and IPvXAddress
00110 
00117     bool operator==(const NodeHandle& rhs) const;
00118 
00125     bool operator!=(const NodeHandle& rhs) const;
00126 
00133     bool operator< (const NodeHandle& rhs) const;
00134 
00141     bool operator> (const NodeHandle& rhs) const;
00142 
00149     bool operator<=(const NodeHandle& rhs) const;
00150 
00157     bool operator>=(const NodeHandle& rhs) const;
00158 
00159 public://methods: operators
00160 
00167     NodeHandle& operator=(const NodeHandle& rhs);
00168 
00169 public://methods: setters and getters
00170 
00176     void setKey( const OverlayKey& key );
00177 
00183     const OverlayKey& getKey() const;
00184 
00190     bool isUnspecified() const;
00191 
00192 public://methods: c++ streaming
00193 
00202     friend std::ostream& operator<<(std::ostream& os, const NodeHandle& n);
00203 
00204 private://methods:
00205 
00211     void assertUnspecified( const NodeHandle& handle ) const;
00212 
00213 public:
00214 
00220     virtual void netPack(cCommBuffer *b);
00221 
00227     virtual void netUnpack(cCommBuffer *b);
00228 
00234     virtual TransportAddress* dup() const;
00235 };
00236 
00243 inline void doPacking(cCommBuffer *b, NodeHandle& obj) {obj.netPack(b);}
00244 
00251 inline void doUnpacking(cCommBuffer *b, NodeHandle& obj) {obj.netUnpack(b);}
00252 
00253 #endif
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3