User Manual, Developers Guide and API Documentation

FlowID.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 16, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #ifndef WNS_SERVICE_TL_FLOWID_HPP
00029 #define WNS_SERVICE_TL_FLOWID_HPP
00030 
00031 #include <WNS/service/nl/Address.hpp>
00032 #include <WNS/service/tl/Service.hpp>
00033 #include <WNS/SmartPtr.hpp>
00034 #include <WNS/IOutputStreamable.hpp>
00035 
00036 #include <sstream>
00037 
00038 namespace wns { namespace service { namespace tl {
00039     class FlowID :
00040         public wns::IOutputStreamable
00041     {
00042     public:
00043         FlowID() :
00044             srcAddress(),
00045             srcPort(-1),
00046             dstAddress(),
00047             dstPort(-1)
00048         {
00049         }
00050 
00051         FlowID(
00052             const wns::service::nl::Address& _srcAddress,
00053             wns::service::tl::Port _srcPort,
00054             const wns::service::nl::Address& _dstAddress,
00055             wns::service::tl::Port _dstPort) :
00056             srcAddress(_srcAddress),
00057             srcPort(_srcPort),
00058             dstAddress(_dstAddress),
00059             dstPort(_dstPort)
00060         {}
00061 
00062         virtual ~FlowID()
00063         {}
00064 
00065         virtual void
00066         swapSrcDest()
00067             {
00068                 wns::service::nl::Address tmpSrcAddress = srcAddress;
00069                 wns::service::tl::Port tmpSrcPort = srcPort;
00070                 srcAddress = dstAddress;
00071                 srcPort = dstPort;
00072                 dstAddress = tmpSrcAddress;
00073                 dstPort = tmpSrcPort;
00074             }
00075 
00076         virtual bool
00077         operator ==(const FlowID& other) const
00078         {
00079             if(srcAddress == other.srcAddress &&
00080                srcPort == other.srcPort &&
00081                dstAddress == other.dstAddress &&
00082                dstPort == other.dstPort) {
00083                 return true;
00084             } else {
00085                 return false;
00086             }
00087         }
00088 
00089         bool
00090         operator <(const FlowID& other) const
00091         {
00092             if(srcAddress < other.srcAddress) {
00093                 return true;
00094             } else if (srcAddress == other.srcAddress) {
00095                 if(srcPort < other.srcPort) {
00096                     return true;
00097                 } else if(srcPort == other.srcPort) {
00098                     if(dstAddress < other.dstAddress) {
00099                         return true;
00100                     } else if(dstAddress == other.dstAddress) {
00101                         if(dstPort < other.dstPort) {
00102                             return true;
00103                         }
00104                     }
00105                 }
00106             }
00107             return false;
00108         }
00109 
00110         virtual std::string
00111         doToString() const
00112         {
00113             std::stringstream ss;
00114             ss << "SRC: " << srcAddress << ":" << srcPort << ", "
00115                << "DST: " << dstAddress << ":" << dstPort;
00116             return ss.str();
00117         }
00118 
00119         wns::service::nl::Address srcAddress;
00120         wns::service::tl::Port srcPort;
00121 
00122         wns::service::nl::Address dstAddress;
00123         wns::service::tl::Port dstPort;
00124     };
00125 } // tl
00126 } // service
00127 } // wns
00128 
00129 #endif // NOT defined WNS_SERVICE_TL_FLOWID_HPP
00130 
00131 /*
00132   Local Variables:
00133   mode: c++
00134   fill-column: 80
00135   c-basic-offset: 8
00136   c-comment-only-line-offset: 0
00137   c-tab-always-indent: t
00138   indent-tabs-mode: t
00139   tab-width: 8
00140   End:
00141 */

Generated on Sun May 27 03:31:54 2012 for openWNS by  doxygen 1.5.5