1 #ifndef MHO_OperatorBuilderManager_HH__
2 #define MHO_OperatorBuilderManager_HH__
29 : fOperatorToolbox(toolbox), fFringeData(fdata), fContainerStore(fdata->GetContainerStore()),
30 fParameterStore(fdata->GetParameterStore())
32 fFormat = control_format;
57 std::string scat(cat);
82 template<
typename XBuilderType >
void AddBuilderType(
const std::string& builder_name,
const std::string& format_key)
84 auto format_it = fFormat.find(format_key);
85 if(format_it != fFormat.end())
87 auto it = fNameToBuilderMap.find(builder_name);
88 if(it == fNameToBuilderMap.end())
90 std::unique_ptr< XBuilderType > builder(
new XBuilderType(fOperatorToolbox, fFringeData));
91 builder->SetFormat(fFormat[format_key]);
94 std::string category =
"unknown";
95 if(format_it->contains(
"operator_category"))
97 category = (*format_it)[
"operator_category"].get< std::string >();
99 auto* raw = builder.get();
100 fAllBuilders.push_back(std::move(builder));
101 fNameToBuilderMap.emplace(builder_name, raw);
102 fCategoryToBuilderMap.emplace(category, raw);
107 msg_error(
"initialization",
"cannot add builder for operator with format key: " << format_key << eom);
115 void CreateNullFormatBuilders();
124 template<
typename XBuilderType >
void AddBuilderTypeWithFormat(
const std::string& builder_name,
const mho_json& format)
126 auto it = fNameToBuilderMap.find(builder_name);
127 if(it == fNameToBuilderMap.end())
129 std::unique_ptr< XBuilderType > builder(
new XBuilderType(fOperatorToolbox, fFringeData));
130 builder->SetFormat(format);
133 std::string category =
"unknown";
134 if(format.contains(
"operator_category"))
136 category = format[
"operator_category"].get< std::string >();
138 auto* raw = builder.get();
139 fAllBuilders.push_back(std::move(builder));
140 fNameToBuilderMap.emplace(builder_name, raw);
141 fCategoryToBuilderMap.emplace(category, raw);
150 MHO_OperatorToolbox* fOperatorToolbox;
153 MHO_FringeData* fFringeData;
154 MHO_ContainerStore* fContainerStore;
155 MHO_ParameterStore* fParameterStore;
158 std::vector< std::unique_ptr< MHO_OperatorBuilder > > fAllBuilders;
161 std::map< std::string, MHO_OperatorBuilder* > fNameToBuilderMap;
164 std::multimap< std::string, MHO_OperatorBuilder* > fCategoryToBuilderMap;
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:238
Class MHO_FringeData.
Definition: MHO_FringeData.hh:30
Manages all the various operator builders.
Definition: MHO_OperatorBuilderManager.hh:26
void BuildOperatorCategory(const char *cat)
Builds operator category from input string and calls BuildOperatorCategory with it.
Definition: MHO_OperatorBuilderManager.hh:55
void CreateDefaultBuilders()
Registers default operator builders for various purposes such as channel labeling,...
Definition: MHO_OperatorBuilderManager.cc:45
void AddBuilderType(const std::string &builder_name, const std::string &format_key)
Adds a new builder type with specified format, inserted into (builder) map for later use.
Definition: MHO_OperatorBuilderManager.hh:82
virtual ~MHO_OperatorBuilderManager()
Definition: MHO_OperatorBuilderManager.hh:35
MHO_OperatorBuilderManager(MHO_OperatorToolbox *toolbox, MHO_FringeData *fdata, mho_json control_format)
Definition: MHO_OperatorBuilderManager.hh:28
void SetControlStatements(mho_json *statements)
pass in parsed control file elements
Definition: MHO_OperatorBuilderManager.hh:42
std::size_t GetNBuildersInCategory(std::string cat)
return the number of operator builders in the specified category
Definition: MHO_OperatorBuilderManager.cc:32
Definition: MHO_AdhocFlagging.hh:18