ATLAS Offline Software
Loading...
Searching...
No Matches
D3PD::AddVariable Class Reference

Common implementation of IAddVariable. More...

#include <AddVariable.h>

Inheritance diagram for D3PD::AddVariable:
Collaboration diagram for D3PD::AddVariable:

Public Member Functions

 AddVariable (const std::string &prefix, const std::string &blockName=s_emptyString)
 Constructor.
 AddVariable (const std::string &prefix, const std::string &blockName, const std::string &suffix)
 Constructor.
StatusCode configureD3PD (IAddVariable *tree)
 Configure the parent tree.
virtual StatusCode addVariable (const std::string &name, const std::type_info &ti, void *&ptr, std::string_view docstring="", const void *defval=0)
 Add a variable to the tuple.
virtual StatusCode addDimensionedVariable (const std::string &name, const std::type_info &ti, void *&ptr, const std::string &dim, std::string_view docstring="", const void *defval=0)
 Add a variable to the tuple.
template<class T>
StatusCode addVariable (const std::string &name, T *&ptr, std::string_view docstring="")
 Make the template implementation from IAddVariable visible.
template<class T, class U>
StatusCode addVariable (const std::string &name, T *&ptr, std::string_view docstring, const U &defval)
 Make the template implementation from IAddVariable visible.
template<class T>
StatusCode addDimensionedVariable (const std::string &name, T *&ptr, const std::string &dim, std::string_view docstring="")
 Add a variable to the tuple.
template<class T, class U>
StatusCode addDimensionedVariable (const std::string &name, T *&ptr, const std::string &dim, std::string_view docstring, const U &defval)
 Add a variable to the tuple.

Protected Attributes

ObjectMetadata m_metadata
 Metadata about the variables created by this object.

Private Attributes

const std::string & m_prefix
 Reference to the variable prefix.
const std::string & m_suffix
 Reference to the variable suffix.
IAddVariable * m_tree
 The parent IAddVariable instance.

Static Private Attributes

static const std::string s_emptyString
 Used to provide a default value for blockName.

Detailed Description

Common implementation of IAddVariable.

This implements the IAddVariable interface for the common case where we just need to add a prefix/suffix to the variable name and forward to another IAddVariable.

References to the prefix/suffix and block name are passed to the constructor (these will typically be tool properties) and the parent IAddVariable is passed to configureD3PD.

Definition at line 36 of file AddVariable.h.

Constructor & Destructor Documentation

◆ AddVariable() [1/2]

D3PD::AddVariable::AddVariable ( const std::string & prefix,
const std::string & blockName = s_emptyString )

Constructor.

Parameters
prefixReference to the variable prefix.
blockNameReference to the block name for this tool.

Definition at line 29 of file AddVariable.cxx.

31 : m_metadata (),
32 m_prefix (prefix),
34 m_tree (0)
35{
36}
static const std::string s_emptyString
Used to provide a default value for blockName.
Definition AddVariable.h:41
ObjectMetadata m_metadata
Metadata about the variables created by this object.
const std::string & m_prefix
Reference to the variable prefix.
const std::string & m_suffix
Reference to the variable suffix.
IAddVariable * m_tree
The parent IAddVariable instance.

◆ AddVariable() [2/2]

D3PD::AddVariable::AddVariable ( const std::string & prefix,
const std::string & blockName,
const std::string & suffix )

Constructor.

Parameters
prefixReference to the variable prefix.
blockNameReference to the block name for this tool.
suffixReference to the variable suffix.
prefixReference to the variable prefix.
blockNameReference to the block name for this tool.

Definition at line 44 of file AddVariable.cxx.

47 : m_metadata (),
48 m_prefix (prefix),
49 m_suffix (suffix),
50 //m_blockName (blockName),
51 m_tree (0)
52{
53}

Member Function Documentation

◆ addDimensionedVariable() [1/3]

StatusCode D3PD::AddVariable::addDimensionedVariable ( const std::string & name,
const std::type_info & ti,
void *& ptr,
const std::string & dim,
std::string_view docstring = "",
const void * defval = 0 )
virtual

Add a variable to the tuple.

Parameters
nameThe name of the variable.
typeThe type of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.
defvalPointer to the default value to use for this variable. Null for no default (generally means to fill with zeros). Of the type given by ti. Only works for basic types.

