ATLAS Offline Software
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-2021 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef ATHCONTAINERS_VIEWVECTOR_H
14 #define ATHCONTAINERS_VIEWVECTOR_H
15 
16 
21 #include "AthLinks/ElementLink.h"
22 #include <atomic>
23 
24 
64 template <class DV>
66  : public DV, public SG::ViewVectorBase
67 {
68 public:
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 
202  ViewVector& operator= (DV&& rhs);
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 
253 private:
257 };
258 
259 
260 #ifndef XAOD_STANDALONE
261 #include "AthenaKernel/BaseInfo.h"
262 namespace SG {
263 
264 
266 template<class DV>
267 struct Bases<ViewVector<DV> > {
269 };
270 
271 
272 }
273 #endif
274 
275 
277 
278 
279 #ifndef XAOD_STANDALONE
280 
297 template <class DV>
299 {
300  static const bool s_isDataObject = false;
301  typedef std::integral_constant<bool, s_isDataObject> is_DataObject_tag;
302  typedef std::true_type has_classID_tag;
303 
304  static const CLID& ID() {
305  if (s_clid == CLID_NULL)
307  static const CLID clid = s_clid;
308  return clid;
309  }
310  static const char* typeNameString() {
311  if (s_name == nullptr)
313  return s_name;
314  }
315  static const std::string& typeName() {
316  static const std::string name = typeNameString(); return name;
317  }
318  static const std::type_info& typeInfo() {
319  return typeid (ViewVector<DV>);
320  }
321  typedef std::false_type has_version_tag;
322  static const bool s_isConst = false;
323 
324  static bool init (CLID clid, const char* name)
325  {
326  if (s_clid == CLID_NULL) {
327  s_clid = clid;
328  s_name = name;
329  }
330  return true;
331  }
332 private:
333  static std::atomic<CLID> s_clid;
334  static std::atomic<const char*> s_name;
335 };
336 
337 template <class DV>
338 std::atomic<CLID> ClassID_traits< ViewVector<DV> >::s_clid { CLID_NULL };
339 template <class DV>
340 std::atomic<const char*> ClassID_traits< ViewVector<DV> >::s_name { nullptr };
341 #endif // not XAOD_STANDALONE
342 
343 
344 #ifdef XAOD_STANDALONE
345 
346 // FIXME: xAOD has its own, incompatible, CLASS_DEF, but we don't want to use it
347 // due to dependency issues. Probably need to move things around
348 // a bit to resolve this.
349 #define VIEWVECTOR_CLASS_DEF(NAME, CID)
350 
351 #else
352 
356 #define VIEWVECTOR_CLASS_DEF(NAME, CID) \
357  [[maybe_unused]] \
358  static const bool clidinit_##CID = ClassID_traits<NAME>::init (CID, #NAME); \
359  CLIDREGISTRY_ADDENTRY(CID, NAME)
360 #endif
361 
362 
363 #endif // not ATHCONTAINERS_VIEWVECTOR_H
364 
ViewVector::ViewVector
ViewVector(const DV &rhs)
Constructor from base vector.
ClassID_traits< ViewVector< DV > >::typeName
static const std::string & typeName()
Definition: ViewVector.h:315
ViewVector::const_value_type
DV::const_value_type const_value_type
Definition: ViewVector.h:79
ClassID_traits::s_isConst
static const bool s_isConst
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:74
ViewVector::operator=
ViewVector & operator=(const ViewVector &rhs)=default
Can use compiler-generated assignment op.
ViewVector::ViewVector
ViewVector(SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
Default constructor.
ClassID_traits< ViewVector< DV > >::typeInfo
static const std::type_info & typeInfo()
Definition: ViewVector.h:318
ViewVector::must_own
static constexpr bool must_own
If true, then this type must own its contents.
Definition: ViewVector.h:88
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
IndexTrackingPolicy.h
Describes the possible index tracking policies.
ViewVector::ViewVector
ViewVector(std::initializer_list< value_type > l)
Constructor from an initializer list.
ClassID_traits< ViewVector< DV > >::s_clid
static std::atomic< CLID > s_clid
Definition: ViewVector.h:333
ViewVector::ViewVector
ViewVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
Sized constructor.
exceptions.h
Exceptions that can be thrown from AthContainers.
ClassID_traits< ViewVector< DV > >::typeNameString
static const char * typeNameString()
Definition: ViewVector.h:310
ViewVector::ViewVector
ViewVector(DV &&rhs)
Move constructor from base vector.
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
ViewVector::value_type
DV::value_type value_type
Definition: ViewVector.h:78
ClassID_traits< ViewVector< DV > >::is_DataObject_tag
std::integral_constant< bool, s_isDataObject > is_DataObject_tag
Definition: ViewVector.h:301
ClassID_traits< ViewVector< DV > >::init
static bool init(CLID clid, const char *name)
Definition: ViewVector.h:324
ViewVector::ViewVector
ViewVector(const ViewVector &)=default
Use the compiler-generated copy constructor.
ClassID_traits< ViewVector< DV > >::has_version_tag
std::false_type has_version_tag
Definition: ViewVector.h:321
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
ClassID_traits< ViewVector< DV > >::ID
static const CLID & ID()
Definition: ViewVector.h:304
ViewVector::base_value_type
DV::base_value_type base_value_type
Definition: ViewVector.h:73
ViewVector::toPersistent
virtual void toPersistent() override
Convert the vector to persistent form.
ViewVector::pointer
DV::pointer pointer
Definition: ViewVector.h:82
BaseInfo.h
Provide an interface for finding inheritance information at run time.
beamspotman.n
n
Definition: beamspotman.py:731
ViewVector
Identify view containers to be made persistent.
Definition: ViewVector.h:67
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
SG::Bases
Traits class to hold derivation information.
Definition: Bases.h:110
ViewVector::const_iterator
DV::const_iterator const_iterator
Definition: ViewVector.h:76
ViewVector::ViewVector
ViewVector(InputIterator first, InputIterator last)
Constructor from iterators.
ViewVector::reference
DV::reference reference
Definition: ViewVector.h:80
ViewVector::unique_type
DV::unique_type unique_type
Definition: ViewVector.h:84
OwnershipPolicy.h
ViewVector::size_type
DV::size_type size_type
Basic types, forwarded from the base.
Definition: ViewVector.h:70
ViewVector::BaseContainer
DV::BaseContainer BaseContainer
Definition: ViewVector.h:74
SG::ViewVectorBase
Hold the persistent representation for a ViewVector.
Definition: ViewVectorBase.h:38
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ViewVector::toTransient
virtual void toTransient() override
Convert the vector to transient form.
ClassID_traits< ViewVector< DV > >::s_name
static std::atomic< const char * > s_name
Definition: ViewVector.h:334
ViewVector::Pers_t
std::vector< ElementLink< DV > > Pers_t
The old persistent form of this class.
Definition: ViewVector.h:91
ViewVector::allocator_type
DV::allocator_type allocator_type
Definition: ViewVector.h:72
SG::throwExcMissingViewVectorCLID
void throwExcMissingViewVectorCLID(const std::type_info &ti)
Throw a SG::ExcMissingViewVectorCLID exception.
Definition: Control/AthContainers/Root/exceptions.cxx:425
ViewVector.icc
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ViewVector::clear
void clear(SG::OwnershipPolicy ownPolicy)
ClassID_traits::s_isDataObject
static const bool s_isDataObject
flags whether T inherits from DataObject
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:44
ViewVector::difference_type
DV::difference_type difference_type
Definition: ViewVector.h:71
ViewVector::DVL_BASE
DV::DVL_BASE DVL_BASE
Definition: ViewVector.h:75
ViewVector::const_reverse_iterator
DV::const_reverse_iterator const_reverse_iterator
Definition: ViewVector.h:77
ClassID_traits< ViewVector< DV > >::has_classID_tag
std::true_type has_classID_tag
Definition: ViewVector.h:302
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
DeMoScan.first
bool first
Definition: DeMoScan.py:534
dq_make_web_display.reference
reference
Definition: dq_make_web_display.py:44
ViewVector::const_reference
DV::const_reference const_reference
Definition: ViewVector.h:81
ViewVector::registerBaseInit
void registerBaseInit()
Helper to ensure that the inheritance information for this class gets initialized.
SG::IndexTrackingPolicy
IndexTrackingPolicy
Definition: IndexTrackingPolicy.h:37
xAOD::BaseContainer
DataVector< SG::AuxElement > BaseContainer
Definition: BaseContainer.h:7
ViewVectorBase.h
Hold the persistent representation for a ViewVector.
ViewVector::clear
void clear(SG::OwnershipPolicy ownPolicy, SG::IndexTrackingPolicy trackIndices)
ViewVector::ViewVector
ViewVector(ViewVector &&rhs)
Move constructor.
SG::BaseList
Represent a list of base classes.
Definition: Bases.h:74
ViewVector::const_pointer
DV::const_pointer const_pointer
Definition: ViewVector.h:83