ATLAS Offline Software
StoreGate/StoreGate/VarHandleKeyArray.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef STOREGATE_VARHANDLEKEYARRAY_H
6 #define STOREGATE_VARHANDLEKEYARRAY_H 1
7 
15 #include "GaudiKernel/DataHandle.h"
16 #include "GaudiKernel/IDataHandleHolder.h"
17 #include "StoreGate/VarHandleKey.h"
18 
19 #include <vector>
20 #include <string>
21 
22 namespace SG {
23 
29  public:
31  virtual ~VarHandleKeyArray() = default;
32  virtual StatusCode assign(const std::vector<std::string>& vs)=0;
33  virtual std::string toString() const = 0;
34  virtual Gaudi::DataHandle::Mode mode() const = 0;
35 
36  virtual std::vector<SG::VarHandleKey*> keys() const = 0;
37 
38  virtual void renounce() = 0;
39  virtual bool renounced() const = 0;
40  virtual void declare(IDataHandleHolder*) = 0;
41 
42  virtual void setOwner( IDataHandleHolder* o ) = 0;
43  virtual const IDataHandleHolder* owner() const = 0;
44  virtual IDataHandleHolder* owner() = 0;
45 
46  };
47 
48 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
49 // mixin class for common functionality
50 //
51 
60  template <class Base>
62  public std::vector<Base> {
63  public:
69 
74  VarHandleKeyArrayCommon( const std::vector<Base>& v ):
75  std::vector<Base>(v) {};
76 
82  VarHandleKeyArrayCommon( std::initializer_list<Base> l ):
83  std::vector<Base>{l} {};
84 
91  VarHandleKeyArrayCommon( std::initializer_list<std::string> l ) {
92  for (auto &e : l) {
93  this->push_back( Base{e} );
94  }
95  }
96 
102  StatusCode initialize (bool used = true);
103 
109  virtual StatusCode assign(const std::vector<std::string>& vs) override;
110 
114  virtual std::string toString() const override;
115 
119  virtual std::vector<SG::VarHandleKey*> keys() const override;
120 
121 
125  virtual void renounce() override { m_isRenounced = true; }
126 
130  virtual bool renounced() const override { return m_isRenounced; }
131 
132  virtual void declare( IDataHandleHolder* ) override;
133 
134  virtual void setOwner( IDataHandleHolder* o ) override { m_owner = o; }
135  virtual const IDataHandleHolder* owner() const override { return m_owner; }
136  virtual IDataHandleHolder* owner() override { return m_owner; }
137 
138  private:
139 
140  bool m_isRenounced{ false };
141  IDataHandleHolder* m_owner{ nullptr };
142 
143  };
144 
145 } // namespace SG
146 
147 namespace std {
148  ostream& operator<<(ostream& s, const SG::VarHandleKeyArray& m);
149 }
150 
151 
153 
154 #endif
used
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SG::VarHandleKeyArray::assign
virtual StatusCode assign(const std::vector< std::string > &vs)=0
SG::VarHandleKeyArrayCommon::VarHandleKeyArrayCommon
VarHandleKeyArrayCommon(std::initializer_list< std::string > l)
base Constructor from a VarHandleKeyArray that takes an initializer list of std::strings.
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:91
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
SG::VarHandleKeyArray::toString
virtual std::string toString() const =0
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
VarHandleKey.h
A property holding a SG store/key/clid from which a VarHandle is made.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::VarHandleKeyArray::owner
virtual IDataHandleHolder * owner()=0
SG::VarHandleKeyArrayCommon::VarHandleKeyArrayCommon
VarHandleKeyArrayCommon(const std::vector< Base > &v)
base Constructor from a VarHandleKeyArray that takes a vector
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:74
SG::VarHandleKeyArrayCommon
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:62
SG::VarHandleKeyArray::keys
virtual std::vector< SG::VarHandleKey * > keys() const =0
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
SG::VarHandleKeyArrayCommon::toString
virtual std::string toString() const override
string representation of the VarHandleKeyArray
SG::VarHandleKeyArrayCommon::renounced
virtual bool renounced() const override
query renounced state
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:130
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
SG::VarHandleKeyArrayCommon::declare
virtual void declare(IDataHandleHolder *) override
SG::VarHandleKeyArrayCommon::setOwner
virtual void setOwner(IDataHandleHolder *o) override
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:134
SG::VarHandleKeyArray::renounced
virtual bool renounced() const =0
SG::VarHandleKeyArrayCommon::owner
virtual const IDataHandleHolder * owner() const override
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:135
SG::VarHandleKeyArray::owner
virtual const IDataHandleHolder * owner() const =0
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
Base
SG::VarHandleKeyArrayCommon::m_isRenounced
bool m_isRenounced
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:140
SG::VarHandleKeyArrayCommon::assign
virtual StatusCode assign(const std::vector< std::string > &vs) override
Set the contents of the VarHandleKeyArray from a vector of std::strings.
SG::VarHandleKeyArrayCommon::keys
virtual std::vector< SG::VarHandleKey * > keys() const override
create array of all base VarHandleKeys in the Array
SG::VarHandleKeyArray::~VarHandleKeyArray
virtual ~VarHandleKeyArray()=default
SG::VarHandleKeyArray::declare
virtual void declare(IDataHandleHolder *)=0
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::VarHandleKeyArrayCommon::renounce
virtual void renounce() override
if called, handles will not be declared in the algorithm I/O
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:125
SG::VarHandleKeyArrayCommon::initialize
StatusCode initialize(bool used=true)
forward the initialization to the member VarHandleKeys
SG::VarHandleKeyArrayCommon::VarHandleKeyArrayCommon
VarHandleKeyArrayCommon(std::initializer_list< Base > l)
base Constructor from a VarHandleKeyArray that takes an initializer list of VarHandleKeys
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:82
EventContainers::Mode
Mode
Definition: IdentifiableContainerBase.h:13
operator<<
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
Definition: TestGaudiProperty.cxx:69
SG::VarHandleKeyArrayCommon::m_owner
IDataHandleHolder * m_owner
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:141
python.PyAthena.v
v
Definition: PyAthena.py:154
SG::VarHandleKeyArrayCommon::owner
virtual IDataHandleHolder * owner() override
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:136
SG::VarHandleKeyArrayCommon::VarHandleKeyArrayCommon
VarHandleKeyArrayCommon()
default base Constructor of mixin
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:68
SG::VarHandleKeyArray::VarHandleKeyArray
VarHandleKeyArray()
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:30
SG::VarHandleKeyArray::mode
virtual Gaudi::DataHandle::Mode mode() const =0
VarHandleKeyArray.icc
SG::VarHandleKeyArray
Definition: StoreGate/StoreGate/VarHandleKeyArray.h:28