MyPyModule.h
Go to the documentation of this file.
1 #ifndef _MyModuleNS_MyPyModule_h_
2 #define _MyModuleNS_MyPyModule_h_
3 
4 #include <fwk/VModule.h>
5 #include <pybind11/embed.h>
6 #include <string>
7 
8 
9 namespace evt {
10  class Event;
11 }
12 
13 //export HDF5_DISABLE_VERSION_CHECK=1
14 
15 // you should assign your module to a namespace
16 namespace MyPyModuleNS {
17 
27  class MyPyModule : public fwk::VModule {
28 
29  public:
30  fwk::VModule::ResultFlag Init() override;
31  fwk::VModule::ResultFlag Run(evt::Event& event) override;
33 
34  private:
35  // const pybind11::scoped_interpreter guard;
36  int fInfoLevel = 0;
37  std::string fFilename;
38 
39  pybind11::module_ fModule;
40  pybind11::object fMainClass;
41 
42  REGISTER_MODULE("MyPyModule", MyPyModule);
43 
44  };
45 
46 }
47 
48 
49 #endif
fwk::VModule::ResultFlag Finish() override
Finish: invoked at end of the run (NOT end of the event)
Definition: MyPyModule.cc:71
Basic example module to call a Python script.
Definition: MyPyModule.h:27
pybind11::module_ fModule
Definition: MyPyModule.h:39
REGISTER_MODULE("MyPyModule", MyPyModule)
fwk::VModule::ResultFlag Run(evt::Event &event) override
Run: invoked once per event.
Definition: MyPyModule.cc:47
pybind11::object fMainClass
Definition: MyPyModule.h:40
Module interface.
Definition: VModule.h:53
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
fwk::VModule::ResultFlag Init() override
Initialize: invoked at beginning of run (NOT beginning of event)
Definition: MyPyModule.cc:25

, generated on Tue Sep 26 2023.