1 #ifndef MHO_PythonOperatorBuilder_HH__
2 #define MHO_PythonOperatorBuilder_HH__
44 std::string op_name = this->
fFormat[
"name"].get< std::string >();
45 std::string op_category = this->
fFormat[
"operator_category"].get< std::string >();
46 std::string module_path =
fAttributes[
"value"][
"module_path"].get< std::string >();
47 std::string function_name =
fAttributes[
"value"][
"function_name"].get< std::string >();
48 double priority = this->
fFormat[
"priority"].get<
double >();
49 if(
fAttributes[
"value"].contains(
"override_priority"))
51 double override_priority =
fAttributes[
"value"][
"override_priority"].get<
double >();
52 msg_debug(
"initialization",
"python operator: " << op_name <<
" priority overridden from " << priority
53 <<
" to " << override_priority << eom);
54 priority = override_priority;
57 op->SetPriority(priority);
58 std::string full_name = module_path +
":" + function_name;
59 op->SetName(full_name);
60 op->SetModulePath(module_path);
61 op->SetFunctionName(function_name);
64 bool replace_duplicates =
false;
70 msg_error(
"initialization",
"cannot build python operator." << eom);
77 TODO_FIXME_MSG(
"TODO FIXME -- improve checks on operator attributes in IsConfigurationOk)")
80 if(
fFormat[
"statement_type"] ==
"operator")
82 if(
fFormat.contains(
"type") &&
fFormat[
"type"].get< std::string >() ==
"compound")
84 for(
auto it =
fFormat[
"fields"].begin(); it !=
fFormat[
"fields"].end(); it++)
93 bool is_required =
true;
94 std::string field_name = (*it).get< std::string >();
96 if(!field_name.empty() && field_name[0] ==
'!')
100 if(!
fAttributes[
"value"].contains(*it) && is_required)
102 msg_error(
"initialization",
"missing attribute called " << *it <<
" in parameters of operator: "
103 <<
fFormat[
"name"].get< std::string >()
104 <<
", will not build " << eom);
#define msg_debug(xKEY, xCONTENT)
Definition: MHO_Message.hh:291
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:238
#define TODO_FIXME_MSG(x)
Definition: MHO_Message.hh:35
Class MHO_ContainerStore.
Definition: MHO_ContainerStore.hh:32
Class MHO_FringeData.
Definition: MHO_FringeData.hh:30
Abtract base class for a builder object (creates an operator for later use)
Definition: MHO_OperatorBuilder.hh:28
MHO_OperatorToolbox * fOperatorToolbox
Definition: MHO_OperatorBuilder.hh:135
mho_json fFormat
Definition: MHO_OperatorBuilder.hh:223
MHO_FringeData * fFringeData
Definition: MHO_OperatorBuilder.hh:138
mho_json fAttributes
Definition: MHO_OperatorBuilder.hh:225
Class MHO_ParameterStore.
Definition: MHO_ParameterStore.hh:52
this class allows a user to inject a python function of the form: func(fringe_data_interface) into th...
Definition: MHO_PyGenericOperator.hh:35
Definition: MHO_PythonOperatorBuilder.hh:21
virtual ~MHO_PythonOperatorBuilder()
Definition: MHO_PythonOperatorBuilder.hh:29
virtual bool IsConfigurationOk() override
Function IsConfigurationOk provided for derived class to validate fAttributes against fFormat and/or ...
Definition: MHO_PythonOperatorBuilder.hh:75
virtual bool Build() override
Builds the object and passes it to toolbox if successful, otherwise returns false.
Definition: MHO_PythonOperatorBuilder.hh:31
MHO_PythonOperatorBuilder(MHO_OperatorToolbox *toolbox, MHO_FringeData *fdata)
Definition: MHO_PythonOperatorBuilder.hh:23
MHO_PythonOperatorBuilder(MHO_OperatorToolbox *toolbox, MHO_ContainerStore *cstore=nullptr, MHO_ParameterStore *pstore=nullptr)
Definition: MHO_PythonOperatorBuilder.hh:25
Definition: MHO_AdhocFlagging.hh:18