ATLAS Offline Software
AthToolSupport/AsgDataHandles/AsgDataHandles/WriteDecorHandle.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration.
4  */
12 #ifndef ASG_DATA_HANDLES_WRITE_DECOR_HANDLE_H
13 #define ASG_DATA_HANDLES_WRITE_DECOR_HANDLE_H
14 
15 #ifndef XAOD_STANDALONE
17 #else
18 
23 // #include "GaudiKernel/EventContext.h"
24 // #include <type_traits>
25 
26 
27 namespace SG {
28 
29 
42 template <class T, class D>
43 class WriteDecorHandle
44  : public ReadHandle<T>
45 {
46 public:
48  typedef ReadHandle<T> Base;
49 
52 
54  typedef typename accessor_t::reference_type
56 
58  typedef typename accessor_t::container_pointer_type
60 
68  explicit WriteDecorHandle (const WriteDecorHandleKey<T>& key);
69 
70 
82  explicit WriteDecorHandle (const WriteDecorHandleKey<T>& key,
83  const EventContext& ctx);
84 
85 
86 // /**
87 // * @brief Copy constructor.
88 // */
89 // WriteDecorHandle (const WriteDecorHandle& rhs);
90 
91 
92 // /**
93 // * @brief Move constructor.
94 // */
95 // WriteDecorHandle (WriteDecorHandle&& rhs);
96 
97 
98 // /**
99 // * @brief Destructor. This will lock the decoration.
100 // */
101 // ~WriteDecorHandle();
102 
103 
104 // /**
105 // * @brief Assignment operator.
106 // */
107 // WriteDecorHandle& operator= (const WriteDecorHandle& rhs);
108 
109 
110 // /**
111 // * @brief Move operator.
112 // */
113 // WriteDecorHandle& operator= (WriteDecorHandle&& rhs);
114 
115 
124  bool isPresent() const;
125 
126 
127 // /**
128 // * @brief Explicitly set the event store.
129 // * @param store The new event store.
130 // *
131 // * This implicitly does a reset().
132 // *
133 // * We need to override this so that the setting gets made on the container
134 // * handle as well.
135 // */
136 // virtual StatusCode setProxyDict (IProxyDict* store) override;
137 
138 
143  reference_type operator() (const AuxElement& e);
144 
145 
146 // /**
147 // * @brief Fetch the variable for one element, as a reference.
148 // * @param index The index of the desired element.
149 // *
150 // * This looks up the variable in the object referenced by this handle.
151 // * For a standalone object, pass an index of 0.
152 // */
153 // reference_type operator() (size_t index);
154 
155 
156 // /**
157 // * @brief Get a pointer to the start of the auxiliary data array,
158 // * for the referenced object.
159 // */
160 // container_pointer_type
161 // getDecorationArray();
162 
163 
168  bool isAvailable();
169 
170 
171 // /**
172 // * @brief Return the aux id for this variable.
173 // */
174 // SG::auxid_t auxid() const;
175 
176 
177  // /**
178  // * @brief Return the mode (read/write/update) for this handle.
179  // */
180  // Gaudi::DataHandle::Mode mode() const;
181 
182 
186  std::string decorKey() const;
187 
188 
189 // private:
190 // /**
191 // * @brief Retrieve an object from StoreGate.
192 // * @param quiet If true, suppress failure messages.
193 // *
194 // * Extended for decoration handles: when we first retrieve the object,
195 // * we make an alias for the decoration and also create the decoration itself.
196 // */
197 // virtual void* typeless_dataPointer_impl (bool quiet) override;
198 
199 
206  bool isAvailable (std::true_type);
207 
208 
215  bool isAvailable (std::false_type);
216 
217 
218 // /**
219 // * @brief Return the referenced object as a @c SG::AuxVectorData.
220 // * Specialization for the case of a standalone object
221 // * (@c T derives from @c SG::AuxElement).
222 // */
223 // const SG::AuxVectorData* vectorData (std::true_type);
224 
225 
226 // /**
227 // * @brief Return the referenced object as a @c SG::AuxVectorData.
228 // * Specialization for the case of a container
229 // * (@c T does not derive from @c SG::AuxElement).
230 // */
231 // const SG::AuxVectorData* vectorData (std::false_type);
232 
233 
234 // /**
235 // * @brief Return the referenced object as a @c SG::AuxVectorData.
236 // *
237 // * If @c T is a container object, then this should be the object itself.
238 // * But if it is a standalone object, deriving from @c SG::AuxElement,
239 // * then we need to call container() on the object.
240 // */
241 // const SG::AuxVectorData* vectorData();
242 
243 
245  std::string m_decorKey;
246 
247 
250 
251 // bool m_madeAlias;
252 };
253 
254 
255 // /**
256 // * @brief Return a @c WriteDecorHandle referencing @c key.
257 // * @param key The key object holding the clid/key/store.
258 // *
259 // * This will raise an exception if the StoreGate key is blank,
260 // * or if the event store cannot be found.
261 // *
262 // * The type of the decoration must be included as an explicit template parameter:
263 // *
264 // *@code
265 // * auto handle = SG::makeHandle<float> (key);
266 // @endcode
267 // *
268 // * Note that @c D comes first in the argument list. It's given explicitly,
269 // * while @c T is inferred from @c key.
270 // */
271 // template <class D, class T>
272 // WriteDecorHandle<T, D> makeHandle (const WriteDecorHandleKey<T>& key);
273 
274 
275 // /**
276 // * @brief Return a @c WriteDecorHandle referencing @c key for an explicit context.
277 // * @param key The key object holding the clid/key/store.
278 // * @param ctx The event context.
279 // *
280 // * This will raise an exception if the StoreGate key is blank,
281 // * or if the event store cannot be found.
282 // *
283 // * If the default event store has been requested, then the thread-specific
284 // * store from the event context will be used.
285 // *
286 // * The type of the decoration must be included as an explicit template parameter:
287 // *
288 // *@code
289 // * auto handle = SG::makeHandle<float> (key, ctx);
290 // @endcode
291 // *
292 // * Note that @c D comes first in the argument list. It's given explicitly,
293 // * while @c T is inferred from @c key.
294 // */
295 // template <class D, class T>
296 // WriteDecorHandle<T, D> makeHandle (const WriteDecorHandleKey<T>& key,
297 // const EventContext& ctx);
298 
299 
307 template <class T>
308 void makeHandle (const WriteDecorHandleKey<T>& key);
309 template <class T>
310 void makeHandle (const WriteDecorHandleKey<T>& key,
311  const EventContext& ctx);
312 
313 
314 } // namespace SG
315 
316 
318 
319 
320 #endif
321 
322 #endif
SG::WriteDecorHandle::container_pointer_type
typename accessor_t::container_pointer_type container_pointer_type
Pointer into the vector holding an aux data item.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:111
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::WriteDecorHandle::isAvailable
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
SG::WriteDecorHandle::decorKey
std::string decorKey() const
Return the name of the decoration alias (CONT.DECOR).
WriteDecorHandle.icc
SG::WriteDecorHandle::operator()
reference_type operator()(const AuxElement &e)
Fetch the variable for one element, as a reference.
ReadHandle< T >
a smart pointer to an object of a given type in an IProxyDict (such as StoreGateSvc)....
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
SG::WriteDecorHandle::accessor_t
SG::AuxElement::Decorator< D > accessor_t
Accessor type for aux data.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:105
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
WriteDecorHandle.h
Handle class for adding a decoration to an object.
SG::Decorator::container_pointer_type
typename AuxDataTraits< T, ALLOC >::container_pointer_type container_pointer_type
Pointer into the container holding this item.
Definition: Decorator.h:68
SG::Decorator::reference_type
typename AuxDataTraits< T, ALLOC >::reference_type reference_type
Type referencing an item.
Definition: Decorator.h:61
ReadHandle.h
Handle class for reading from StoreGate.
SG::WriteDecorHandle::WriteDecorHandle
WriteDecorHandle(const WriteDecorHandleKey< T > &key)
Constructor from a WriteDecorHandleKey.
SG::WriteDecorHandle::Base
ReadHandle< T > Base
Base class.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:102
DecorKeyHelpers.h
WriteDecorHandleKey.h
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
SG::WriteDecorHandle::reference_type
typename accessor_t::reference_type reference_type
Type referencing an aux data item.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:108
SG::WriteDecorHandle::isPresent
bool isPresent() const
Is the referenced container present in SG?
SG::WriteDecorHandle::m_decorKey
std::string m_decorKey
Name of the decoration alias: CONT.DECOR.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:310
SG::WriteDecorHandle::m_acc
accessor_t m_acc
Accessor for the aux data item.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:313
AuxElement.h
Base class for elements of a container that can have aux data.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37