User Manual, Developers Guide and API Documentation

Group.cpp

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 #include <WNS/ldk/Group.hpp>
00029 #include <WNS/ldk/utils.hpp>
00030 #include <WNS/ldk/Layer.hpp>
00031 
00032 #include <string>
00033 
00034 using namespace wns::ldk;
00035 
00036 STATIC_FACTORY_REGISTER_WITH_CREATOR(Group,
00037                                      FunctionalUnit,
00038                                      "wns.Group",
00039                                      FUNConfigCreator);
00040 
00041 Group::Group(
00042     fun::FUN* fuNet,
00043     const pyconfig::View& _config) :
00044 
00045     CommandTypeSpecifier<>(fuNet),
00046     HasReceptor<>(),
00047     HasConnector<>(),
00048     HasDeliverer<>(),
00049     config(_config),
00050     logger("WNS", "Group")
00051 {
00052     sub = new fun::Sub(getFUN());
00053 
00054     pyconfig::View funView(config, "fun");
00055     configureFUN(sub, funView);
00056 
00057     if (!config.isNone("top") && (config.len("topPorts") == 0))
00058     {
00059         FunctionalUnit* topFU = sub->getFunctionalUnit(config.get<std::string>("top"));
00060 
00061         updateConnectorReceptacleRegistry("SinglePort", topFU->getFromConnectorReceptacleRegistry("SinglePort"));
00062         updateDelivererRegistry("SinglePort", topFU->getFromDelivererRegistry("SinglePort"));
00063         updateReceptorRegistry("SinglePort", topFU->getFromReceptorRegistry("SinglePort"));
00064     }
00065     else if (config.isNone("top") && !(config.len("topPorts") == 0))
00066     {
00067         int numPorts = config.len("topPorts");
00068         for (int ii = 0; ii < numPorts; ++ii)
00069         {
00070             pyconfig::View portConfig(config, "topPorts", ii);
00071 
00072             FunctionalUnit* fu = sub->getFunctionalUnit(portConfig.get<std::string>("fuName"));
00073             std::string fuPort = portConfig.get<std::string>("fuPort.name");
00074             std::string groupPort = portConfig.get<std::string>("groupPort.name");
00075 
00076             addToConnectorReceptacleRegistry(groupPort, fu->getFromConnectorReceptacleRegistry(fuPort));
00077             addToDelivererRegistry(groupPort, fu->getFromDelivererRegistry(fuPort));
00078             addToReceptorRegistry(groupPort, fu->getFromReceptorRegistry(fuPort));
00079         }
00080     }
00081     else
00082     {
00083         wns::Exception e;
00084         e << "Misconfiguration of Group FU!";
00085         throw e;
00086     }
00087 
00088     if (!config.isNone("bottom") && (config.len("bottomPorts") == 0))
00089     {
00090         FunctionalUnit* bottomFU = sub->getFunctionalUnit(config.get<std::string>("bottom"));
00091 
00092         updateConnectorRegistry("SinglePort", bottomFU->getFromConnectorRegistry("SinglePort"));
00093         updateDelivererReceptacleRegistry("SinglePort", bottomFU->getFromDelivererReceptacleRegistry("SinglePort"));
00094         updateReceptorReceptacleRegistry("SinglePort", bottomFU->getFromReceptorReceptacleRegistry("SinglePort"));
00095     }
00096     else if (config.isNone("bottom") && !(config.len("bottomPorts") == 0))
00097     {
00098         int numPorts = config.len("bottomPorts");
00099         for (int ii = 0; ii < numPorts; ++ii)
00100         {
00101             pyconfig::View portConfig(config, "bottomPorts", ii);
00102 
00103             FunctionalUnit* fu = sub->getFunctionalUnit(portConfig.get<std::string>("fuName"));
00104             std::string fuPort = portConfig.get<std::string>("fuPort.name");
00105             std::string groupPort = portConfig.get<std::string>("groupPort.name");
00106 
00107             addToConnectorRegistry(groupPort, fu->getFromConnectorRegistry(fuPort));
00108             addToDelivererReceptacleRegistry(groupPort, fu->getFromDelivererReceptacleRegistry(fuPort));
00109             addToReceptorReceptacleRegistry(groupPort, fu->getFromReceptorReceptacleRegistry(fuPort));
00110         }
00111     }
00112     else
00113     {
00114         wns::Exception e;
00115         e << "Misconfiguration of Group FU!";
00116         throw e;
00117     }
00118 }
00119 
00120 
00121 Group::Group(const Group& other) :
00122     CompoundHandlerInterface<FunctionalUnit>(other),
00123     CommandTypeSpecifierInterface(other),
00124     HasConnectorInterface(other),
00125     HasReceptorInterface(other),
00126     HasDelivererInterface(other),
00127     CloneableInterface(other),
00128     IOutputStreamable(other),
00129     PythonicOutput(other),
00130     FunctionalUnit(other),
00131     HasReceptor<>(),
00132     HasConnector<>(),
00133     HasDeliverer<>(),
00134     CommandTypeSpecifier<>(other),
00135     Cloneable<Group>(other),
00136 
00137     config(other.config),
00138     logger("WNS", "Group")
00139 {
00140     sub = new fun::Sub(getFUN());
00141 
00142     pyconfig::View funView(config, "fun");
00143     configureFUN(sub, funView);
00144     sub->onFUNCreated();
00145 
00146     if (!config.isNone("top") && (config.len("topPorts") == 0))
00147     {
00148         FunctionalUnit* topFU = sub->getFunctionalUnit(config.get<std::string>("top"));
00149 
00150         updateConnectorReceptacleRegistry("SinglePort", topFU->getFromConnectorReceptacleRegistry("SinglePort"));
00151         updateDelivererRegistry("SinglePort", topFU->getFromDelivererRegistry("SinglePort"));
00152         updateReceptorRegistry("SinglePort", topFU->getFromReceptorRegistry("SinglePort"));
00153     }
00154     else if (config.isNone("top") && !(config.len("topPorts") == 0))
00155     {
00156         int numPorts = config.len("topPorts");
00157         for (int ii = 0; ii < numPorts; ++ii)
00158         {
00159             pyconfig::View portConfig(config, "topPorts", ii);
00160 
00161             FunctionalUnit* fu = sub->getFunctionalUnit(portConfig.get<std::string>("fuName"));
00162             std::string fuPort = portConfig.get<std::string>("fuPort.name");
00163             std::string groupPort = portConfig.get<std::string>("groupPort.name");
00164 
00165             addToConnectorReceptacleRegistry(groupPort, fu->getFromConnectorReceptacleRegistry(fuPort));
00166             addToDelivererRegistry(groupPort, fu->getFromDelivererRegistry(fuPort));
00167             addToReceptorRegistry(groupPort, fu->getFromReceptorRegistry(fuPort));
00168         }
00169     }
00170     else
00171     {
00172         wns::Exception e;
00173         e << "Misconfiguration of Group FU!";
00174         throw e;
00175     }
00176 
00177     if (!config.isNone("bottom") && (config.len("bottomPorts") == 0))
00178     {
00179         FunctionalUnit* bottomFU = sub->getFunctionalUnit(config.get<std::string>("bottom"));
00180 
00181         updateConnectorRegistry("SinglePort", bottomFU->getFromConnectorRegistry("SinglePort"));
00182         updateDelivererReceptacleRegistry("SinglePort", bottomFU->getFromDelivererReceptacleRegistry("SinglePort"));
00183         updateReceptorReceptacleRegistry("SinglePort", bottomFU->getFromReceptorReceptacleRegistry("SinglePort"));
00184     }
00185     else if (config.isNone("bottom") && !(config.len("bottomPorts") == 0))
00186     {
00187         int numPorts = config.len("bottomPorts");
00188         for (int ii = 0; ii < numPorts; ++ii)
00189         {
00190             pyconfig::View portConfig(config, "bottomPorts", ii);
00191 
00192             FunctionalUnit* fu = sub->getFunctionalUnit(portConfig.get<std::string>("fuName"));
00193             std::string fuPort = portConfig.get<std::string>("fuPort.name");
00194             std::string groupPort = portConfig.get<std::string>("groupPort.name");
00195 
00196             addToConnectorRegistry(groupPort, fu->getFromConnectorRegistry(fuPort));
00197             addToDelivererReceptacleRegistry(groupPort, fu->getFromDelivererReceptacleRegistry(fuPort));
00198             addToReceptorReceptacleRegistry(groupPort, fu->getFromReceptorReceptacleRegistry(fuPort));
00199         }
00200     }
00201     else
00202     {
00203         wns::Exception e;
00204         e << "Misconfiguration of Group FU!";
00205         throw e;
00206     }
00207 }
00208 
00209 
00210 Group::~Group()
00211 {
00212     delete sub;
00213 }
00214 
00215 
00216 void
00217 Group::onFUNCreated()
00218 {
00219     sub->onFUNCreated();
00220 } // onFUNCreated
00221 
00222 
00223 bool
00224 Group::doIsAccepting(const CompoundPtr& compound) const
00225 {
00226     wns::Exception e;
00227     e << "doIsAccepting(const CompoundPtr&) of Group FU must not be called!";
00228     throw e;
00229 } // isAccepting
00230 
00231 
00232 void
00233 Group::doSendData(const CompoundPtr& compound)
00234 {
00235     wns::Exception e;
00236     e << "doSendData(const CompoundPtr&) of Group FU must not be called!";
00237     throw e;
00238 } // doSendData
00239 
00240 
00241 void
00242 Group::doOnData(const CompoundPtr& compound)
00243 {
00244     wns::Exception e;
00245     e << "doOnData(const CompoundPtr&) of Group FU must not be called!";
00246     throw e;
00247 } // doOnData
00248 
00249 
00250 void
00251 Group::doWakeup()
00252 {
00253     wns::Exception e;
00254     e << "doWakeup() of Group FU must not be called!";
00255     throw e;
00256 } // wakeup
00257 
00258 
00259 fun::Sub*
00260 Group::getSubFUN() const
00261 {
00262     return sub;
00263 } // getSubFUN
00264 
00265 
00266 void
00267 Group::setName(std::string _name)
00268 {
00269     FunctionalUnit::setName(_name);
00270     getSubFUN()->setNameParentFU(_name);
00271 }

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