If called from the constructor, the only effect is to clear ptr.

Implements D3PD::IAddVariable.

Definition at line 122 of file AddVariable.cxx.

128{
129 if (!m_tree) {
130 // Called from constructor --- just initialize pointer.
131 ptr = 0;
132 return StatusCode::SUCCESS;
133 }
134
135 CHECK( m_metadata.addDimensionedVariable( m_prefix + name + m_suffix,
136 ti, ptr, dim,
137 docstring, defval ) );
138 return m_tree->addDimensionedVariable (m_prefix + name + m_suffix,
139 ti, ptr, dim,
140 docstring, defval);
141}
#define CHECK(...)
Evaluate an expression and check for errors.
void * ptr(T *p)
Definition SGImplSvc.cxx:76

◆ addDimensionedVariable() [2/3]

template<class T, class U>
StatusCode D3PD::IAddVariable::addDimensionedVariable ( const std::string & name,
T *& ptr,
const std::string & dim,
std::string_view docstring,
const U & defval )

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.
defvalPointer to the default value to use for this variable. Only works for basic types.

If called from the constructor, the only effect is to clear ptr.

◆ addDimensionedVariable() [3/3]

template<class T>
StatusCode D3PD::IAddVariable::addDimensionedVariable ( const std::string & name,
T *& ptr,
const std::string & dim,
std::string_view docstring = "" )

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.

If called from the constructor, the only effect is to clear ptr.

◆ addVariable() [1/3]

StatusCode D3PD::AddVariable::addVariable ( const std::string & name,
const std::type_info & ti,
void *& ptr,
std::string_view docstring = "",
const void * defval = 0 )
virtual

Add a variable to the tuple.

Parameters
nameThe name of the variable.
typeThe type of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
docstringDocumentation string for this variable.
defvalPointer to the default value to use for this variable. Null for no default (generally means to fill with zeros). Of the type given by ti. Only works for basic types.

If called from the constructor, the only effect is to clear ptr.

Implements D3PD::IAddVariable.

Definition at line 84 of file AddVariable.cxx.

89{
90 if (!m_tree) {
91 // Called from constructor --- just initialize pointer.
92 ptr = 0;
93 return StatusCode::SUCCESS;
94 }
95
96 CHECK( m_metadata.addVariable( m_prefix + name + m_suffix,
97 ti, ptr, docstring, defval ) );
98 return m_tree->addVariable (m_prefix + name + m_suffix,
99 ti, ptr, docstring, defval);
100}

◆ addVariable() [2/3]

template<class T, class U>
StatusCode D3PD::IAddVariable::addVariable ( const std::string & name,
T *& ptr,
std::string_view docstring,
const U & defval )

Make the template implementation from IAddVariable visible.

◆ addVariable() [3/3]

template<class T>
StatusCode D3PD::IAddVariable::addVariable ( const std::string & name,
T *& ptr,
std::string_view docstring = "" )

Make the template implementation from IAddVariable visible.

◆ configureD3PD()

StatusCode D3PD::AddVariable::configureD3PD ( IAddVariable * tree)

Configure the parent tree.

Parameters
treeThe parent IAddVariable instance.

Definition at line 60 of file AddVariable.cxx.

61{
62 m_tree = tree;
63 m_metadata.clear();
64 return StatusCode::SUCCESS;
65}
TChain * tree

Member Data Documentation

◆ m_metadata

ObjectMetadata D3PD::AddVariable::m_metadata
protected

Metadata about the variables created by this object.

Definition at line 129 of file AddVariable.h.

◆ m_prefix

const std::string& D3PD::AddVariable::m_prefix
private

Reference to the variable prefix.

Definition at line 134 of file AddVariable.h.

◆ m_suffix

const std::string& D3PD::AddVariable::m_suffix
private

Reference to the variable suffix.

Definition at line 137 of file AddVariable.h.

◆ m_tree

IAddVariable* D3PD::AddVariable::m_tree
private

The parent IAddVariable instance.

Definition at line 141 of file AddVariable.h.

◆ s_emptyString

const std::string D3PD::AddVariable::s_emptyString
staticprivate

Used to provide a default value for blockName.

Definition at line 41 of file AddVariable.h.


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