User Manual, Developers Guide and API Documentation

Interface.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_NODE_COMPONENT_INTERFACE_HPP
00029 #define WNS_NODE_COMPONENT_INTERFACE_HPP
00030 
00031 #include <WNS/StaticFactory.hpp>
00032 #include <WNS/node/component/ConfigCreator.hpp>
00033 #include <WNS/node/Interface.hpp>
00034 #include <WNS/service/Service.hpp>
00035 
00036 #include <string>
00037 
00038 namespace wns { namespace node {
00039     class Interface;
00040 } // node
00041 } // wns
00042 
00043 namespace wns { namespace node { namespace component {
00052     class Interface
00053     {
00054     public:
00058         virtual
00059         ~Interface()
00060         {}
00061 
00067         virtual std::string
00068         getName() const = 0;
00069 
00089         void
00090         startup()
00091         {
00092             return this->doStartup();
00093         }
00094 
00104         virtual void
00105         onNodeCreated() = 0;
00106 
00114         virtual void
00115         onWorldCreated() = 0;
00116 
00121         virtual void
00122         onShutdown() = 0;
00123 
00127         template <typename SERVICETYPE>
00128         SERVICETYPE
00129         getService(const std::string& serviceName) const
00130         {
00131             return getNode()->getService<SERVICETYPE>(serviceName);
00132         }
00133 
00137         template <typename SERVICETYPE>
00138         SERVICETYPE
00139         getRemoteService(const component::FQSN& fqsn) const
00140         {
00141             return getNode()->getRemoteService<SERVICETYPE>(fqsn);
00142         }
00143 
00147         virtual void
00148         addService(const std::string& name, service::Service* service)
00149         {
00150             getNode()->addService(name, service);
00151         }
00152 
00156         virtual wns::probe::bus::ContextProviderCollection&
00157         getContextProviderCollection() const
00158         {
00159             return getNode()->getContextProviderCollection();
00160         }
00161 
00162     protected:
00166         virtual wns::node::Interface*
00167         getNode() const = 0;
00168 
00172         virtual void
00173         doStartup() = 0;
00174     };
00175 
00176     typedef
00177     ConfigCreator<component::Interface, component::Interface>
00178     Creator;
00179 
00180     typedef
00181     wns::StaticFactory<component::Creator>
00182     Factory;
00183 } // component
00184 } // node
00185 } // wns
00186 #endif
00187 
00188 /*
00189   Local Variables:
00190   mode: c++
00191   fill-column: 80
00192   c-basic-offset: 8
00193   c-tab-always-indent: t
00194   indent-tabs-mode: t
00195   tab-width: 8
00196   End:
00197 */

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