#include <InitSequencer.h>
Inheritance diagram for oasys::InitSequencer:
Suppose you have a singleton style modules A, B and C with an init method and B depends on A and C depends on A and B. C also has configuration options which need to be set. example is the namespace of the modules A, B and C.
// A.cc OASYS_DECLARE_INIT_MODULE_0(example, A) { A::init(); } // B.cc - depends on A OASYS_DECLARE_INIT_MODULE_1(example, B, "example::A") { B::init(); } // C.cc - configuration option OASYS_DECLARE_INIT_CONFIG(example, C_config); // C.cc - depends on A, B and C_config OASYS_DECLARE_INIT_MODULE_2(example, C, "example::A", "example::B", "example::C_config") { C::init(); }
Now to start component "C", something needs to call OASYS_INIT_CONFIG_DONE(example, C_config) first, and then:
// ... some configuration setting code OASYS_INIT_CONFIG_DONE(example, C_config); // ... Singleton<InitSequencer> sequencer; sequencer->start("example::C");
Definition at line 77 of file InitSequencer.h.
Public Types | |
typedef std::map< std::string, InitStep * > | StepMap |
typedef std::vector< std::string > | Plan |
Public Member Functions | |
InitSequencer () | |
int | start (std::string step, Plan *plan=0) |
Perform the actions needed to start the component. | |
void | add_step (InitStep *step) |
InitStep * | get_step (const std::string &name) |
void | reset () |
void | print_dot () |
Private Types | |
typedef std::vector< std::string > | ReverseDepList |
typedef std::map< std::string, ReverseDepList > | ReverseDepEdges |
Private Member Functions | |
int | run_steps () |
Run the steps. | |
int | topo_sort () |
Do topological sort. | |
void | dfs (InitStep *step, ReverseDepEdges &edges) |
void | mark_dep (const std::string &target) |
Mark steps that are needed to start target. | |
void | add_extra_dep (InitExtraDependency *extra_dep) |
Add this step as a dependency. | |
void | add_extra_deps () |
Actually add the dependencies. | |
Private Attributes | |
StepMap | steps_ |
int | dfs_time_ |
std::vector< InitExtraDependency * > | extra_dependencies_ |
Friends | |
class | InitExtraDependency |
typedef std::map<std::string, InitStep*> oasys::InitSequencer::StepMap |
Definition at line 81 of file InitSequencer.h.
typedef std::vector<std::string> oasys::InitSequencer::Plan |
Definition at line 82 of file InitSequencer.h.
typedef std::vector<std::string> oasys::InitSequencer::ReverseDepList [private] |
Definition at line 118 of file InitSequencer.h.
typedef std::map<std::string, ReverseDepList> oasys::InitSequencer::ReverseDepEdges [private] |
Definition at line 119 of file InitSequencer.h.
oasys::InitSequencer::InitSequencer | ( | ) |
Definition at line 39 of file InitSequencer.cc.
int oasys::InitSequencer::start | ( | std::string | step, | |
Plan * | plan = 0 | |||
) |
Perform the actions needed to start the component.
step | which step to start | |
plan | optional plan (made by humans) which the InitSequencer will try to execute. |
Definition at line 45 of file InitSequencer.cc.
References add_extra_deps(), mark_dep(), run_steps(), and topo_sort().
void oasys::InitSequencer::add_step | ( | InitStep * | step | ) |
Add a step to the initialization.
Definition at line 69 of file InitSequencer.cc.
References ASSERT, log_warn, oasys::InitStep::name(), and steps_.
InitStep * oasys::InitSequencer::get_step | ( | const std::string & | name | ) |
Get a InitStep* from the name
Definition at line 84 of file InitSequencer.cc.
void oasys::InitSequencer::reset | ( | ) |
Reset the done state of all of the modules. NOTE: This is mostly for the testing harness. You better know what you're doing if you call this.
Definition at line 91 of file InitSequencer.cc.
References steps_.
void oasys::InitSequencer::print_dot | ( | ) |
Log a dot graph of the dependencies.
Definition at line 101 of file InitSequencer.cc.
int oasys::InitSequencer::run_steps | ( | ) | [private] |
int oasys::InitSequencer::topo_sort | ( | ) | [private] |
void oasys::InitSequencer::dfs | ( | InitStep * | step, | |
ReverseDepEdges & | edges | |||
) | [private] |
Definition at line 204 of file InitSequencer.cc.
References dfs_time_, oasys::InitStep::name(), steps_, and oasys::InitStep::time_.
Referenced by topo_sort().
void oasys::InitSequencer::mark_dep | ( | const std::string & | target | ) | [private] |
void oasys::InitSequencer::add_extra_dep | ( | InitExtraDependency * | extra_dep | ) | [private] |
Add this step as a dependency.
Definition at line 265 of file InitSequencer.cc.
References extra_dependencies_.
void oasys::InitSequencer::add_extra_deps | ( | ) | [private] |
Actually add the dependencies.
Definition at line 271 of file InitSequencer.cc.
References ASSERT, extra_dependencies_, log_debug, and steps_.
Referenced by start().
friend class InitExtraDependency [friend] |
Definition at line 78 of file InitSequencer.h.
StepMap oasys::InitSequencer::steps_ [private] |
Definition at line 121 of file InitSequencer.h.
Referenced by add_extra_deps(), add_step(), dfs(), get_step(), mark_dep(), print_dot(), reset(), run_steps(), and topo_sort().
int oasys::InitSequencer::dfs_time_ [private] |
std::vector<InitExtraDependency*> oasys::InitSequencer::extra_dependencies_ [private] |
Definition at line 124 of file InitSequencer.h.
Referenced by add_extra_dep(), and add_extra_deps().