19 #include <ModuleUtils.h> 21 #include <momemta/Logging.h> 23 #include <ModuleDefUtils.h> 29 typedef typename std::remove_cv<T>::type
type;
31 T* pset = ¶meters;
33 while (!nested_attributes.empty()) {
35 nested_attributes.erase(nested_attributes.begin());
37 if (pset->template existsAs<type>(nested_attribute.name))
38 pset = &pset->template get<type>(nested_attribute.name);
49 bool momemta::validateModuleParameters(
const ModuleList::value_type& module_def,
const ParameterSet& parameters) {
51 std::vector<std::string> errors;
52 std::vector<std::string> warnings;
56 for (
const auto& attr_def: module_def.attributes) {
59 if (attr_def.global || attr_def.optional)
62 if (! parameters.exists(attr_def.name))
63 errors.emplace_back(
"Attribute not found: " + attr_def.name);
67 for (
const auto& input_def: module_def.inputs) {
74 while (!nested_attributes.empty()) {
75 AttrDef nested_attribute = nested_attributes.front();
76 nested_attributes.erase(nested_attributes.begin());
81 LOG(error) <<
"Attribute " << nested_attribute.name <<
" not found in PSet " 82 << pset->getModuleType() <<
"::" << pset->getModuleName();
88 if (!pset || !pset->exists(input_def.name))
89 errors.emplace_back(
"Input not found: " + input_def.name);
93 const auto& parameter_names = parameters.getNames();
94 for (
const auto& name: parameter_names) {
97 if (name.length() > 0 && name[0] ==
'@')
100 if (! momemta::inputOrAttrExists(name, module_def))
101 warnings.emplace_back(
"Unexpected parameter: " + name);
104 if (! warnings.empty()) {
106 LOG(warning) <<
"Warnings found during validation of parameters for module " 107 << parameters.getModuleType() <<
"::" << parameters.getModuleName();
108 for (
const auto& warning: warnings)
109 LOG(warning) <<
" " << warning;
110 LOG(warning) <<
"These parameters will never be used by the module, check your configuration file.";
113 if (!errors.empty()) {
115 LOG(error) <<
"Validation of parameters for module " << parameters.getModuleType() <<
"::" 116 << parameters.getModuleName() <<
" failed: ";
117 for (
const auto& error: errors)
118 LOG(error) <<
" " << error;
120 LOG(error) <<
"Check your configuration file.";
123 return errors.empty();
130 assert(pset || input.optional);
135 if (input.optional && !pset->exists(input.name))
139 return pset->get<std::vector<InputTag>>(input.name);
141 return gtl::make_optional<std::vector<InputTag>>({pset->get<
InputTag>(input.name)});
145 void momemta::setInputTagsForInput(
const ArgDef& input,
147 const std::vector<InputTag>& inputTags) {
153 pset->raw_set(input.name, inputTags);
155 assert(inputTags.size() == 1);
156 pset->raw_set(input.name, inputTags.front());
Type type(lua_State *L, int index)
Extract the type of a lua value.
bool optional
Only meaningful for inputs.
Defines an input / output.
A class encapsulating a lua table.
std::vector< AttrDef > nested_attributes