ATLAS Offline Software
Loading...
Searching...
No Matches
DataHandle.h
Go to the documentation of this file.
1/* -*- C++ -*- */
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
10#ifndef STOREGATE_DATAHANDLE_H
11#define STOREGATE_DATAHANDLE_H
12
16#include "SGTools/ProxyMap.h"
17#include "SGTools/DataProxy.h"
21#include <iterator>
22#include <iostream>
23
40template <typename DATA>
42 public DataHandleBase
43{
44public:
45 using iterator_category = std::forward_iterator_tag;
46 using value_type = DATA;
47 using difference_type = std::ptrdiff_t;
50
51 typedef pointer pointer_type; // `using' here gives cppcheck false positives
52 using const_pointer_type = const DATA*;
54 using const_reference_type = const DATA&;
55
57
59
63 DataHandle& operator= (const DATA& d)
64 {
66 if (ptr) {
67 *ptr = d;
68 } else {
69 std::cerr << "invalid proxy\n";
70 }
71 return *this;
72 }
73
74 virtual ~DataHandle();
76
78
79 bool isValid() const;
80
81 // FIXME op! is to keep backward compatibility with Gaudi
82 // FIXME similar to checking the SmartDataPtr
83 // FIXME dangerous stuff: remove!
85 bool operator !() const { return !isValid(); }
86
87 //FIXME VERY dangerous stuff: remove!
89 operator int() const { return isValid(); }
91
93
94 const DataHandle& operator++ () const;
95 DataHandle operator++ (int) const;
96
97 const_pointer_type operator->() const { return cptr(); }
98
99 const_reference_type operator*() const { return *cptr(); }
101
103
104 operator const_pointer_type() const { return cptr(); }
105
107
108 virtual void reset (bool /*hard*/) override { m_ptr = 0; }
110
112
115 const SG::ConstProxyIterator& itr2);
116
118
120 virtual CLID clid() const override { return ClassID_traits<DATA>::ID(); }
121
122 friend
123 bool operator== ATLAS_NOT_THREAD_SAFE (const DataHandle<DATA>& h1,
124 const DataHandle<DATA>& h2)
125 {
126 return h1.m_proxy == h2.m_proxy;
127 }
128
129 friend
130 bool operator!= ATLAS_NOT_THREAD_SAFE (const DataHandle<DATA>& h1,
131 const DataHandle<DATA>& h2)
132 {
133 return h1.m_proxy != h2.m_proxy;
134 }
135
136private:
137
138 // OK since DataHandle should only be used locally, not shared between threads.
139 // Eventually we'd like to deprecate DataHandle anyway.
142
143
144};
145
147
148/* FIXME LEGACY - No dependency on ActiveStoreSvc here, but a number of Muon AtlasEvent packages are
149 getting the include through this one!!!! */
150
152
153#endif // STOREGATE_DATAHANDLE_H
154
155
156
157
158
159
160
161
162
163
164
const APEvtWeight operator!(const APEvtWeight &a_in)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
Helpers for retrieving the payload held by a DataProxy.
uint32_t CLID
The Class ID type.
Define macros for attributes used to control the static checker.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Header file for AthHistogramAlgorithm.
std::string ID_type
SG::DataProxy * m_proxy
the proxy holding the object we are bound to
DataHandleBase()
Default constructor:
DataHandleBase & operator=(const DataHandleBase &rhs)
Assignment operator:
const DATA * const_pointer_type
Definition DataHandle.h:52
bool isValid() const
RETRIEVES the DO to check it is valid and unlocked.
virtual ~DataHandle()
unbind from the proxy before we go
const_pointer_type m_ptr
Definition DataHandle.h:140
std::ptrdiff_t difference_type
Definition DataHandle.h:47
const_reference_type operator*() const
Definition DataHandle.h:99
DATA value_type
Definition DataHandle.h:46
virtual void reset(bool) override
reset pointer
Definition DataHandle.h:108
pointer pointer_type
Definition DataHandle.h:51
value_type & reference
Definition DataHandle.h:49
const_pointer_type operator->() const
Definition DataHandle.h:97
const_pointer_type dataPointer() const
DataHandleBase::ID_type ID_type
Definition DataHandle.h:56
reference reference_type
Definition DataHandle.h:53
DataHandle(const DataHandle &h)
virtual CLID clid() const override
the CLID of the object we are bound to
Definition DataHandle.h:120
value_type * pointer
Definition DataHandle.h:48
DataHandle(SG::DataProxy *proxy)
const DATA & const_reference_type
Definition DataHandle.h:54
const_pointer_type cptr() const
safer explicit ptr accessor
DataHandle(const SG::ConstProxyIterator &itr1, const SG::ConstProxyIterator &itr2)
std::forward_iterator_tag iterator_category
Definition DataHandle.h:45
ProxyMap::const_iterator ConstProxyIterator
Definition ProxyMap.h:24