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

ModuleManager.hh

Go to the documentation of this file.
00001 // $Id: ModuleManager.hh 1781 2011-04-11 12:10:19Z tho $
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 
00026 #ifndef HH_SENF_PPI_ModuleManager_
00027 #define HH_SENF_PPI_ModuleManager_ 1
00028 
00029 // Custom includes
00030 #include <vector>
00031 #include <deque>
00032 #include "predecl.hh"
00033 #include <senf/Scheduler/Scheduler.hh>
00034 #include <senf/Utils/Console/ScopedDirectory.hh>
00035 
00036 //#include "ModuleManager.mpp"
00037 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00038 
00039 namespace senf {
00040 namespace ppi {
00041 
00047     class ModuleManager
00048     {
00049     public:
00050         //-////////////////////////////////////////////////////////////////////////
00051         // Types
00052 
00053         struct Initializable
00054         {
00055             Initializable();
00056             virtual ~Initializable();
00057             ModuleManager & moduleManager() const;
00058             void enqueueInitializable();
00059             void dequeueInitializable();
00060             bool initializationScheduled() const;
00061 
00062             virtual void v_init() = 0;
00063         };
00064 
00065         //-////////////////////////////////////////////////////////////////////////
00067         //\{
00068 
00069         static ModuleManager & instance();
00070 
00071         // default default constructor
00072         // default copy constructor
00073         // default copy assignment
00074         // default destructor
00075 
00076         // no conversion constructors
00077 
00078         //\}
00079         //-////////////////////////////////////////////////////////////////////////
00080 
00081         void init();                    
00082         void run();                     
00083 
00084         bool running() const;           
00085 
00086         senf::console::DirectoryNode & consoleDir() const;
00087 
00088     private:
00089         ModuleManager();
00090 
00091         void registerModule(module::Module & module);
00092         void unregisterModule(module::Module & module);
00093 
00094         void registerInitializable(Initializable & i);
00095         void unregisterInitializable(Initializable & i);
00096         bool initializableRegistered(Initializable const & i) const;
00097 
00098         void dumpModules(std::ostream & os) const;
00099 
00100         typedef std::vector<module::Module *> ModuleRegistry;
00101         typedef std::deque<Initializable *> InitQueue;
00102 
00103 #ifndef DOXYGEN
00104         struct RunGuard;
00105         friend class RunGuard;
00106 #endif
00107 
00108         ModuleRegistry moduleRegistry_;
00109         bool running_;
00110         bool terminate_;
00111 
00112         InitQueue initQueue_;
00113 
00114         scheduler::EventHook initRunner_;
00115 
00116         senf::console::ScopedDirectory<> consoleDir_;
00117 
00118         friend class module::Module;
00119         friend class Initializable;
00120     };
00121 
00122 }}
00123 
00124 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00125 #include "ModuleManager.cci"
00126 //#include "ModuleManager.ct"
00127 //#include "ModuleManager.cti"
00128 #endif
00129 
00130 
00131 // Local Variables:
00132 // mode: c++
00133 // fill-column: 100
00134 // comment-column: 40
00135 // c-file-style: "senf"
00136 // indent-tabs-mode: nil
00137 // ispell-local-dictionary: "american"
00138 // compile-command: "scons -u test"
00139 // End:

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