ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
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. More...
 
const void * access (const SG::AuxElement &p) const
 Try to retrieve an aux data item from p. More...
 

Public Attributes

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

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 {
48 
49  std::string firstName;
50  SG::auxid_t firstId = SG::null_auxid;
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 = 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 }

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 }

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:
RootUtils::Type::init
void init(const std::string &typname)
Initialize from a type name.
Definition: Type.cxx:154
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
D3PD::AuxDataFillerTool::Var::has_default
bool has_default
If true, this aux variable can be defaulted.
Definition: AuxDataFillerTool.h:119
D3PD::AuxDataFillerTool::Var::accessors
std::vector< SG::AuxElement::TypelessConstAccessor > accessors
Aux data accessor(s) for the item.
Definition: AuxDataFillerTool.h:128
D3PD::AuxDataFillerTool::Var::label
std::string label
Name of the aux data item(s).
Definition: AuxDataFillerTool.h:134
python.DomainsRegistry.reg
reg
globals -----------------------------------------------------------------—
Definition: DomainsRegistry.py:343
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:62
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
lumiFormat.i
int i
Definition: lumiFormat.py:92
D3PD::AuxDataFillerTool::Var::name
std::string name
Name of the variable.
Definition: AuxDataFillerTool.h:109
D3PD::AuxDataFillerTool::Var::ti
const std::type_info * ti
Type of the variable, as type_info.
Definition: AuxDataFillerTool.h:125
D3PD::AuxDataFillerTool::Var::ptr
void * ptr
Pointer passed to ID3PD.
Definition: AuxDataFillerTool.h:131
D3PD::AuxDataFillerTool::Var::defobj
RootUtils::Type::unique_ptr defobj
If present, a default object instance to use if the aux variable is not present.
Definition: AuxDataFillerTool.h:116
RootUtils::Type::fromString
void fromString(void *p, const std::string &s) const
Initialize an object from a string.
Definition: Type.cxx:601
D3PD::AuxDataFillerTool::Var::docstring
std::string docstring
Docstring for the variable.
Definition: AuxDataFillerTool.h:112
RootUtils::Type::unique_ptr
std::unique_ptr< void, Deleter > unique_ptr
A std::unique_ptr type referencing a generic pointer.
Definition: Type.h:344
a
TList * a
Definition: liststreamerinfos.cxx:10
RootUtils::Type::create
void * create() const
Create an instance of the object.
Definition: Type.cxx:296
D3PD::AuxDataFillerTool::Var::type
RootUtils::Type type
Type of the item.
Definition: AuxDataFillerTool.h:122