Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members

Module.hh

Go to the documentation of this file.
00001 // $Id: Module.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00027 #ifndef HH_SENF_PPI_Module_
00028 #define HH_SENF_PPI_Module_ 1
00029 
00030 // Custom includes
00031 #include <vector>
00032 #include <boost/utility.hpp>
00033 #include <boost/ptr_container/ptr_vector.hpp>
00034 #include <senf/Scheduler/ClockService.hh>
00035 #include "predecl.hh"
00036 #include "ModuleManager.hh"
00037 
00038 //#include "Module.mpp"
00039 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00040 
00041 namespace senf {
00042 namespace ppi {
00043 
00044     namespace detail { class EventBindingBase; }
00045 
00046 namespace module {
00047 
00178     class Module
00179         : ModuleManager::Initializable, boost::noncopyable
00180     {
00181     public:
00182         virtual ~Module();
00183 
00184     protected:
00185         Module();
00186 
00187 #ifndef DOXYGEN
00188         template <class Source, class Target>
00189         Route<Source, Target> & route(Source & source, Target & target);
00190 #else
00191         Route<connector::InputConnector, connector::OutputConnector> &
00192         route(connector::InputConnector & input, connector::OutputConnector & output);
00194 
00221         Route<connector::InputConnector, EventDescriptor> &
00222         route(connector::InputConnector & input, EventDescriptor & output);
00224 
00237         Route<EventDescriptor, connector::OutputConnector> &
00238         route(EventDescriptor & input, connector::OutputConnector & output);
00240 
00251 #endif
00252 
00253         void noroute(connector::Connector & connector); 
00254 
00264 #ifndef DOXYGEN
00265         template <class Descriptor, class Target>
00266         void registerEvent(Descriptor & descriptor, Target target);
00267 #else
00268         template <class Target>
00269         void registerEvent(EventDescriptor & descriptor, Target target);
00271 
00288 #endif
00289 
00290         ClockService::clock_type time() const; 
00291 
00294         ClockService::clock_type now() const; 
00295 
00296 #ifndef DOXYGEN
00297         virtual void macro_SENF_PPI_MODULE_missing() = 0;
00298 
00299     private:
00300 #endif
00301         virtual void v_init();          
00302 
00309 #ifndef DOXYGEN
00310     public:
00311 #endif
00312         void destroy();
00313 
00314     private:
00315         EventManager & eventManager() const;
00316         ModuleManager & moduleManager() const;
00317 
00318         void registerConnector(connector::Connector & connector);
00319         void unregisterConnector(connector::Connector & connector);
00320         void unregisterEvent(EventDescriptor & event);
00321 
00322         RouteBase & addRoute(std::auto_ptr<RouteBase> route);
00323 
00324         typedef std::vector<connector::Connector *> ConnectorRegistry;
00325         ConnectorRegistry connectorRegistry_;
00326 
00327         typedef boost::ptr_vector<RouteBase> RouteInfoBase;
00328         RouteInfoBase routes_;
00329 
00330         template <class Source, class Target>
00331         friend class detail::RouteHelper;
00332         friend class senf::ppi::ModuleManager;
00333         friend class connector::Connector;
00334         friend class senf::ppi::detail::EventBindingBase;
00335     };
00336 
00343 #   define SENF_PPI_MODULE(name)                                                                  \
00344     public:                                                                                       \
00345         ~ name() { destroy(); }                                                                   \
00346         void macro_SENF_PPI_MODULE_missing() {}                                                   \
00347     private:
00348 
00349 }}}
00350 
00351 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00352 #include "Module.cci"
00353 #include "Module.ct"
00354 //#include "Module.cti"
00355 #endif
00356 
00357 
00358 // Local Variables:
00359 // mode: c++
00360 // fill-column: 100
00361 // c-file-style: "senf"
00362 // indent-tabs-mode: nil
00363 // ispell-local-dictionary: "american"
00364 // compile-command: "scons -u test"
00365 // comment-column: 40
00366 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research