4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief ModuleManager public header */
31 #ifndef HH_SENF_PPI_ModuleManager_
32 #define HH_SENF_PPI_ModuleManager_ 1
38 #include <senf/Scheduler/Scheduler.hh>
39 #include <senf/Utils/Console/ScopedDirectory.hh>
41 //#include "ModuleManager.mpp"
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
47 /** \brief Internal: Module management
49 Every module is registered with the ModuleManager. The ModuleManager controls module
50 initialization and execution of the network.
55 //-////////////////////////////////////////////////////////////////////////
61 virtual ~Initializable();
62 ModuleManager & moduleManager() const;
63 void enqueueInitializable();
64 void dequeueInitializable();
65 bool initializationScheduled() const;
67 virtual void v_init() = 0;
70 //-////////////////////////////////////////////////////////////////////////
71 ///\name Structors and default members
74 static ModuleManager & instance();
76 // default default constructor
77 // default copy constructor
78 // default copy assignment
81 // no conversion constructors
84 //-////////////////////////////////////////////////////////////////////////
86 void init(); ///< Called by senf::ppi::init()
87 void run(); ///< Called by senf::ppi::run()
89 bool running() const; ///< \c true, if the network is running
91 senf::console::DirectoryNode & consoleDir() const;
96 void registerModule(module::Module & module);
97 void unregisterModule(module::Module & module);
99 void registerInitializable(Initializable & i);
100 void unregisterInitializable(Initializable & i);
101 bool initializableRegistered(Initializable const & i) const;
103 void dumpModules(std::ostream & os) const;
105 typedef std::vector<module::Module *> ModuleRegistry;
106 typedef std::deque<Initializable *> InitQueue;
110 friend class RunGuard;
113 ModuleRegistry moduleRegistry_;
117 InitQueue initQueue_;
119 scheduler::EventHook initRunner_;
121 senf::console::ScopedDirectory<> consoleDir_;
123 friend class module::Module;
124 friend class Initializable;
129 //-/////////////////////////////////////////////////////////////////////////////////////////////////
130 #include "ModuleManager.cci"
131 //#include "ModuleManager.ct"
132 //#include "ModuleManager.cti"
139 // comment-column: 40
140 // c-file-style: "senf"
141 // indent-tabs-mode: nil
142 // ispell-local-dictionary: "american"
143 // compile-command: "scons -u test"