|
ATLAS Offline Software
|
Go to the documentation of this file.
18 #include "boost/algorithm/string/trim.hpp"
19 #include "boost/algorithm/string/split.hpp"
37 const std::string& the_docstring,
38 const std::vector<std::string>& the_labels,
39 const std::vector<std::string>& the_label_classes,
40 const std::string& the_defstring,
43 docstring (the_docstring),
44 has_default (the_has_default),
49 std::string firstName;
52 assert (the_labels.size() == the_label_classes.size());
53 for (
size_t i = 0;
i < the_labels.size();
i++) {
55 if (auxid != SG::null_auxid) {
56 accessors.emplace_back (the_labels[
i], the_label_classes[
i]);
58 std::string
name = the_label_classes[
i] +
"::" + the_labels[
i];
72 std::string errstr =
"Inconsistent types for aux data: " +
73 firstName +
" (" + reg.
getTypeName (firstId) +
") vs " +
75 throw std::runtime_error (errstr);
81 if (the_has_default && !the_defstring.empty()) {
111 const std::string&
name,
116 "Prefix to add to aux data names.");
119 "Specify variables to fill. "
120 "Each is of the form VAR[=AUXVAR][<DEF][#DOCSTRING].\n"
121 "VAR is the D3PD variable name. "
122 "AUXVAR is the aux data item name. It may contain a class "
123 "name before a ::. If omitted, it defaults to VAR. "
124 "It may also be a comma-separated string of variable "
125 "names; the first one found to be present will be used. "
126 "If the < is present, then it is not an error for this "
127 "variable to be missing. If not empty, DEF specifies the "
128 "default value to use (works only for basic types). "
129 "DEF may be preceded with a type name: `TYPE: DEF' to "
130 "specify a type in the case the type of this aux variable "
132 "An optional documentation string may be given after a #.");
152 std::string docstring =
"[AuxData: ";
153 docstring +=
v->label;
155 docstring +=
v->docstring;
158 return StatusCode::SUCCESS;
173 const void* aux =
v->access(
p);
175 v->type.assign (
v->ptr, aux);
176 else if (!
v->has_default) {
182 return StatusCode::SUCCESS;
192 std::string docstring;
193 std::string::size_type ipos =
name.find (
'#');
194 if (ipos != std::string::npos) {
195 docstring =
name.substr (ipos+1, std::string::npos);
199 std::string defstring;
200 bool has_default =
false;
201 ipos =
name.find (
'<');
202 if (ipos != std::string::npos) {
203 defstring =
name.substr (ipos+1, std::string::npos);
204 name.erase (ipos, std::string::npos);
209 ipos =
name.find (
'=');
210 if (ipos != std::string::npos) {
211 name.erase (ipos, std::string::npos);
212 label.erase (0, ipos+1);
215 std::vector<std::string>
labels;
217 std::vector<std::string> label_classes;
218 for (std::string&
l :
labels) {
219 std::string label_class;
220 ipos =
l.find (
"::");
221 if (ipos != std::string::npos) {
222 label_class =
l.substr (0, ipos);
228 label_classes.push_back (label_class);
237 if (!defstring.empty()) {
238 ipos = defstring.find (
':');
239 if (ipos != std::string::npos) {
240 std::string typname = defstring.substr (0, ipos);
242 defstring.erase (0, ipos+1);
248 for (
size_t i = 0;
i <
labels.size();
i++)
255 m_vars.push_back (std::make_unique<Var>
257 defstring, has_default));
259 catch (
const std::runtime_error&
e) {
261 <<
"Can't find aux data item(s) " <<
label
262 <<
" [" <<
e.what() <<
"]";
263 return StatusCode::FAILURE;
266 if (
m_vars.back()->accessors.empty()) {
268 <<
"Can't find aux data item(s) " <<
label;
269 return StatusCode::FAILURE;
272 return StatusCode::SUCCESS;
void init(const std::string &typname)
Initialize from a type name.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
SG::auxid_t findAuxID(const std::string &name, const std::string &clsname="") const
Look up a name -> auxid_t mapping.
Base class for elements of a container that can have aux data.
const std::type_info * getTypeInfo() const
Return the type_info for the described type.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Handle mappings between names and auxid_t.
size_t auxid_t
Identifier for a particular aux data item.
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
Block filler tool for noisy FEB information.
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
::StatusCode StatusCode
StatusCode definition for legacy code.
#define CHECK(...)
Evaluate an expression and check for errors.
void fromString(void *p, const std::string &s) const
Initialize an object from a string.
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
std::unique_ptr< void, Deleter > unique_ptr
A std::unique_ptr type referencing a generic pointer.
Handle mappings between names and auxid_t.
void trim(std::string &input)
void * create() const
Create an instance of the object.
Base class for elements of a container that can have aux data.
SG::auxid_t getAuxID(const std::string &name, const std::string &clsname="", const Flags flags=Flags::None, const SG::auxid_t linkedVariable=SG::null_auxid)
Look up a name -> auxid_t mapping.