ATLAS Offline Software
Loading...
Searching...
No Matches
StoreGate/StoreGate/VarHandleKeyArray.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_VARHANDLEKEYARRAY_H
6#define STOREGATE_VARHANDLEKEYARRAY_H 1
7
14
15#include "GaudiKernel/DataHandle.h"
16#include "GaudiKernel/IDataHandleHolder.h"
18
19#include <vector>
20#include <string>
21
22namespace SG {
23
29 public:
31 virtual ~VarHandleKeyArray() = default;
32 virtual StatusCode assign(const std::vector<std::string>& vs)=0;
33 virtual void push_back(const std::string& key)=0;
34 virtual std::string toString() const = 0;
35 virtual Gaudi::DataHandle::Mode mode() const = 0;
36
37 virtual std::vector<SG::VarHandleKey*> keys() const = 0;
38
39 virtual void renounce() = 0;
40 virtual bool renounced() const = 0;
41 virtual void declare(IDataHandleHolder*) = 0;
42
43 virtual void setOwner( IDataHandleHolder* o ) = 0;
44 virtual const IDataHandleHolder* owner() const = 0;
45 virtual IDataHandleHolder* owner() = 0;
46
47 };
48
49/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
50// mixin class for common functionality
51//
52
60
61 template <class Base>
63 public std::vector<Base> {
64 public:
70
75 VarHandleKeyArrayCommon( const std::vector<Base>& v ):
76 std::vector<Base>(v) {};
77
82 VarHandleKeyArrayCommon( std::initializer_list<Base> l ):
83 std::vector<Base>{l} {};
84
90 VarHandleKeyArrayCommon( std::initializer_list<std::string> l ) {
91 for (const auto &e : l) {
92 std::vector<Base>::emplace_back( e );
93 }
94 }
95
106 template <class T = Base>
107 requires T::isDecorHandleKey
109 std::initializer_list<std::string> l ) {
110 for (const auto &e : l) {
111 std::vector<Base>::emplace_back( contKey, e );
112 }
113 }
114
120 StatusCode initialize (bool used = true);
121
127 virtual StatusCode assign(const std::vector<std::string>& vs) override;
128
133 virtual void push_back(const std::string& key) override {
134 std::vector<Base>::emplace_back( key );
135 }
136
140 virtual std::string toString() const override;
141
145 virtual std::vector<SG::VarHandleKey*> keys() const override;
146
147
151 virtual void renounce() override { m_isRenounced = true; }
152
156 virtual bool renounced() const override { return m_isRenounced; }
157
158 virtual void declare( IDataHandleHolder* ) override;
159
160 virtual void setOwner( IDataHandleHolder* o ) override { m_owner = o; }
161 virtual const IDataHandleHolder* owner() const override { return m_owner; }
162 virtual IDataHandleHolder* owner() override { return m_owner; }
163
164 private:
165
166 bool m_isRenounced{ false };
167 IDataHandleHolder* m_owner{ nullptr };
168
169 };
170
171} // namespace SG
172
173namespace std {
174 ostream& operator<<(ostream& s, const SG::VarHandleKeyArray& m);
175}
176
177
179
180#endif
A property holding a SG store/key/clid from which a VarHandle is made.
virtual void declare(IDataHandleHolder *) override
virtual void renounce() override
if called, handles will not be declared in the algorithm I/O
VarHandleKeyArrayCommon(const std::vector< Base > &v)
base Constructor that takes a vector
virtual void push_back(const std::string &key) override
Add a new key to the VarHandleKeyArray.
VarHandleKeyArrayCommon(VarHandleKey &contKey, std::initializer_list< std::string > l)
base Constructor that takes an associated container and an initializer list of std::strings.
virtual std::string toString() const override
string representation of the VarHandleKeyArray
virtual void setOwner(IDataHandleHolder *o) override
virtual const IDataHandleHolder * owner() const override
virtual bool renounced() const override
query renounced state
StatusCode initialize(bool used=true)
forward the initialization to the member VarHandleKeys
virtual IDataHandleHolder * owner() override
VarHandleKeyArrayCommon()
default base Constructor of mixin
virtual StatusCode assign(const std::vector< std::string > &vs) override
Set the contents of the VarHandleKeyArray from a vector of std::strings.
virtual std::vector< SG::VarHandleKey * > keys() const override
create array of all base VarHandleKeys in the Array
VarHandleKeyArrayCommon(std::initializer_list< Base > l)
base Constructor that takes an initializer list of VarHandleKeys
VarHandleKeyArrayCommon(std::initializer_list< std::string > l)
base Constructor that takes an initializer list of std::strings.
virtual std::vector< SG::VarHandleKey * > keys() const =0
virtual bool renounced() const =0
virtual void push_back(const std::string &key)=0
virtual void setOwner(IDataHandleHolder *o)=0
virtual ~VarHandleKeyArray()=default
virtual IDataHandleHolder * owner()=0
virtual Gaudi::DataHandle::Mode mode() const =0
virtual StatusCode assign(const std::vector< std::string > &vs)=0
virtual const IDataHandleHolder * owner() const =0
virtual std::string toString() const =0
virtual void renounce()=0
virtual void declare(IDataHandleHolder *)=0
A property holding a SG store/key/clid from which a VarHandle is made.
holding In fact this class is here in order to allow STL container for all features This class is sho...
Forward declaration.
STL namespace.
ostream & operator<<(ostream &s, const SG::VarHandleKey &m)