ATLAS Offline Software
Loading...
Searching...
No Matches
AthLinks/DataLink.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-2026 CERN for the benefit of the ATLAS collaboration
4*/
11
12
13#ifndef ATHLINKS_DATALINK_H
14#define ATHLINKS_DATALINK_H
15
16
17#include "AthLinks/DataLinkBase.h"
22#include <format>
23#include <vector>
24class EventContext;
25class IProxyDict;
26
27
93template <class STORABLE>
95 : public DataLinkBase
96{
97public:
99 typedef STORABLE value_type;
100 typedef STORABLE* pointer;
101 typedef const STORABLE* const_pointer;
102 typedef STORABLE& reference;
103 typedef const STORABLE& const_reference;
104
107
110
111
115 static CLID classID();
116
117
118 //========================================================================
121
122
127
128
135
136
142 DataLink(const_reference data, const EventContext& ctx);
143
144
151
152
158 DataLink(const_pointer pdata, const EventContext& ctx);
159
160
167
168
174 DataLink(const ID_type& dataID, const EventContext& ctx);
175
176
185
186
194 DataLink(sgkey_t key, const EventContext& ctx);
195
196
204
205
207 //========================================================================
210
211
222
223
229 void toStorableObject(const_reference data, const EventContext& ctx);
230
231
242
243
249 void toIdentifiedObject(const ID_type& dataID, const EventContext& ctx);
250
251
264
265
273 void toIdentifiedObject(sgkey_t key, const EventContext& ctx);
274
275
291
292
303 void toDefaultObject (const EventContext& ctx);
304
305
316 bool toTransient (IProxyDict* sg = 0);
317
318
327 bool toTransient (const EventContext& ctx);
328
329
341 bool toTransient (const ID_type& dataID, IProxyDict* sg = 0);
342
343
353 bool toTransient (const ID_type& dataID, const EventContext& ctx);
354
355
356
358 //========================================================================
361
368
369
376
377
382
383
388
389
393 operator const_pointer() const;
394
395
400
401
405 bool isValid() const;
406
407
408
412 bool operator!() const;
413
414
415 // Inherited from base class:
416 // bool isDefault() const;
417 // const ID_type& dataID() const;
418 // sgkey_t key() const;
419 // void clear();
420 // SG::DataProxy* proxy (bool nothrow = false) const;
421 // IProxyDict* source() const;
422 // bool toPersistent();
423 // bool toPersistentNoRemap();
424 // bool operator== (const DataLinkBase& other) const;
425 // bool operator!= (const DataLinkBase& other) const;
426
427
428private:
434 const void* storable() const;
435
436
443};
444
445
446namespace SG {
447
448
452template <class STORABLE>
453class ToTransient<DataLink<STORABLE> >
454{
455public:
457 IProxyDict* sg = nullptr);
459 const EventContext& ctx);
460};
461
462
467template <class STORABLE, class ALLOC>
468class ToTransient<std::vector<DataLink<STORABLE>, ALLOC> >
469{
470public:
471 static void toTransient (std::vector<DataLink<STORABLE>, ALLOC>& dlv,
472 IProxyDict* sg = nullptr);
473 static void toTransient (std::vector<DataLink<STORABLE>, ALLOC>& dlv,
474 const EventContext& ctx);
475};
476
477
482template <class STORABLE, class ALLOC1, class ALLOC2>
483class ToTransient<std::vector<std::vector<DataLink<STORABLE>, ALLOC1>, ALLOC2> >
484{
485public:
486 static void toTransient (std::vector<std::vector<DataLink<STORABLE>, ALLOC1>, ALLOC2>& dlvv,
487 IProxyDict* sg = nullptr);
488 static void toTransient (std::vector<std::vector<DataLink<STORABLE>, ALLOC1>, ALLOC2>& dlvv,
489 const EventContext& ctx);
490};
491
492
493
494} // namespace SG
495
496
497namespace std {
498
499
500// C++20 compatible formatter.
501template <class T>
502struct formatter<DataLink<T> >
503 : public formatter<string_view>
504{
505 template <class FmtContext>
506 FmtContext::iterator format(const DataLink<T>& k, FmtContext& ctx) const
507 {
508 if (k.isDefault()) {
509 return formatter<string_view>::format ("(nullLink)", ctx);
510 }
511 return std::format_to (ctx.out(), "@{}", k.dataID());
512 }
513};
514
515
516} // namespace std
517
518
519#include "AthLinks/DataLink.icc"
520
521
522#endif // not ATHLINKS_DATALINK_H
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
uint32_t CLID
The Class ID type.
Define a hook for running code after an object has been read.
SG::DataProxyHolder::sgkey_t sgkey_t
Type of hashed keys.
DataLinkBase()
Default constructor.
SG::DataProxyHolder::ID_type ID_type
Type of string keys.
Manage DataProxy reference in ElementLink/DataLink.
Define a hook for running code after an object has been read.
Definition ToTransient.h:40
Forward declaration.
STL namespace.
Some out-of-line helpers for ExtendedEventContext.