TransportAddress.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 __TRANSPORTADDRESS_H_
00026 #define __TRANSPORTADDRESS_H_
00027 
00028 //#include <stdint.h>
00029 #include <oversim_mapset.h>
00030 
00031 #include <omnetpp.h>
00032 #include <IPvXAddress.h>
00033 
00044 class TransportAddress
00045 {
00046 public:
00047 
00051     class hashFcn
00052     {
00053     public:
00054         size_t operator()( const TransportAddress& h1 ) const
00055         {
00056             return h1.hash();
00057         }
00058     };
00059 
00060 public://collection typedefs
00061 
00062     typedef UNORDERED_SET<TransportAddress, hashFcn> Set; 
00064 public://fields
00065 
00066     IPvXAddress ip; 
00067     int port; 
00069 public://construction
00070 
00074     TransportAddress( );
00075 
00079     virtual ~TransportAddress( ) {};
00080 
00086     TransportAddress( const TransportAddress& handle );
00087 
00094     TransportAddress(const IPvXAddress& ip, int port = -1);
00095 
00096 public://static fields
00097 
00098     static const TransportAddress UNSPECIFIED_NODE; 
00099     static const std::vector<TransportAddress> UNSPECIFIED_NODES;
00100 
00101 public://methods: delegates to OverlayKey and IPvXAddress
00102 
00109     bool operator==(const TransportAddress& rhs) const;
00110 
00117     bool operator!=(const TransportAddress& rhs) const;
00118 
00125     bool operator< (const TransportAddress& rhs) const;
00126 
00133     bool operator> (const TransportAddress& rhs) const;
00134 
00141     bool operator<=(const TransportAddress& rhs) const;
00142 
00149     bool operator>=(const TransportAddress& rhs) const;
00150 
00151 public://methods: operators
00152 
00159     TransportAddress& operator=(const TransportAddress& rhs);
00160 
00161 public://methods: setters and getters
00162 
00169     void setAddress( const IPvXAddress& ip, int port = -1 );
00170 
00176     void setPort( int port );
00177 
00183     const IPvXAddress& getAddress() const;
00184 
00190     int getPort() const;
00191 
00197     bool isUnspecified() const;
00198 
00199 public://methods: hashing
00200 
00206     size_t hash() const;
00207 
00208 public://methods: c++ streaming
00209 
00218     friend std::ostream& operator<<(std::ostream& os, const TransportAddress& n);
00219 
00220 private://methods:
00221 
00227     void assertUnspecified( const TransportAddress& handle ) const;
00228 
00229 public:
00230 
00236     virtual TransportAddress* dup() const;
00237 };
00238 
00245 inline void doPacking(cCommBuffer *buf, TransportAddress& addr)
00246 {
00247     doPacking(buf, addr.getAddress());
00248     doPacking(buf, addr.getPort());
00249 }
00250 
00257 inline void doUnpacking(cCommBuffer *buf, TransportAddress& addr)
00258 {
00259     IPvXAddress ip;
00260     int port;
00261     doUnpacking(buf, ip);
00262     doUnpacking(buf, port);
00263     addr.setAddress(ip, port);
00264 }
00265 
00266 
00267 #endif

Generated on Wed Mar 25 16:32:50 2009 for OverSim by  doxygen 1.5.5