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::TypelessConstAccessor > accessors
 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 35 of file AuxDataFillerTool.cxx.

41 : name (the_name),
42 docstring (the_docstring),
43 has_default (the_has_default),
44 ptr (0)
45{
46 const SG::AuxTypeRegistry& reg = SG::AuxTypeRegistry::instance();
47
48 std::string firstName;
50 ti = 0;
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]);
54 if (auxid != SG::null_auxid) {
55 accessors.emplace_back (the_labels[i], the_label_classes[i]);
56
57 std::string name = the_label_classes[i] + "::" + the_labels[i];
58 if (!label.empty())
59 label += ",";
60 label += name;
61
62 // Find the type of the variable.
63 if (ti == 0) {
64 ti = reg.getType (auxid);
65 type.init (reg.getTypeName (auxid));
66 firstName = std::move(name);
67 firstId = auxid;
68 }
69 else {
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);
75 }
76 }
77 }
78 }
79
80 if (the_has_default && !the_defstring.empty()) {
82 type.fromString (defobj.get(), the_defstring);
83 }
84}
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
SG::auxid_t auxid() const
Return the aux id for this variable.
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 93 of file AuxDataFillerTool.cxx.

94{
95 for (const auto& a : accessors) {
96 if (a.isAvailable(p))
97 return a(p);
98 }
99 return 0;
100}
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: