X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FModuleManager.hh;h=14ad1a925bfad3c54b497a25432ccc2a5e1e9c01;hb=b8ca4a544cce3e6023bb56b712a03d6362f2bb79;hp=843562bb24006c117c816bea8c0043ef66a2808d;hpb=0327b3f303ea2a61d44a30bfaac022874dcf2a0d;p=senf.git diff --git a/PPI/ModuleManager.hh b/PPI/ModuleManager.hh index 843562b..14ad1a9 100644 --- a/PPI/ModuleManager.hh +++ b/PPI/ModuleManager.hh @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -23,12 +23,14 @@ /** \file \brief ModuleManager public header */ -#ifndef HH_ModuleManager_ -#define HH_ModuleManager_ 1 +#ifndef HH_SENF_PPI_ModuleManager_ +#define HH_SENF_PPI_ModuleManager_ 1 // Custom includes #include +#include #include "predecl.hh" +#include "../Scheduler/Scheduler.hh" //#include "ModuleManager.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -36,12 +38,30 @@ namespace senf { namespace ppi { - /** \brief + /** \brief Internal: Module management + + Every module is registered with the ModuleManager. The ModuleManager controls module + initialization and execution of the network. */ class ModuleManager { public: /////////////////////////////////////////////////////////////////////////// + // Types + + struct Initializable + { + Initializable(); + virtual ~Initializable(); + ModuleManager & moduleManager() const; + void enqueueInitializable(); + void dequeueInitializable(); + bool initializationScheduled() const; + + virtual void v_init() = 0; + }; + + /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ @@ -57,25 +77,39 @@ namespace ppi { ///@} /////////////////////////////////////////////////////////////////////////// - void registerModule(module::Module & module); - void unregisterModule(module::Module & module); - - void init(); - void run(); + void init(); ///< Called by senf::ppi::init() + void run(); ///< Called by senf::ppi::run() - bool running() const; + bool running() const; ///< \c true, if the network is running private: ModuleManager(); + void registerModule(module::Module & module); + void unregisterModule(module::Module & module); + + void registerInitializable(Initializable & i); + void unregisterInitializable(Initializable & i); + bool initializableRegistered(Initializable const & i) const; + typedef std::vector ModuleRegistry; + typedef std::deque InitQueue; +#ifndef DOXYGEN struct RunGuard; friend class RunGuard; +#endif ModuleRegistry moduleRegistry_; bool running_; bool terminate_; + + InitQueue initQueue_; + + scheduler::EventHook initRunner_; + + friend class module::Module; + friend class Initializable; };