Belle II Software light-2406-ragdoll
Module.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <boost/python/register_ptr_to_python.hpp>
10#include <boost/python/class.hpp>
11#include <boost/python/list.hpp>
12#include <boost/python/dict.hpp>
13#include <boost/python/copy_const_reference.hpp>
14#include <boost/python/overloads.hpp>
15#include <boost/python/enum.hpp>
16#include <boost/python/docstring_options.hpp>
17#include <utility>
18
19#include <framework/core/Module.h>
20#include <framework/core/ModuleCondition.h>
21#include <framework/core/PyModule.h>
22#include <framework/core/ModuleManager.h>
23#include <framework/core/Path.h>
24
25#include <framework/logging/Logger.h>
26
27using namespace Belle2;
28using namespace boost::python;
29
31 m_name(),
32 m_type(),
33 m_description("Not set by the author"),
34 m_propertyFlags(0),
35 m_logConfig(),
36 m_hasReturnValue(false),
37 m_returnValue(0)
38{
39}
40
41const std::string& Module::getType() const
42{
43 if (m_type.empty())
44 B2FATAL("Module type not set for " << getName());
45 return m_type;
46}
47
48void Module::setType(const std::string& type)
49{
50 if (!m_type.empty())
51 B2FATAL("Trying to change module type from " << m_type << " is not allowed, the value is assumed to be fixed.");
52 m_type = type;
53}
54
55void Module::setLogLevel(int logLevel)
56{
57 m_logConfig.setLogLevel(static_cast<LogConfig::ELogLevel>(logLevel));
58}
59
60
61void Module::setDebugLevel(int debugLevel)
62{
63 m_logConfig.setDebugLevel(debugLevel);
64}
65
66
67void Module::setAbortLevel(int abortLevel)
68{
69 m_logConfig.setAbortLevel(static_cast<LogConfig::ELogLevel>(abortLevel));
70}
71
72
73void Module::setLogInfo(int logLevel, unsigned int logInfo)
74{
75 m_logConfig.setLogInfo(static_cast<LogConfig::ELogLevel>(logLevel), logInfo);
76}
77
78
79void Module::if_value(const std::string& expression, const std::shared_ptr<Path>& path, EAfterConditionPath afterConditionPath)
80{
81 m_conditions.emplace_back(expression, path, afterConditionPath);
82}
83
84
85void Module::if_false(const std::shared_ptr<Path>& path, EAfterConditionPath afterConditionPath)
86{
87 if_value("<1", path, afterConditionPath);
88}
89
90void Module::if_true(const std::shared_ptr<Path>& path, EAfterConditionPath afterConditionPath)
91{
92 if_value(">=1", path, afterConditionPath);
93}
94
95
97{
98 if (m_conditions.empty()) return false;
99
100 //okay, a condition was set for this Module...
101 if (!m_hasReturnValue) {
102 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
103 }
104
105 for (const auto& condition : m_conditions) {
106 if (condition.evaluate(m_returnValue)) {
107 return true;
108 }
109 }
110 return false;
111}
112
113std::shared_ptr<Path> Module::getConditionPath() const
114{
115 PathPtr p;
116 if (m_conditions.empty()) return p;
117
118 //okay, a condition was set for this Module...
119 if (!m_hasReturnValue) {
120 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
121 }
122
123 for (const auto& condition : m_conditions) {
124 if (condition.evaluate(m_returnValue)) {
125 return condition.getPath();
126 }
127 }
128
129 // if none of the conditions were true, return a null pointer.
130 return p;
131}
132
134{
135 if (m_conditions.empty()) return EAfterConditionPath::c_End;
136
137 //okay, a condition was set for this Module...
138 if (!m_hasReturnValue) {
139 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
140 }
141
142 for (const auto& condition : m_conditions) {
143 if (condition.evaluate(m_returnValue)) {
144 return condition.getAfterConditionPath();
145 }
146 }
147
148 return EAfterConditionPath::c_End;
149}
150std::vector<std::shared_ptr<Path>> Module::getAllConditionPaths() const
151{
152 std::vector<std::shared_ptr<Path>> allConditionPaths;
153 for (const auto& condition : m_conditions) {
154 allConditionPaths.push_back(condition.getPath());
155 }
156
157 return allConditionPaths;
158}
159
160bool Module::hasProperties(unsigned int propertyFlags) const
161{
162 return (propertyFlags & m_propertyFlags) == propertyFlags;
163}
164
165
167{
169 std::string allMissing = "";
170 for (const auto& s : missing)
171 allMissing += s + " ";
172 if (!missing.empty())
173 B2ERROR("The following required parameters of Module '" << getName() << "' were not specified: " << allMissing <<
174 "\nPlease add them to your steering file.");
175 return !missing.empty();
176}
177
178
179std::shared_ptr<PathElement> Module::clone() const
180{
182 newModule->m_moduleParamList.setParameters(getParamList());
183 newModule->setName(getName());
184 newModule->m_package = m_package;
185 newModule->m_propertyFlags = m_propertyFlags;
186 newModule->m_logConfig = m_logConfig;
187 newModule->m_conditions = m_conditions;
188
189 return newModule;
190}
191
192std::string Module::getPathString() const
193{
194
195 std::string output = getName();
196
197 for (const auto& condition : m_conditions) {
198 output += condition.getString();
199 }
200
201 return output;
202}
203
204//============================================================================
205// Protected methods
206//============================================================================
207
208void Module::setPropertyFlags(unsigned int propertyFlags)
209{
210 m_propertyFlags = propertyFlags;
211}
212
213
214void Module::setDescription(const std::string& description)
215{
216 m_description = description;
217}
218
219
221{
222 m_hasReturnValue = true;
223 m_returnValue = value;
224}
225
226
228{
229 m_hasReturnValue = true;
230 m_returnValue = value;
231}
232
233
234void Module::setParamPython(const std::string& name, const boost::python::object& pyObj)
235{
236 LogSystem& logSystem = LogSystem::Instance();
237 logSystem.updateModule(&(getLogConfig()), getName());
238 try {
240 } catch (std::runtime_error& e) {
241 throw std::runtime_error("Cannot set parameter '" + name + "' for module '"
242 + m_name + "': " + e.what());
243 }
244
245 logSystem.updateModule(nullptr);
246}
247
248
249void Module::setParamPythonDict(const boost::python::dict& dictionary)
250{
251
252 LogSystem& logSystem = LogSystem::Instance();
253 logSystem.updateModule(&(getLogConfig()), getName());
254
255 boost::python::list dictKeys = dictionary.keys();
256 int nKey = boost::python::len(dictKeys);
257
258 //Loop over all keys in the dictionary
259 for (int iKey = 0; iKey < nKey; ++iKey) {
260 boost::python::object currKey = dictKeys[iKey];
261 boost::python::extract<std::string> keyProxy(currKey);
262
263 if (keyProxy.check()) {
264 const boost::python::object& currValue = dictionary[currKey];
265 setParamPython(keyProxy, currValue);
266 } else {
267 B2ERROR("Setting the module parameters from a python dictionary: invalid key in dictionary!");
268 }
269 }
270
271 logSystem.updateModule(nullptr);
272}
273
274
275//=====================================================================
276// Python API
277//=====================================================================
278
279std::shared_ptr<boost::python::list> Module::getParamInfoListPython() const
280{
282}
283
284namespace {
286 boost::python::list _getParamInfoListPython(const Module* m)
287 {
288 return *(m->getParamInfoListPython().get()); //copy the list object
289 }
290 boost::python::list _getAllConditionPathsPython(const Module* m)
291 {
292 boost::python::list allConditionPaths;
293 for (const auto& conditionPath : m->getAllConditionPaths()) {
294 allConditionPaths.append(boost::python::object(conditionPath));
295 }
296
297 return allConditionPaths;
298 }
299 boost::python::list _getAllConditionsPython(const Module* m)
300 {
301 boost::python::list allConditions;
302 for (const auto& condition : m->getAllConditions()) {
303 allConditions.append(boost::python::object(boost::ref(condition)));
304 }
305
306 return allConditions;
307 }
308}
309
310#if !defined(__GNUG__) || defined(__ICC)
311#else
312#pragma GCC diagnostic push
313#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
314#endif
315// cppcheck-suppress unknownMacro
316BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(if_value_overloads, if_value, 2, 3)
317BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(if_false_overloads, if_false, 1, 2)
318BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(if_true_overloads, if_true, 1, 2)
319#if !defined(__GNUG__) || defined(__ICC)
320#else
321#pragma GCC diagnostic pop
322#endif
323
324
326{
327 // to avoid confusion between std::arg and boost::python::arg we want a shorthand namespace as well
328 namespace bp = boost::python;
329
330 docstring_options options(true, true, false); //userdef, py sigs, c++ sigs
331
332 void (Module::*setReturnValueInt)(int) = &Module::setReturnValue;
333
334 enum_<Module::EAfterConditionPath>("AfterConditionPath",
335 R"(Determines execution behaviour after a conditional path has been executed:
336
337.. attribute:: END
338
339 End processing of this path after the conditional path. (this is the default for if_value() etc.)
340
341.. attribute:: CONTINUE
342
343 After the conditional path, resume execution after this module.)")
344 .value("END", Module::EAfterConditionPath::c_End)
345 .value("CONTINUE", Module::EAfterConditionPath::c_Continue)
346 ;
347
348 /* Do not change the names of >, <, ... we use them to serialize conditional pathes */
349 enum_<Belle2::ModuleCondition::EConditionOperators>("ConditionOperator")
356 ;
357
358 enum_<Module::EModulePropFlags>("ModulePropFlags",
359 R"(Flags to indicate certain low-level features of modules, see :func:`Module.set_property_flags()`, :func:`Module.has_properties()`. Most useful flags are:
360
361.. attribute:: PARALLELPROCESSINGCERTIFIED
362
363 This module can be run in parallel processing mode safely (All I/O must be done through the data store, in particular, the module must not write any files.)
364
365.. attribute:: HISTOGRAMMANAGER
366
367 This module is used to manage histograms accumulated by other modules
368
369.. attribute:: TERMINATEINALLPROCESSES
370
371 When using parallel processing, call this module's terminate() function in all processes. This will also ensure that there is exactly one process (single-core if no parallel modules found) or at least one input, one main and one output process.
372)")
373 .value("INPUT", Module::EModulePropFlags::c_Input)
374 .value("OUTPUT", Module::EModulePropFlags::c_Output)
375 .value("PARALLELPROCESSINGCERTIFIED", Module::EModulePropFlags::c_ParallelProcessingCertified)
376 .value("HISTOGRAMMANAGER", Module::EModulePropFlags::c_HistogramManager)
377 .value("INTERNALSERIALIZER", Module::EModulePropFlags::c_InternalSerializer)
378 .value("TERMINATEINALLPROCESSES", Module::EModulePropFlags::c_TerminateInAllProcesses)
379 ;
380
381 //Python class definition
382 class_<Module, PyModule> module("Module", R"(
383Base class for Modules.
384
385A module is the smallest building block of the framework.
386A typical event processing chain consists of a Path containing
387modules. By inheriting from this base class, various types of
388modules can be created. To use a module, please refer to
389:func:`Path.add_module()`. A list of modules is available by running
390``basf2 -m`` or ``basf2 -m package``, detailed information on parameters is
391given by e.g. ``basf2 -m RootInput``.
392
393The 'Module Development' section in the manual provides detailed information
394on how to create modules, setting parameters, or using return values/conditions:
395https://confluence.desy.de/display/BI/Software+Basf2manual#Module_Development
396
397)");
398 module
399 .def("__str__", &Module::getPathString)
400 .def("name", &Module::getName, return_value_policy<copy_const_reference>(),
401 "Returns the name of the module. Can be changed via :func:`set_name() <Module.set_name()>`, use :func:`type() <Module.type()>` for identifying a particular module class.")
402 .def("type", &Module::getType, return_value_policy<copy_const_reference>(),
403 "Returns the type of the module (i.e. class name minus 'Module')")
404 .def("set_name", &Module::setName, args("name"), R"(
405Set custom name, e.g. to distinguish multiple modules of the same type.
406
407>>> path.add_module('EventInfoSetter')
408>>> ro = path.add_module('RootOutput', branchNames=['EventMetaData'])
409>>> ro.set_name('RootOutput_metadata_only')
410>>> print(path)
411[EventInfoSetter -> RootOutput_metadata_only]
412
413)")
414 .def("description", &Module::getDescription, return_value_policy<copy_const_reference>(),
415 "Returns the description of this module.")
416 .def("package", &Module::getPackage, return_value_policy<copy_const_reference>(),
417 "Returns the package this module belongs to.")
418 .def("available_params", &_getParamInfoListPython,
419 "Return list of all module parameters as `ModuleParamInfo` instances")
420 .def("has_properties", &Module::hasProperties, (bp::arg("properties")),
421 R"DOCSTRING(Allows to check if the module has the given properties out of `ModulePropFlags` set.
422
423>>> if module.has_properties(ModulePropFlags.PARALLELPROCESSINGCERTIFIED):
424>>> ...
425
426Parameters:
427 properties (int): bitmask of `ModulePropFlags` to check for.
428)DOCSTRING")
429 .def("set_property_flags", &Module::setPropertyFlags, args("property_mask"),
430 "Set module properties in the form of an OR combination of `ModulePropFlags`.");
431 {
432 // python signature is too crowded, make ourselves
433 docstring_options subOptions(true, false, false); //userdef, py sigs, c++ sigs
434 module
435 .def("if_value", &Module::if_value,
436 (bp::arg("expression"), bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
437 R"DOCSTRING(if_value(expression, condition_path, after_condition_path=AfterConditionPath.END)
438
439Sets a conditional sub path which will be executed after this
440module if the return value set in the module passes the given ``expression``.
441
442Modules can define a return value (int or bool) using ``setReturnValue()``,
443which can be used in the steering file to split the Path based on this value, for example
444
445>>> module_with_condition.if_value("<1", another_path)
446
447In case the return value of the ``module_with_condition`` for a given event is
448less than 1, the execution will be diverted into ``another_path`` for this event.
449
450You could for example set a special return value if an error occurs, and divert
451the execution into a path containing :b2:mod:`RootOutput` if it is found;
452saving only the data producing/produced by the error.
453
454After a conditional path has executed, basf2 will by default stop processing
455the path for this event. This behaviour can be changed by setting the
456``after_condition_path`` argument.
457
458Parameters:
459 expression (str): Expression to determine if the conditional path should be executed.
460 This should be one of the comparison operators ``<``, ``>``, ``<=``,
461 ``>=``, ``==``, or ``!=`` followed by a numerical value for the return value
462 condition_path (Path): path to execute in case the expression is fulfilled
463 after_condition_path (AfterConditionPath): What to do once the ``condition_path`` has been executed.
464)DOCSTRING")
465 .def("if_false", &Module::if_false,
466 (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
467 R"DOC(if_false(condition_path, after_condition_path=AfterConditionPath.END)
468
469Sets a conditional sub path which will be executed after this module if
470the return value of the module evaluates to False. This is equivalent to
471calling `if_value` with ``expression=\"<1\"``)DOC")
472 .def("if_true", &Module::if_true,
473 (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
474 R"DOC(if_true(condition_path, after_condition_path=AfterConditionPath.END)
475
476Sets a conditional sub path which will be executed after this module if
477the return value of the module evaluates to True. It is equivalent to
478calling `if_value` with ``expression=\">=1\"``)DOC");
479 }
480 module
481 .def("has_condition", &Module::hasCondition,
482 "Return true if a conditional path has been set for this module "
483 "using `if_value`, `if_true` or `if_false`")
484 .def("get_all_condition_paths", &_getAllConditionPathsPython,
485 "Return a list of all conditional paths set for this module using "
486 "`if_value`, `if_true` or `if_false`")
487 .def("get_all_conditions", &_getAllConditionsPython,
488 "Return a list of all conditional path expressions set for this module using "
489 "`if_value`, `if_true` or `if_false`")
490 .add_property("logging", make_function(&Module::getLogConfig, return_value_policy<reference_existing_object>()),
492 .def("return_value", setReturnValueInt, bp::arg("value"), \
493 "Set a return value. Can be used by custom modules to set the return value "
494 "used to determine if conditional paths are executed")
495 .def("set_log_level", &Module::setLogLevel, bp::arg("log_level"),
496 "Set the log level for this module. Messages below that level will be suppressed\n\n"
497 "Parameters:\n log_level (LogLevel): Minimum level for messages to be displayed")
498 .def("set_debug_level", &Module::setDebugLevel, bp::arg("debug_level"),
499 "Set the debug level for this module. Debug messages with a higher level will "
500 "be suppressed. This function has no visible effect if the log level is "
501 "not set to `DEBUG <LogLevel.DEBUG>`\n\n"
502 "Parameters:\n debug_level (int): Maximum debug level for messages to be displayed.")
503 .def("set_abort_level", &Module::setAbortLevel, bp::arg("abort_level"),
504 "Set the log level which will cause processing to be aborted. Usually "
505 "processing is only aborted for `FATAL <LogLevel.FATAL>` messages "
506 "but with this function it's possible to set this to a lower value\n\n"
507 "Parameters:\n abort_level (LogLevel): log level which will cause processing to be aborted.")
508 .def("set_log_info", &Module::setLogInfo, args("log_info"),
509 "Set a `LogInfo` configuration object for this module to determine how log messages should be formatted")
510 //tell python about the default implementations of virtual functions
511 .def("initialize", &Module::def_initialize,
512 "This function is called by the processing just once before processing any data "
513 "is processed. Modules can override this method to perform some actions at "
514 "startup once all parameters are set")
515 .def("beginRun", &Module::def_beginRun,
516 "This function is called by the processing just before a new run of data "
517 "is processed. Modules can override this method to perform actions which "
518 "are run dependent")
519 .def("event", &Module::def_event,
520 "This function is called by the processing once for each event."
521 "Modules should override this method to perform actions during event processing")
522 .def("endRun", &Module::def_endRun,
523 "This function is called by the processing just after a new run of data "
524 "is processed. Modules can override this method to perform actions which "
525 "are run dependent")
526 .def("terminate", &Module::def_terminate,
527 "This function is called by the processing once after all data "
528 "is processed. Modules can override this method to perform some cleanup at "
529 "shutdown. The terminate functions of all modules are called in reverse "
530 "order of the `initialize` calls.")
531 ;
532 {
533 // The param function is overloaded with different signatures which makes
534 // the boost docstring very useless so we handcraft a docstring
535 docstring_options param_options(true, false, false); //userdef, py sigs, c++ sigs
536 module
537 .def("param", &Module::setParamPython)
538 .def("param", &Module::setParamPythonDict, R"DOCSTRING(param(key, value=None)
539This method can be used to set module parameters. There are two ways of
540calling this function:
541
5421. With two arguments where the first is the name of the parameter and the second is the value.
543
544 >>> module.param("parameterName", "parameterValue")
545
5462. Or with just one parameter which is a dictionary mapping multiple parameter names to their values
547
548 >>> module.param({"parameter1": "value1", "parameter2": True})
549)DOCSTRING")
550 ;
551 }
552
553 register_ptr_to_python<ModulePtr>();
554}
555
556//=====================================================================
557// ModuleProxyBase
558//=====================================================================
559
560ModuleProxyBase::ModuleProxyBase(std::string moduleType, std::string package) : m_moduleType(std::move(moduleType)),
561 m_package(std::move(package))
562{
564}
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition: LogConfig.h:98
ELogLevel
Definition of the supported log levels.
Definition: LogConfig.h:26
void setAbortLevel(ELogLevel abortLevel)
Configure the abort level.
Definition: LogConfig.h:112
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:25
void setLogInfo(ELogLevel logLevel, unsigned int logInfo)
Configure the printed log information for the given level.
Definition: LogConfig.h:127
Class for logging debug, info and error messages.
Definition: LogSystem.h:46
void updateModule(const LogConfig *moduleLogConfig=nullptr, const std::string &moduleName="")
Sets the log configuration to the given module log configuration and sets the module name This method...
Definition: LogSystem.h:191
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
@ c_GE
Greater or equal than: ">=".
@ c_SE
Smaller or equal than: "<=".
@ c_GT
Greater than: ">"
@ c_NE
Not equal: "!=".
@ c_EQ
Equal: "=" or "=="
@ c_ST
Smaller than: "<"
EAfterConditionPath
Different options for behaviour after a conditional path was executed.
void registerModuleProxy(ModuleProxyBase *moduleProxy)
Registers a module proxy.
std::shared_ptr< Module > registerModule(const std::string &moduleName, std::string sharedLibPath="") noexcept(false)
Creates an instance of a module and registers it to the ModuleManager.
static ModuleManager & Instance()
Exception is thrown if the requested module could not be created by the ModuleManager.
std::shared_ptr< boost::python::list > getParamInfoListPython() const
Returns a python list of all parameters.
std::vector< std::string > getUnsetForcedParams() const
Returns list of unset parameters (if they are required to have a value.
ModuleProxyBase(std::string moduleType, std::string package)
The constructor of the ModuleProxyBase class.
Definition: Module.cc:497
Base class for Modules.
Definition: Module.h:72
void setLogLevel(int logLevel)
Configure the log level.
Definition: Module.cc:55
std::shared_ptr< boost::python::list > getParamInfoListPython() const
Returns a python list of all parameters.
Definition: Module.cc:279
LogConfig & getLogConfig()
Returns the log system configuration.
Definition: Module.h:225
void if_value(const std::string &expression, const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
Add a condition to the module.
Definition: Module.cc:79
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
const ModuleParamList & getParamList() const
Return module param list.
Definition: Module.h:363
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
const std::string & getName() const
Returns the name of the module.
Definition: Module.h:187
void if_true(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to set the condition of the module.
Definition: Module.cc:90
virtual void def_endRun()
This method can receive that the current run ends as a call from the Python side.
Definition: Module.h:439
std::vector< std::shared_ptr< Path > > getAllConditionPaths() const
Return all condition paths currently set (no matter if the condition is true or not).
Definition: Module.cc:150
int m_returnValue
The return value.
Definition: Module.h:519
Module()
Constructor.
Definition: Module.cc:30
const std::string & getType() const
Returns the type of the module (i.e.
Definition: Module.cc:41
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220
@ c_HistogramManager
This module is used to manage histograms accumulated by other modules.
Definition: Module.h:81
@ c_Input
This module is an input module (reads data).
Definition: Module.h:78
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
@ c_InternalSerializer
This module is an internal serializer/deserializer for parallel processing.
Definition: Module.h:82
@ c_Output
This module is an output module (writes data).
Definition: Module.h:79
@ c_TerminateInAllProcesses
When using parallel processing, call this module's terminate() function in all processes().
Definition: Module.h:83
void setLogConfig(const LogConfig &logConfig)
Set the log system configuration.
Definition: Module.h:230
const std::string & getDescription() const
Returns the description of the module.
Definition: Module.h:202
void setAbortLevel(int abortLevel)
Configure the abort log level.
Definition: Module.cc:67
virtual void def_terminate()
Wrapper method for the virtual function terminate() that has the implementation to be used in a call ...
Definition: Module.h:445
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition: Module.cc:61
void setParamPython(const std::string &name, const boost::python::object &pyObj)
Implements a method for setting boost::python objects.
Definition: Module.cc:234
virtual void def_initialize()
Wrappers to make the methods without "def_" prefix callable from Python.
Definition: Module.h:420
unsigned int m_propertyFlags
The properties of the module as bitwise or (with |) of EModulePropFlags.
Definition: Module.h:512
void if_false(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to add a condition to the module.
Definition: Module.cc:85
ModuleParamList m_moduleParamList
List storing and managing all parameter of the module.
Definition: Module.h:516
bool hasCondition() const
Returns true if at least one condition was set for the module.
Definition: Module.h:311
std::shared_ptr< Path > getConditionPath() const
Returns the path of the last true condition (if there is at least one, else reaturn a null pointer).
Definition: Module.cc:113
std::string m_type
The type of the module, saved as a string.
Definition: Module.h:509
bool m_hasReturnValue
True, if the return value is set.
Definition: Module.h:518
virtual void def_beginRun()
Wrapper method for the virtual function beginRun() that has the implementation to be used in a call f...
Definition: Module.h:426
const std::string & getPackage() const
Returns the package this module is in.
Definition: Module.h:197
void setName(const std::string &name)
Set the name of the module.
Definition: Module.h:214
void setType(const std::string &type)
Set the module type.
Definition: Module.cc:48
static void exposePythonAPI()
Exposes methods of the Module class to Python.
Definition: Module.cc:325
LogConfig m_logConfig
The log system configuration of the module.
Definition: Module.h:514
Module::EAfterConditionPath getAfterConditionPath() const
What to do after the conditional path is finished.
Definition: Module.cc:133
std::vector< ModuleCondition > m_conditions
Module condition, only non-null if set.
Definition: Module.h:521
std::shared_ptr< PathElement > clone() const override
Create an independent copy of this module.
Definition: Module.cc:179
bool hasProperties(unsigned int propertyFlags) const
Returns true if all specified property flags are available in this module.
Definition: Module.cc:160
std::string m_description
The description of the module.
Definition: Module.h:511
virtual void def_event()
Wrapper method for the virtual function event() that has the implementation to be used in a call from...
Definition: Module.h:432
std::string m_name
The name of the module, saved as a string (user-modifiable)
Definition: Module.h:508
bool evalCondition() const
If at least one condition was set, it is evaluated and true returned if at least one condition return...
Definition: Module.cc:96
void setParamPythonDict(const boost::python::dict &dictionary)
Implements a method for reading the parameter values from a boost::python dictionary.
Definition: Module.cc:249
std::string m_package
Package this module is found in (may be empty).
Definition: Module.h:510
void setLogInfo(int logLevel, unsigned int logInfo)
Configure the printed log information for the given level.
Definition: Module.cc:73
bool hasUnsetForcedParams() const
Returns true and prints error message if the module has unset parameters which the user has to set in...
Definition: Module.cc:166
std::string getPathString() const override
return the module name.
Definition: Module.cc:192
std::shared_ptr< Path > PathPtr
Defines a pointer to a path object as a boost shared pointer.
Definition: Path.h:35
void setParamPython(const std::string &name, const PythonObject &pyObj)
Implements a method for setting boost::python objects.
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition: Module.h:43
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24
STL namespace.