ATLAS Offline Software
Loading...
Searching...
No Matches
D3PD::AuxDataFillerTool::Var Struct Reference

Describe one variable. More...

Collaboration diagram for D3PD::AuxDataFillerTool::Var:

Public Member Functions

 Var (const std::string &the_name, const std::string &the_docstring, const std::vector< std::string > &the_labels, const std::vector< std::string > &the_label_classes, const std::string &the_defstring, bool the_has_default)
 Constructor.
const void * access (const SG::AuxElement &p) const
 Try to retrieve an aux data item from p.

Public Attributes

std::string name
 Name of the variable.
std::string docstring
 Docstring for the variable.
RootUtils::Type::unique_ptr defobj
 If present, a default object instance to use if the aux variable is not present.
bool has_default
 If true, this aux variable can be defaulted.
RootUtils::Type type
 Type of the item.
const std::type_info * ti
 Type of the variable, as type_info.
std::vector< SG::AuxElement::TypelessConstAccessoraccessors
 Aux data accessor(s) for the item.
void * ptr
 Pointer passed to ID3PD.
std::string label
 Name of the aux data item(s).

Detailed Description

Describe one variable.

Definition at line 80 of file AuxDataFillerTool.h.

Constructor & Destructor Documentation

◆ Var()

D3PD::AuxDataFillerTool::Var::Var ( const std::string & the_name,
const std::string & the_docstring,
const std::vector< std::string > & the_labels,
const std::vector< std::string > & the_label_classes,
const std::string & the_defstring,
bool the_has_default )

Constructor.

Parameters
the_nameName of the variable.
the_docstringDocstring for the variable.
the_labelsName of the aux data item(s).
the_label_classesClass(es) of the aux data item(s), or blank strings.
the_defstringString giving the default value.
the_has_defaultCan this variable be defaulted?

Definition at line 36 of file AuxDataFillerTool.cxx.

42 : name (the_name),
43 docstring (the_docstring),
44 has_default (the_has_default),
45 ptr (0)
46{
47 const SG::AuxTypeRegistry& reg = SG::AuxTypeRegistry::instance();
48
49 std::string firstName;
51 ti = 0;
52 assert (the_labels.size() == the_label_classes.size());
53 for (size_t i = 0; i < the_labels.size(); i++) {
54 SG::auxid_t auxid = reg.findAuxID (the_labels[i], the_label_classes[i]);
55 if (auxid != SG::null_auxid) {
56 accessors.emplace_back (the_labels[i], the_label_classes[i]);
57
58 std::string name = the_label_classes[i] + "::" + the_labels[i];
59 if (!label.empty())
60 label += ",";
61 label += name;
62
63 // Find the type of the variable.
64 if (ti == 0) {
65 ti = reg.getType (auxid);
66 type.init (reg.getTypeName (auxid));
67 firstName = std::move(name);
68 firstId = auxid;
69 }
70 else {
71 if (ti != reg.getType (auxid)) {
72 std::string errstr = "Inconsistent types for aux data: " +
73 firstName + " (" + reg.getTypeName (firstId) +") vs " +
74 name + " (" + reg.getTypeName (auxid) + ")";
75 throw std::runtime_error (errstr);
76 }
77 }
78 }
79 }
80
81 if (the_has_default && !the_defstring.empty()) {
83 type.fromString (defobj.get(), the_defstring);
84 }
85}
std::unique_ptr< void, Deleter > unique_ptr
A std::unique_ptr type referencing a generic pointer.
Definition Type.h:344
static AuxTypeRegistry & instance()
Return the singleton registry instance.
static const auxid_t null_auxid
To signal no aux data item.
Definition AuxTypes.h:30
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
const std::type_info * ti
Type of the variable, as type_info.
bool has_default
If true, this aux variable can be defaulted.
void * ptr
Pointer passed to ID3PD.
std::vector< SG::AuxElement::TypelessConstAccessor > accessors
Aux data accessor(s) for the item.
RootUtils::Type::unique_ptr defobj
If present, a default object instance to use if the aux variable is not present.
std::string label
Name of the aux data item(s).
RootUtils::Type type
Type of the item.
std::string name
Name of the variable.
std::string docstring
Docstring for the variable.

Member Function Documentation

◆ access()

const void * D3PD::AuxDataFillerTool::Var::access ( const SG::AuxElement & p) const

Try to retrieve an aux data item from p.

Parameters
pThe element to read from.

Returns 0 if no alternatives are available.

Definition at line 94 of file AuxDataFillerTool.cxx.

95{
96 for (const auto& a : accessors) {
97 if (a.isAvailable(p))
98 return a(p);
99 }
100 return 0;
101}
static Double_t a

Member Data Documentation

◆ accessors

std::vector<SG::AuxElement::TypelessConstAccessor> D3PD::AuxDataFillerTool::Var::accessors

Aux data accessor(s) for the item.

Definition at line 128 of file AuxDataFillerTool.h.

◆ defobj

RootUtils::Type::unique_ptr D3PD::AuxDataFillerTool::Var::defobj

If present, a default object instance to use if the aux variable is not present.

Definition at line 116 of file AuxDataFillerTool.h.

◆ docstring

std::string D3PD::AuxDataFillerTool::Var::docstring

Docstring for the variable.

Definition at line 112 of file AuxDataFillerTool.h.

◆ has_default

bool D3PD::AuxDataFillerTool::Var::has_default

If true, this aux variable can be defaulted.

Definition at line 119 of file AuxDataFillerTool.h.

◆ label

std::string D3PD::AuxDataFillerTool::Var::label

Name of the aux data item(s).

Definition at line 134 of file AuxDataFillerTool.h.

◆ name

std::string D3PD::AuxDataFillerTool::Var::name

Name of the variable.

Definition at line 109 of file AuxDataFillerTool.h.

◆ ptr

void* D3PD::AuxDataFillerTool::Var::ptr

Pointer passed to ID3PD.

Definition at line 131 of file AuxDataFillerTool.h.

◆ ti

const std::type_info* D3PD::AuxDataFillerTool::Var::ti

Type of the variable, as type_info.

Definition at line 125 of file AuxDataFillerTool.h.

◆ type

RootUtils::Type D3PD::AuxDataFillerTool::Var::type

Type of the item.

Definition at line 122 of file AuxDataFillerTool.h.


The documentation for this struct was generated from the following files: