ATLAS Offline Software
Loading...
Searching...
No Matches
VariableMule< T, C > Class Template Reference

#include <VariableMule.h>

Collaboration diagram for VariableMule< T, C >:

Public Member Functions

 VariableMule (const T &default_value)
template<typename OWNER>
StatusCode initialize (OWNER *parent, const std::vector< std::string > &froms, const std::string &to)
void copy (const std::vector< MatchedPair< C > > &pairs, const EventContext &cxt) const

Public Attributes

std::map< std::string, std::string > toCopy

Private Types

using RC = SG::ReadDecorHandleKeyArray<C>
using WC = SG::WriteDecorHandleKeyArray<C>

Private Attributes

RC m_fromKeys
WC m_toKeys
m_default
std::vector< SG::AuxElement::ConstAccessor< T > > m_fromAcc

Detailed Description

template<typename T, typename C>
class VariableMule< T, C >

Definition at line 23 of file VariableMule.h.

Member Typedef Documentation

◆ RC

template<typename T, typename C>
using VariableMule< T, C >::RC = SG::ReadDecorHandleKeyArray<C>
private

Definition at line 28 of file VariableMule.h.

◆ WC

template<typename T, typename C>
using VariableMule< T, C >::WC = SG::WriteDecorHandleKeyArray<C>
private

Definition at line 29 of file VariableMule.h.

Constructor & Destructor Documentation

◆ VariableMule()

template<typename T, typename C>
VariableMule< T, C >::VariableMule ( const T & default_value)
inline

Definition at line 35 of file VariableMule.h.

Member Function Documentation

◆ copy()

template<typename T, typename C>
void VariableMule< T, C >::copy ( const std::vector< MatchedPair< C > > & pairs,
const EventContext & cxt ) const
inline

Definition at line 61 of file VariableMule.h.

62 {
65 for (const auto& k: m_fromKeys) {
66 from.emplace_back(k, cxt);
67 }
68 for (const auto& k: m_toKeys) {
69 to.emplace_back(k, cxt);
70 }
71 size_t n_keys = m_fromAcc.size();
72 for (const auto& pair: pairs) {
73 for (size_t iii = 0; iii < n_keys; iii++) {
74 if (pair.from) {
75 to.at(iii)(*pair.to) = m_fromAcc.at(iii)(*pair.from);
76 } else {
77 to.at(iii)(*pair.to) = m_default;
78 }
79 }
80 }
81 }
std::vector< SG::AuxElement::ConstAccessor< T > > m_fromAcc

◆ initialize()

template<typename T, typename C>
template<typename OWNER>
StatusCode VariableMule< T, C >::initialize ( OWNER * parent,
const std::vector< std::string > & froms,
const std::string & to )
inline

Definition at line 40 of file VariableMule.h.

42 {
43 // the owner keeps pointers to the keys, so the storage must not move
44 m_fromKeys.reserve(toCopy.size() * froms.size());
45 m_toKeys.reserve(toCopy.size());
46 m_fromAcc.reserve(toCopy.size());
47 for (const auto& key: toCopy) {
48 std::string fullto = to + "." + key.second;
49 std::string doc = "Key to move " + key.first + "->" + key.second;
50 for (const auto& from: froms) {
51 std::string fullfrom = from + "." + key.first;
52 m_fromKeys.emplace_back(parent, "read_" + key.first, fullfrom, doc);
53 }
54 m_fromAcc.emplace_back(key.first);
55 m_toKeys.emplace_back(parent, "write_" + key.second, fullto, doc);
56 }
57 ATH_CHECK(m_fromKeys.initialize());
58 ATH_CHECK(m_toKeys.initialize());
60 }
#define ATH_CHECK
Evaluate an expression and check for errors.
std::map< std::string, std::string > toCopy

Member Data Documentation

◆ m_default

template<typename T, typename C>
T VariableMule< T, C >::m_default
private

Definition at line 32 of file VariableMule.h.

◆ m_fromAcc

template<typename T, typename C>
std::vector<SG::AuxElement::ConstAccessor<T> > VariableMule< T, C >::m_fromAcc
private

Definition at line 33 of file VariableMule.h.

◆ m_fromKeys

template<typename T, typename C>
RC VariableMule< T, C >::m_fromKeys
private

Definition at line 30 of file VariableMule.h.

◆ m_toKeys

template<typename T, typename C>
WC VariableMule< T, C >::m_toKeys
private

Definition at line 31 of file VariableMule.h.

◆ toCopy

template<typename T, typename C>
std::map<std::string,std::string> VariableMule< T, C >::toCopy

Definition at line 26 of file VariableMule.h.


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