User Manual, Developers Guide and API Documentation

SingleLink.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. 5, 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_LDK_SINGLELINK_HPP
00029 #define WNS_LDK_SINGLELINK_HPP
00030 
00031 #include <WNS/ldk/Link.hpp>
00032 
00033 #include <WNS/ldk/FunctionalUnit.hpp>
00034 
00035 #include <iostream>
00036 
00037 namespace wns { namespace ldk {
00038 
00039         template <typename RECEPTACLETYPE>
00040         class SingleLink
00041             : virtual public Link<RECEPTACLETYPE>
00042         {
00043         public:
00044             SingleLink()
00045                 : rec(NULL)
00046             {}
00047 
00048 
00049             virtual
00050             ~SingleLink()
00051             {
00052                 rec = NULL;
00053             }
00054 
00058             //{@
00059             virtual void
00060             add(RECEPTACLETYPE* it)
00061             {
00062                 assure(
00063                     rec == NULL,
00064                     "Can't add " + it->getFU()->toString() + ", already got " + rec->getFU()->toString());
00065 
00066                 assureNotNull(it);
00067 
00068                 rec = it;
00069             }
00070 
00071             virtual unsigned long int
00072             size() const
00073             {
00074                 return rec == NULL ? 0 : 1;
00075             }
00076 
00077             virtual void
00078             clear()
00079             {
00080                 rec = NULL;
00081             }
00082 
00083             virtual const typename Link<RECEPTACLETYPE>::ExchangeContainer
00084             get() const
00085             {
00086                 typename Link<RECEPTACLETYPE>::ExchangeContainer container;
00087                 if(this->rec != NULL)
00088                 {
00089                     container.push_back(rec);
00090                 }
00091                 return container;
00092             }
00093 
00094             virtual void
00095             set(const typename Link<RECEPTACLETYPE>::ExchangeContainer& src)
00096             {
00097                 assure(src.size() < 2, "SingleLink takes one FU at most");
00098 
00099                 rec = NULL;
00100                 if (!src.empty())
00101                 {
00102                     this->rec = src.front();
00103                     assureNotNull(rec);
00104                 }
00105             }
00107 
00108         protected:
00109             RECEPTACLETYPE*
00110             getRec() const
00111             {
00112                 return rec;
00113             }
00114 
00115         private:
00116             RECEPTACLETYPE* rec;
00117         };
00118     } // ldk
00119 } // wns
00120 
00121 #endif // WNS_LDK_SINGLELINK_HPP
00122 

Generated on Fri May 25 03:31:47 2012 for openWNS by  doxygen 1.5.5