36 const std::string& the_docstring,
37 const std::vector<std::string>& the_labels,
38 const std::vector<std::string>& the_label_classes,
39 const std::string& the_defstring,
48 std::string firstName;
51 assert (the_labels.size() == the_label_classes.size());
52 for (
size_t i = 0; i < the_labels.size(); i++) {
53 SG::auxid_t auxid = reg.findAuxID (the_labels[i], the_label_classes[i]);
55 accessors.emplace_back (the_labels[i], the_label_classes[i]);
57 std::string
name = the_label_classes[i] +
"::" + the_labels[i];
64 ti = reg.getType (auxid);
65 type.init (reg.getTypeName (auxid));
66 firstName = std::move(
name);
70 if (
ti != reg.getType (auxid)) {
71 std::string errstr =
"Inconsistent types for aux data: " +
72 firstName +
" (" + reg.getTypeName (firstId) +
") vs " +
73 name +
" (" + reg.getTypeName (auxid) +
")";
74 throw std::runtime_error (errstr);
80 if (the_has_default && !the_defstring.empty()) {
110 const std::string& name,
111 const IInterface* parent)
115 "Prefix to add to aux data names.");
118 "Specify variables to fill. "
119 "Each is of the form VAR[=AUXVAR][<DEF][#DOCSTRING].\n"
120 "VAR is the D3PD variable name. "
121 "AUXVAR is the aux data item name. It may contain a class "
122 "name before a ::. If omitted, it defaults to VAR. "
123 "It may also be a comma-separated string of variable "
124 "names; the first one found to be present will be used. "
125 "If the < is present, then it is not an error for this "
126 "variable to be missing. If not empty, DEF specifies the "
127 "default value to use (works only for basic types). "
128 "DEF may be preceded with a type name: `TYPE: DEF' to "
129 "specify a type in the case the type of this aux variable "
131 "An optional documentation string may be given after a #.");
151 std::string docstring =
"[AuxData: ";
152 docstring += v->label;
154 docstring += v->docstring;
157 return StatusCode::SUCCESS;
172 const void* aux = v->access(p);
174 v->type.assign (v->ptr, aux);
175 else if (!v->has_default) {
181 return StatusCode::SUCCESS;
191 std::string docstring;
192 std::string::size_type ipos = name.find (
'#');
193 if (ipos != std::string::npos) {
194 docstring = name.substr (ipos+1, std::string::npos);
198 std::string defstring;
199 bool has_default =
false;
200 ipos = name.find (
'<');
201 if (ipos != std::string::npos) {
202 defstring = name.substr (ipos+1, std::string::npos);
203 name.erase (ipos, std::string::npos);
207 std::string
label = name;
208 ipos = name.find (
'=');
209 if (ipos != std::string::npos) {
210 name.erase (ipos, std::string::npos);
211 label.erase (0, ipos+1);
215 std::vector<std::string> label_classes;
216 for (std::string& l : labels) {
217 std::string label_class;
218 ipos = l.find (
"::");
219 if (ipos != std::string::npos) {
220 label_class = l.substr (0, ipos);
226 label_classes.push_back (std::move(label_class));
235 if (!defstring.empty()) {
236 ipos = defstring.find (
':');
237 if (ipos != std::string::npos) {
238 std::string typname = defstring.substr (0, ipos);
240 defstring.erase (0, ipos+1);
246 for (
size_t i = 0; i < labels.size(); i++){
247 auto auxid = reg.getAuxID (*ti, labels[i], label_classes[i]);
250 <<
"AuxDataFillerTool::parseVars: auxid is invalid for "<<labels[i]<<
"\n";
258 m_vars.push_back (std::make_unique<Var>
259 (name, docstring, labels, label_classes,
260 defstring, has_default));
262 catch (
const std::runtime_error& e) {
264 <<
"Can't find aux data item(s) " <<
label
265 <<
" [" << e.what() <<
"]";
266 return StatusCode::FAILURE;
269 if (
m_vars.back()->accessors.empty()) {
271 <<
"Can't find aux data item(s) " <<
label;
272 return StatusCode::FAILURE;
275 return StatusCode::SUCCESS;
Base class for elements of a container that can have aux data.
Handle mappings between names and auxid_t.
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
const std::type_info * getTypeInfo() const
Return the type_info for the described type.
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
std::string label(const std::string &format, int i)
std::string_view trimWhiteSpaces(std::string_view str) noexcept
Removes all trailing and starting whitespaces from a string.
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
Block filler tool for noisy FEB information.
static const auxid_t null_auxid
To signal no aux data item.
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
size_t auxid_t
Identifier for a particular aux data item.