fwkPython.cc
Go to the documentation of this file.
1 #include <boost/python.hpp>
2 #include <boost/preprocessor.hpp>
3 using namespace boost::python;
4 
5 #include <evt/Event.h>
6 
7 #include <fwk/RunController.h>
8 #include <fwk/CentralConfig.h>
9 #include <fwk/VModule.h>
10 
11 #include <string>
12 
13 void Config(const std::string& infile)
14 {
15  fwk::CentralConfig::GetInstance(infile, false);
16 }
17 
18 void WriteConfig(std::string filename)
19 {
21 }
22 
23 std::string GetConfig()
24 {
26 }
27 
28 struct VModuleWrap : fwk::VModule, wrapper<fwk::VModule>
29 {
31  {
32  return this->get_override("Init")();
33  }
34 
36  {
37  return this->get_override("Run")(event);
38  }
39 
41  {
42  return this->get_override("Finish")();
43  }
44 };
45 
46 // CentralConfig
47 // NOTE: still can't get this to work; no use banging my head...
48 /*
49 static fwk::CentralConfig* (fwk::CentralConfig::*get_instance2)(const std::string&,
50  const bool) = &fwk::CentralConfig::GetInstance;
51 
52 void (fwk::CentralConfig::*write_config1)(std::string) = &fwk::CentralConfig::WriteConfig;
53 */
54 
55 // RunController
57 
58 // VModule
60 
61 void fwkPython()
62 {
63  class_<fwk::RunController, boost::noncopyable>("RunController", no_init)
64  .def("GetInstance", &fwk::RunController::GetInstance,
65  return_value_policy<reference_existing_object>())
66  .staticmethod("GetInstance")
67  .def("Init", &fwk::RunController::Init)
68  .def("Run", &fwk::RunController::Run)
69  .def("Finish", &fwk::RunController::Finish)
70  .def("GetNumberOfRegisteredModules", &fwk::RunController::GetNumberOfRegisteredModules)
71  .def("GetRegisteredModuleNames", &fwk::RunController::GetRegisteredModuleNames)
72  .def("GetModule", get_module,
73  return_internal_reference<>());
74 
75  def("Config", Config);
76  def("WriteConfig", WriteConfig);
77  def("GetConfig", GetConfig);
78 
79  /*
80  class_<fwk::CentralConfig, boost::noncopyable>("CentralConfig", no_init)
81  .def("GetInstance", &fwk::CentralConfig::GetInstance,
82  return_value_policy<reference_existing_object>())
83  .staticmethod("GetInstance")
84  .def("GetInstance", get_instance2,
85  return_value_policy<reference_existing_object>())
86  .staticmethod("GetInstance")
87  .def("WriteConfig", write_config1)
88  .def("GetConfig", &fwk::CentralConfig::GetConfig);
89  */
90 
91  enum_<fwk::VModule::ResultFlag>("ResultFlag")
92  .value("eSuccess", fwk::VModule::eSuccess)
93  .value("eFailure", fwk::VModule::eFailure)
94  .value("eBreakLoop", fwk::VModule::eBreakLoop)
95  .value("eContinueLoop", fwk::VModule::eContinueLoop);
96 
97  class_<VModuleWrap, boost::noncopyable>("VModule")
98  .def("Init", pure_virtual(&fwk::VModule::Init))
99  .def("Run", pure_virtual(run))
100  .def("Finish", pure_virtual(&fwk::VModule::Finish));
101 }
std::string GetRegisteredModuleNames() const
Get list of all module builder names and module versions in the registry.
Report success to RunController.
Definition: VModule.h:62
virtual ResultFlag Finish()=0
Finish: invoked at end of the run (NOT end of the event)
virtual void Init()
Skip remaining modules in the current loop and continue with next iteration of the loop...
Definition: VModule.h:68
std::string GetConfig()
Get configuration in a string.
fwk::VModule &(fwk::RunController::* get_module)(const std::string &) const
Definition: fwkPython.cc:56
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
Definition: fwkPython.cc:40
Break current loop. It works for nested loops too!
Definition: VModule.h:66
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Definition: fwkPython.cc:30
Auger Software Run Control.
Definition: RunController.h:26
void WriteConfig(std::string filename)
Definition: fwkPython.cc:18
virtual ResultFlag Run(evt::Event &event)=0
Run: invoked once per event.
Module interface.
Definition: VModule.h:53
fwk::VModule::ResultFlag(fwk::VModule::* run)(evt::Event &)
Definition: fwkPython.cc:59
int GetNumberOfRegisteredModules() const
Return number of registered modules.
virtual void Finish()
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
void fwkPython()
Definition: fwkPython.cc:61
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
Definition: fwkPython.cc:35
Report failure to RunController, causing RunController to terminate execution.
Definition: VModule.h:64
char * filename
Definition: dump1090.h:266
void WriteConfig(const std::string &fileName="")
Get the link name for moduleConfigLink with given id (any)
virtual ResultFlag Init()=0
Initialize: invoked at beginning of run (NOT beginning of event)
virtual void Run()
void Config(const std::string &infile)
Definition: fwkPython.cc:13
VModule & GetModule(const std::string &moduleName) const
Get module by name.
std::string GetConfig()
Definition: fwkPython.cc:23

, generated on Tue Sep 26 2023.