HOPS
HOPS class reference
MHO_PythonOperatorBuilder.hh
Go to the documentation of this file.
1 #ifndef MHO_PythonOperatorBuilderBuilder_HH__
2 #define MHO_PythonOperatorBuilderBuilder_HH__
3 
4 #include "MHO_OperatorBuilder.hh"
6 
7 namespace hops
8 {
9 
19 {
20  public:
22  : MHO_OperatorBuilder(toolbox, fdata){};
23 
25  MHO_ParameterStore* pstore = nullptr)
26  : MHO_OperatorBuilder(toolbox, cstore, pstore){};
27 
29 
30  virtual bool Build() override
31  {
32  if(IsConfigurationOk())
33  {
35 
36  //pass the data container and parameter stores to the python operator
37  // op->SetParameterStore(this->fParameterStore);
38  // op->SetContainerStore(this->fContainerStore);
39  op->SetFringeData(this->fFringeData);
40 
41  //retrieve pass the module/function name info from the control file
42  std::string op_name = this->fFormat["name"].get< std::string >();
43  std::string op_category = this->fFormat["operator_category"].get< std::string >();
44  std::string module_name = fAttributes["value"]["module_name"].get< std::string >();
45  std::string function_name = fAttributes["value"]["function_name"].get< std::string >();
46  double priority = this->fFormat["priority"].get< double >();
47 
48  op->SetPriority(priority);
49  op->SetName(module_name + ":" + function_name);
50  op->SetModuleName(module_name);
51  op->SetFunctionName(function_name);
52 
53  //TODO handle naming scheme for multiple python operators (should they have a name parameter?)
54  bool replace_duplicates = false;
55  this->fOperatorToolbox->AddOperator(op, op->GetName(), op_category, replace_duplicates);
56  return true;
57  }
58  else
59  {
60  msg_error("initialization", "cannot build python operator." << eom);
61  return false;
62  }
63  }
64 
65  private:
66 };
67 
68 } // namespace hops
69 
70 #endif
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:244
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:27
MHO_OperatorToolbox * fOperatorToolbox
Definition: MHO_OperatorBuilder.hh:150
virtual bool IsConfigurationOk()
Function IsConfigurationOk provided for derived class to validate fAttributes against fFormat and/or ...
Definition: MHO_OperatorBuilder.hh:123
mho_json fFormat
Definition: MHO_OperatorBuilder.hh:160
MHO_FringeData * fFringeData
Definition: MHO_OperatorBuilder.hh:153
mho_json fAttributes
Definition: MHO_OperatorBuilder.hh:162
Class MHO_OperatorToolbox.
Definition: MHO_OperatorToolbox.hh:26
void AddOperator(MHO_Operator *op, const std::string &name, const std::string &category, bool replace_duplicate=true)
Adds an operator to the toolbox with optional replacement if duplicate name exists.
Definition: MHO_OperatorToolbox.hh:41
void SetName(std::string name)
Setter for operator name.
Definition: MHO_Operator.hh:46
virtual void SetPriority(const double &priority)
Setter for operator priority (determines order of execution within a operator category)
Definition: MHO_Operator.hh:64
std::string GetName() const
Getter for operator name.
Definition: MHO_Operator.hh:53
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:34
void SetFunctionName(std::string function_name)
Definition: MHO_PyGenericOperator.hh:58
void SetModuleName(std::string module_name)
Definition: MHO_PyGenericOperator.hh:56
void SetFringeData(MHO_FringeData *fdata)
Definition: MHO_PyGenericOperator.hh:50
Definition: MHO_PythonOperatorBuilder.hh:19
virtual ~MHO_PythonOperatorBuilder()
Definition: MHO_PythonOperatorBuilder.hh:28
virtual bool Build() override
Builds the object and passes it to toolbox if successful, otherwise returns false.
Definition: MHO_PythonOperatorBuilder.hh:30
MHO_PythonOperatorBuilder(MHO_OperatorToolbox *toolbox, MHO_FringeData *fdata)
Definition: MHO_PythonOperatorBuilder.hh:21
MHO_PythonOperatorBuilder(MHO_OperatorToolbox *toolbox, MHO_ContainerStore *cstore=nullptr, MHO_ParameterStore *pstore=nullptr)
Definition: MHO_PythonOperatorBuilder.hh:24
Definition: MHO_ChannelLabeler.hh:17