ATLAS Offline Software
A/AthLinks/ElementLink.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 /*
3  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4  */
5 #ifndef ATHLINKS_ELEMENTLINK_H
6 #define ATHLINKS_ELEMENTLINK_H
7 
8 // System include(s):
9 extern "C" {
10 # include <stdint.h>
11 }
12 #include <string>
13 #include <RootMetaSelection.h>
14 
15 // Local include(s):
16 #include "AthLinks/ElementLinkBase.h"
18 
19 // Forward declaration(s):
20 namespace ROOT { namespace Meta { namespace Selection {
21  template< typename STORABLE >
22  class ElementLink;
23 }}}
24 namespace xAOD {
25  class TVirtualEvent;
26 }
27 
38 template< typename STORABLE >
39 class ElementLink : public ElementLinkBase {
40 
41 public:
44 
46  typedef std::string ID_type;
48  typedef uint32_t sgkey_t;
49 
51  typedef const STORABLE& BaseConstReference;
53  typedef const STORABLE* BaseConstPointer;
54 
56  typedef size_t index_type;
57 
59  typedef typename STORABLE::value_type value_type;
61  typedef typename STORABLE::const_iterator const_iterator;
62 
71 
73 
76 
81 
88 
99 
102  xAOD::TVirtualEvent* event = 0 );
105  xAOD::TVirtualEvent* event = 0 );
106 
109 
111 
114 
117 
122 
124  bool setElement( ElementType element );
127 
130  xAOD::TVirtualEvent* event = 0 );
133  xAOD::TVirtualEvent* event = 0 );
135  void reset();
136 
138 
141 
146 
148  index_type index() const { return persIndex(); }
149 
151  const ID_type& dataID() const;
153  sgkey_t key() const { return persKey(); }
154 
156  bool operator==( const ElementLink& rhs ) const;
158  bool operator!=( const ElementLink& rhs ) const;
159 
162 
164  ElementConstPointer operator->() const { return cptr(); }
166  operator ElementConstPointer () const { return cptr(); }
169 
171  bool isValid() const;
173  bool operator!() const { return ! isValid(); }
174 
176  ElementType cachedElement() const { return m_element; }
178  bool hasCachedElement() const { return m_elementCached; }
179 
181 
183  xAOD::TVirtualEvent* source() const { return m_event; }
184 
186  bool toPersistent() { return true; }
187 
188 private:
190  virtual bool toTransient();
194  void findIndex();
195 
201  mutable bool m_elementCached;
204 
206  typedef typename
208 
209 }; // class ElementLink
210 
211 template <typename STORABLE>
213  const ElementLink<STORABLE> &rhs);
214 
215 template <typename STORABLE>
217  const ElementLink<STORABLE> &rhs);
218 
219 /*
220  * The following piece of code declares all members of the ElementLink
221  * class as transient.
222  */
223 namespace ROOT { namespace Meta { namespace Selection {
224 template< typename STORABLE >
225 class ElementLink : public SelectNoInstance
226 {
227 
228 public:
231 
233  ROOT::Meta::Selection::MemberAttributes< kTransient > m_container;
234  ROOT::Meta::Selection::MemberAttributes< kTransient > m_element;
235  ROOT::Meta::Selection::MemberAttributes< kTransient > m_elementCached;
236  ROOT::Meta::Selection::MemberAttributes< kTransient > m_event;
237 
238 };
239 }}} // ROOT namespace
240 
241 // Include the implementation:
242 #ifndef __GCCXML__
243 # include "ElementLink.icc"
244 #endif // __GCCXML__
245 
246 #endif // ATHLINKS_ELEMENTLINK_H
xAOD::TVirtualEvent
Base interface for getting objects out of the input file.
Definition: TVirtualEvent.h:32
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
SG::GenericElementLinkBase::ID_type
SG::DataProxyHolder::ID_type ID_type
Type of string keys.
Definition: GenericElementLinkBase.h:98
ElementLinkBase
Base class for ElementLinks to vectors of pointers.
Definition: AthLinks/ElementLinkBase.h:59
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
SG::GenericElementLinkBase::index_type
INDEXING_POLICY::index_type index_type
The index type presented to and returned from the link.
Definition: GenericElementLinkBase.h:89
SG::GenericElementLinkBase::sgkey_t
SG::DataProxyHolder::sgkey_t sgkey_t
Type of hashed keys.
Definition: GenericElementLinkBase.h:95
test_pyathena.parent
parent
Definition: test_pyathena.py:15
SG::GenericElementLinkBase::ElementConstPointer
INDEXING_POLICY::ElementConstPointer ElementConstPointer
Definition: GenericElementLinkBase.h:81
TypeTools.h
value_type
Definition: EDM_MasterSearch.h:11
SG::GenericElementLinkBase::ElementType
INDEXING_POLICY::ElementType ElementType
Generic pointer to an element.
Definition: GenericElementLinkBase.h:80
ROOT
Selection rules: declare transient members.
Definition: DataVector.h:580