ATLAS Offline Software
StoreGate/StoreGate/HandleKeyArray.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef STOREGATE_HANDLEKEYARRAY_H
6 #define STOREGATE_HANDLEKEYARRAY_H 1
7 
9 #include "GaudiKernel/EventContext.h"
10 #include "GaudiKernel/ThreadLocalContext.h"
11 
12 #include <vector>
13 #include <string>
14 
15 namespace SG {
16 
44  template <class T_Handle, class T_HandleKey, Gaudi::DataHandle::Mode MODE>
45  class HandleKeyArray : public VarHandleKeyArrayCommon< T_HandleKey > {
46  public:
51 
57  HandleKeyArray( const std::vector<T_HandleKey>& v ) :
58  VarHandleKeyArrayCommon<T_HandleKey> ( v ) {}
59 
65  HandleKeyArray( std::initializer_list<T_HandleKey> l ):
66  VarHandleKeyArrayCommon<T_HandleKey> {l} {}
67 
74  HandleKeyArray( std::initializer_list<std::string> key_names):
75  VarHandleKeyArrayCommon<T_HandleKey> {key_names} {}
76 
87  template <class T = T_HandleKey>
88  requires T::isDecorHandleKey
90  std::initializer_list<std::string> key_names ):
91  VarHandleKeyArrayCommon<T_HandleKey> {contKey, key_names} {}
92 
102  template <std::derived_from<IProperty> OWNER>
103  inline HandleKeyArray( OWNER* owner,
104  std::string name,
105  std::initializer_list<std::string> l,
106  std::string doc="") :
107  VarHandleKeyArrayCommon<T_HandleKey> {l} {
108  auto p = owner->declareProperty(std::move(name), *this, std::move(doc));
109  p->template setOwnerType<OWNER>();
110  }
111 
112 
126  template <std::derived_from<IProperty> OWNER, class T = T_HandleKey>
127  requires T::isDecorHandleKey
128  inline HandleKeyArray( OWNER* owner,
129  std::string name,
130  VarHandleKey& contKey,
131  std::initializer_list<std::string> l,
132  std::string doc="") :
133  VarHandleKeyArrayCommon<T_HandleKey> {contKey, l} {
134  auto p = owner->declareProperty(std::move(name), *this, std::move(doc));
135  p->template setOwnerType<OWNER>();
136  }
137 
138 
142  virtual Gaudi::DataHandle::Mode mode() const override { return MODE; }
143 
148  std::vector< T_Handle > makeHandles() const {
149  const EventContext& ctx = Gaudi::Hive::currentContext();
150  std::vector< T_Handle > hndl;
151  for (const T_HandleKey& k : *this) {
152  hndl.emplace_back ( k, ctx );
153  }
154  return hndl;
155  }
156 
161  std::vector< T_Handle > makeHandles (const EventContext& ctx) const
162  {
163  std::vector< T_Handle > hndl;
164  for (const T_HandleKey& k : *this) {
165  hndl.emplace_back ( k, ctx);
166  }
167  return hndl;
168  }
169 
170  };
171 
172 } // namespace SG
173 
174 #endif
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::HandleKeyArray::HandleKeyArray
HandleKeyArray(const std::vector< T_HandleKey > &v)
Constructor from a HandleKeyArray that takes a vector of ReadHandleKeys.
Definition: StoreGate/StoreGate/HandleKeyArray.h:57
VarHandleKeyArray.h
Base class for VarHandleKeyArray for reading from StoreGate.
SG::VarHandleKeyArrayCommon
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:63
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:45
requires
requires requires()
This specialization is used for classes deriving from DataObject.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:68
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:157
SG::HandleKeyArray::HandleKeyArray
HandleKeyArray()
default Constructor from a HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:50
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
SG::VarHandleKeyArrayCommon< T_HandleKey >::owner
virtual const IDataHandleHolder * owner() const override
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:161
MODE
#define MODE
Definition: CellClusterLinkTool.h:24
SG::HandleKeyArray::HandleKeyArray
HandleKeyArray(std::initializer_list< std::string > key_names)
Constructor from a HandleKeyArray that takes an initializer list of std::strings.
Definition: StoreGate/StoreGate/HandleKeyArray.h:74
SG::HandleKeyArray::HandleKeyArray
HandleKeyArray(OWNER *owner, std::string name, std::initializer_list< std::string > l, std::string doc="")
auto-declaring Property Constructor from a HandleKeyArray that takes an initializer list of std::stri...
Definition: StoreGate/StoreGate/HandleKeyArray.h:103
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
EventContainers::Mode
Mode
Definition: IdentifiableContainerBase.h:13
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition: StoreGate/StoreGate/VarHandleKey.h:59
SG::HandleKeyArray::makeHandles
std::vector< T_Handle > makeHandles(const EventContext &ctx) const
create a vector of Handles from the HandleKeys in the array, with explicit EventContext.
Definition: StoreGate/StoreGate/HandleKeyArray.h:161
python.PyAthena.v
v
Definition: PyAthena.py:154
SG::HandleKeyArray::HandleKeyArray
requires T::isDecorHandleKey HandleKeyArray(VarHandleKey &contKey, std::initializer_list< std::string > key_names)
base Constructor that takes an associated container and an initializer list of std::strings.
Definition: StoreGate/StoreGate/HandleKeyArray.h:89
SG::HandleKeyArray::makeHandles
std::vector< T_Handle > makeHandles() const
create a vector of Handles from the HandleKeys in the array
Definition: StoreGate/StoreGate/HandleKeyArray.h:148
SG::HandleKeyArray::HandleKeyArray
requires T::isDecorHandleKey HandleKeyArray(OWNER *owner, std::string name, VarHandleKey &contKey, std::initializer_list< std::string > l, std::string doc="")
auto-declaring Property Constructor from a HandleKeyArray that takes an initializer list of std::stri...
Definition: StoreGate/StoreGate/HandleKeyArray.h:128
SG::HandleKeyArray::HandleKeyArray
HandleKeyArray(std::initializer_list< T_HandleKey > l)
Constructor from a HandleKeyArray that takes an initializer list of HandleKeys.
Definition: StoreGate/StoreGate/HandleKeyArray.h:65
SG::HandleKeyArray::mode
virtual Gaudi::DataHandle::Mode mode() const override
return the type (Read/Write/Update) of handle
Definition: StoreGate/StoreGate/HandleKeyArray.h:142
fitman.k
k
Definition: fitman.py:528