ATLAS Offline Software
Loading...
Searching...
No Matches
ViewVector.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-2025 CERN for the benefit of the ATLAS collaboration
4*/
11
12
13#ifndef ATHCONTAINERS_VIEWVECTOR_H
14#define ATHCONTAINERS_VIEWVECTOR_H
15
16
21#include "AthLinks/ElementLink.h"
22#include <atomic>
23
24
64template <class DV>
66 : public DV, public SG::ViewVectorBase
67{
68public:
70 typedef typename DV::size_type size_type;
71 typedef typename DV::difference_type difference_type;
72 typedef typename DV::allocator_type allocator_type;
73 typedef typename DV::base_value_type base_value_type;
74 typedef typename DV::BaseContainer BaseContainer;
75 typedef typename DV::DVL_BASE DVL_BASE;
76 typedef typename DV::const_iterator const_iterator;
77 typedef typename DV::const_reverse_iterator const_reverse_iterator;
78 typedef typename DV::value_type value_type;
79 typedef typename DV::const_value_type const_value_type;
80 typedef typename DV::reference reference;
81 typedef typename DV::const_reference const_reference;
82 typedef typename DV::pointer pointer;
83 typedef typename DV::const_pointer const_pointer;
84 typedef typename DV::unique_type unique_type;
85
87 // cppcheck-suppress duplInheritedMember
88 static constexpr bool must_own = DV::must_own;
89
91 typedef std::vector<ElementLink<DV> > Pers_t;
92
93
94 //========================================================================
97
98
106
107
120
121
127 template <class InputIterator>
128 ViewVector(InputIterator first, InputIterator last);
129
130
132 ViewVector (const ViewVector&) = default;
133
134
142
143
148 ViewVector (const DV& rhs);
149
150
157 ViewVector (DV&& rhs);
158
159
164 ViewVector(std::initializer_list<value_type> l);
165
166
168 ViewVector& operator= (const ViewVector& rhs) = default;
169
170
183 ViewVector& operator= (const DV& rhs);
184
185
193
194
203
204
212 ViewVector& operator= (std::initializer_list<value_type> l);
213
214
216 using DV::clear;
217
218
226 void clear (SG::OwnershipPolicy ownPolicy);
227
228
237 void clear (SG::OwnershipPolicy ownPolicy,
238 SG::IndexTrackingPolicy trackIndices);
239
240
244 virtual void toPersistent() override;
245
246
250 virtual void toTransient() override;
251
252
253private:
257};
258
259
260#ifndef XAOD_STANDALONE
262namespace SG {
263
264
266template<class DV>
267struct Bases<ViewVector<DV> > {
269};
270
271
272}
273#endif
274
275
277
278
279#ifndef XAOD_STANDALONE
297template <class DV>
299{
300 static const bool s_isDataObject = false;
301 typedef std::true_type has_classID_tag;
302
303 static const CLID& ID() {
304 if (s_clid == CLID_NULL)
306 static const CLID clid = s_clid;
307 return clid;
308 }
309 static const char* typeNameString() {
310 if (s_name == nullptr)
312 return s_name;
313 }
314 static const std::string& typeName() {
315 static const std::string name = typeNameString(); return name;
316 }
317 static const std::type_info& typeInfo() {
318 return typeid (ViewVector<DV>);
319 }
320 typedef std::false_type has_version_tag;
321 static const bool s_isConst = false;
322
323 static bool init (CLID clid, const char* name)
324 {
325 if (s_clid == CLID_NULL) {
326 s_clid = clid;
327 s_name = name;
328 }
329 return true;
330 }
331private:
332 static std::atomic<CLID> s_clid;
333 static std::atomic<const char*> s_name;
334};
335
336template <class DV>
337std::atomic<CLID> ClassID_traits< ViewVector<DV> >::s_clid { CLID_NULL };
338template <class DV>
339std::atomic<const char*> ClassID_traits< ViewVector<DV> >::s_name { nullptr };
340#endif // not XAOD_STANDALONE
341
342
343#ifdef XAOD_STANDALONE
344
345// FIXME: xAOD has its own, incompatible, CLASS_DEF, but we don't want to use it
346// due to dependency issues. Probably need to move things around
347// a bit to resolve this.
348#define VIEWVECTOR_CLASS_DEF(NAME, CID)
349
350#else
351
355#define VIEWVECTOR_CLASS_DEF(NAME, CID) \
356 [[maybe_unused]] \
357 static const bool clidinit_##CID = ClassID_traits<NAME>::init (CID, #NAME); \
358 CLIDREGISTRY_ADDENTRY(CID, NAME)
359#endif
360
361
362#endif // not ATHCONTAINERS_VIEWVECTOR_H
363
Exceptions that can be thrown from AthContainers.
Provide an interface for finding inheritance information at run time.
uint32_t CLID
The Class ID type.
Describes the possible index tracking policies.
Hold the persistent representation for a ViewVector.
std::atomic< CLID > ClassID_traits< ViewVector< DV > >::s_clid
Definition ViewVector.h:337
std::atomic< const char * > ClassID_traits< ViewVector< DV > >::s_name
Definition ViewVector.h:339
Hold the persistent representation for a ViewVector.
Identify view containers to be made persistent.
Definition ViewVector.h:67
void registerBaseInit()
Helper to ensure that the inheritance information for this class gets initialized.
std::vector< ElementLink< DV > > Pers_t
The old persistent form of this class.
Definition ViewVector.h:91
ViewVector(const ViewVector &)=default
Use the compiler-generated copy constructor.
ViewVector(std::initializer_list< value_type > l)
Constructor from an initializer list.
DV::const_pointer const_pointer
Definition ViewVector.h:83
static constexpr bool must_own
Definition ViewVector.h:88
void clear(SG::OwnershipPolicy ownPolicy, SG::IndexTrackingPolicy trackIndices)
virtual void toTransient() override
Convert the vector to transient form.
DV::reference reference
Definition ViewVector.h:80
void clear(SG::OwnershipPolicy ownPolicy)
ViewVector(DV &&rhs)
Move constructor from base vector.
ViewVector(InputIterator first, InputIterator last)
Constructor from iterators.
DV::const_reverse_iterator const_reverse_iterator
Definition ViewVector.h:77
DV::unique_type unique_type
Definition ViewVector.h:84
ViewVector(const DV &rhs)
Constructor from base vector.
virtual void toPersistent() override
Convert the vector to persistent form.
DV::size_type size_type
Basic types, forwarded from the base.
Definition ViewVector.h:70
DV::const_reference const_reference
Definition ViewVector.h:81
DV::value_type value_type
Definition ViewVector.h:78
DV::base_value_type base_value_type
Definition ViewVector.h:73
DV::const_value_type const_value_type
Definition ViewVector.h:79
DV::difference_type difference_type
Definition ViewVector.h:71
ViewVector(ViewVector &&rhs)
Move constructor.
DV::DVL_BASE DVL_BASE
Definition ViewVector.h:75
DV::const_iterator const_iterator
Definition ViewVector.h:76
DV::allocator_type allocator_type
Definition ViewVector.h:72
DV::BaseContainer BaseContainer
Definition ViewVector.h:74
ViewVector & operator=(const ViewVector &rhs)=default
Can use compiler-generated assignment op.
ViewVector(SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
Default constructor.
ViewVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
Sized constructor.
DV::pointer pointer
Definition ViewVector.h:82
Forward declaration.
OwnershipPolicy
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
void throwExcMissingViewVectorCLID(const std::type_info &ti)
Throw a SG::ExcMissingViewVectorCLID exception.
static std::atomic< CLID > s_clid
Definition ViewVector.h:332
static const char * typeNameString()
Definition ViewVector.h:309
static std::atomic< const char * > s_name
Definition ViewVector.h:333
static const std::type_info & typeInfo()
Definition ViewVector.h:317
static const std::string & typeName()
Definition ViewVector.h:314
static bool init(CLID clid, const char *name)
Definition ViewVector.h:323
Default, invalid implementation of ClassID_traits.
Represent a list of base classes.
Definition Bases.h:79
Traits class to hold derivation information.
Definition Bases.h:115