ATLAS Offline Software
Loading...
Searching...
No Matches
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
15namespace SG {
16
43
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
#define MODE
Base class for VarHandleKeyArray for reading from StoreGate.
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...
HandleKeyArray(VarHandleKey &contKey, std::initializer_list< std::string > key_names)
base Constructor that takes an associated container and an initializer list of std::strings.
HandleKeyArray(const std::vector< T_HandleKey > &v)
Constructor from a HandleKeyArray that takes a vector of ReadHandleKeys.
std::vector< T_Handle > makeHandles(const EventContext &ctx) const
create a vector of Handles from the HandleKeys in the array, with explicit EventContext.
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...
HandleKeyArray()
default Constructor from a HandleKeyArray
std::vector< T_Handle > makeHandles() const
create a vector of Handles from the HandleKeys in the array
HandleKeyArray(std::initializer_list< std::string > key_names)
Constructor from a HandleKeyArray that takes an initializer list of std::strings.
virtual Gaudi::DataHandle::Mode mode() const override
return the type (Read/Write/Update) of handle
HandleKeyArray(std::initializer_list< T_HandleKey > l)
Constructor from a HandleKeyArray that takes an initializer list of HandleKeys.
A property holding a SG store/key/clid from which a VarHandle is made.
Forward declaration.