User Manual, Developers Guide and API Documentation

FunctionalUnit.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_FUNCTIONALUNIT_HPP
00029 #define WNS_LDK_FUNCTIONALUNIT_HPP
00030 
00031 #include <WNS/ldk/Compound.hpp>
00032 #include <WNS/ldk/CompoundHandlerInterface.hpp>
00033 #include <WNS/ldk/CommandTypeSpecifierInterface.hpp>
00034 #include <WNS/ldk/HasReceptorInterface.hpp>
00035 #include <WNS/ldk/HasConnectorInterface.hpp>
00036 #include <WNS/ldk/HasDelivererInterface.hpp>
00037 #include <WNS/ldk/Receptor.hpp>
00038 #include <WNS/ldk/Connector.hpp>
00039 #include <WNS/ldk/Deliverer.hpp>
00040 #include <WNS/ldk/ConnectorRegistry.hpp>
00041 #include <WNS/ldk/ReceptorRegistry.hpp>
00042 #include <WNS/ldk/DelivererRegistry.hpp>
00043 
00044 #include <WNS/Cloneable.hpp>
00045 #include <WNS/StaticFactory.hpp>
00046 #include <WNS/ldk/FUNConfigCreator.hpp>
00047 #include <WNS/PythonicOutput.hpp>
00048 
00049 
00050 #include <string>
00051 
00052 namespace wns { namespace ldk {
00053     class ILayer;
00054 
00063     class FunctionalUnit :
00064         public virtual CompoundHandlerInterface<FunctionalUnit>,
00065         public virtual HasConnectorInterface,
00066         public virtual HasReceptorInterface,
00067         public virtual HasDelivererInterface,
00068         public virtual ConnectorRegistry,
00069         public virtual ReceptorRegistry,
00070         public virtual DelivererRegistry,
00071         public virtual CommandTypeSpecifierInterface,
00072         public virtual CloneableInterface,
00073         public virtual PythonicOutput
00074     {
00075     public:
00076         friend class CommandProxy;
00077 
00078         FunctionalUnit() :
00079             name("None")
00080         {}
00081 
00082         virtual ~FunctionalUnit()
00083         {}
00084 
00148         template <typename T>
00149                 T* connect(T* that, const std::string& srcPort = "SinglePort", const std::string& dstPort = "SinglePort")
00150         {
00151             FunctionalUnit* connectee = that->whenConnecting();
00152                         doConnect(connectee, srcPort, dstPort);
00153             return that;
00154         }
00155 
00164         template <typename T>
00165         T* downConnect(T* that, const std::string& srcPort = "SinglePort", const std::string& dstPort = "SinglePort")
00166         {
00167             FunctionalUnit* connectee = that->whenConnecting();
00168             doDownConnect(connectee, srcPort, dstPort);
00169             return that;
00170         }
00171 
00180         template <typename T>
00181         T* upConnect(T* that, const std::string& srcPort = "SinglePort", const std::string& dstPort = "SinglePort")
00182         {
00183             FunctionalUnit* connectee = that->whenConnecting();
00184             doUpConnect(connectee, srcPort, dstPort);
00185             return that;
00186         }
00187 
00207         virtual void
00208         onFUNCreated()
00209         {}
00210 
00253          virtual FunctionalUnit*
00254         whenConnecting()
00255         {
00256             return this;
00257         } //  whenConnecting
00258 
00262         virtual void
00263         setName(std::string _name)
00264         {
00265             name = _name;
00266         }
00267 
00271         virtual std::string
00272         getName() const
00273         {
00274             return name;
00275         }
00276 
00277     protected:
00284         virtual std::string
00285         doToString() const
00286         {
00287             return this->getName() + " (" + PythonicOutput::doToString() + ")";
00288         }
00289 
00290     private:
00304         virtual void
00305         doConnect(FunctionalUnit* that, const std::string& srcPort, const std::string& dstPort);
00306 
00320         virtual void
00321         doDownConnect(FunctionalUnit* that, const std::string& srcPort, const std::string& dstPort);
00322 
00336         virtual void
00337         doUpConnect(FunctionalUnit* that, const std::string& srcPort, const std::string& dstPort);
00338 
00339         std::string name;
00340     };
00341     typedef FUNConfigCreator<FunctionalUnit> FunctionalUnitCreator;
00342     typedef wns::StaticFactory<FunctionalUnitCreator> FunctionalUnitFactory;
00343 
00515 }}
00516 
00517 
00518 #endif // NOT defined WNS_LDK_FUNCTIONALUNIT_HPP
00519 
00520 

Generated on Thu May 24 03:31:40 2012 for openWNS by  doxygen 1.5.5