ATLAS Offline Software
AuxTypeVector.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-2024 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef ATHCONTAINERS_AUXTYPEVECTOR_H
14 #define ATHCONTAINERS_AUXTYPEVECTOR_H
15 
16 
21 #include <typeinfo>
22 #include <vector>
23 #include <algorithm>
24 #include <utility>
25 #include <stdint.h>
26 #include <type_traits>
27 
28 
29 namespace SG {
30 
31 
32 class AuxDataOption;
33 
34 
48 template <class T, class CONT>
50  : public IAuxTypeVector
51 {
52 public:
54  typedef CONT vector_type;
55 
58 
60  typedef typename vector_type::value_type vector_value_type;
61 
62 
63 protected:
66  static const int SCALE = sizeof(element_type) / sizeof(vector_value_type);
67 
68 
69 public:
77  AuxTypeVectorHolder (auxid_t auxid, vector_type* vecPtr, bool ownFlag,
78  bool isLinked);
79 
80 
86 
87 
93 
94 
100 
101 
106 
107 
112 
113 
118 
119 
123  virtual std::unique_ptr<IAuxTypeVector> clone() const override;
124 
125 
129  virtual void* toPtr() override;
130 
131 
135  virtual const void* toPtr() const override;
136 
137 
141  virtual void* toVector() override;
142 
143 
150  virtual const std::type_info* objType() const override;
151 
152 
156  virtual size_t size() const override;
157 
158 
166  virtual bool resize (size_t sz) override;
167 
168 
173  virtual void reserve (size_t sz) override;
174 
175 
184  virtual bool setOption (const AuxDataOption& option) override;
185 
186 
213  virtual bool shift (size_t pos, ptrdiff_t offs) override;
214 
215 
237  virtual bool insertMove (size_t pos, void* beg, void* end,
238  IAuxStore& srcStore) override;
239 
240 
250  virtual std::unique_ptr<IAuxTypeVector> toPacked() override;
251 
252 
253 private:
263  element_type* beg,
264  element_type* end,
265  std::true_type);
266 
267 
277  element_type* beg,
278  element_type* end,
279  std::false_type);
280 
283 
285  bool m_ownFlag;
286 };
287 
288 
289 //**********************************************************************
290 
291 
300 template <class HOLDER>
302  : public HOLDER
303 {
304 public:
305  using Base = HOLDER;
306  using vector_type = typename Base::vector_type;
307  using element_type = typename Base::element_type;
308  using vector_value_type = typename Base::vector_value_type;
309 
310 
318  AuxTypeVectorT (auxid_t auxid, size_t size, size_t capacity,
319  bool isLinked);
320 
321 
322 
327 
328 
333 
334 
339 
340 
345 
346 
350  virtual std::unique_ptr<IAuxTypeVector> clone() const override;
351 
352 
353 private:
356 };
357 
358 
360 template <class T,
361  class ALLOC = AuxAllocator_t<T>,
362  class CONT = typename AuxDataTraits<T, ALLOC>::vector_type>
364 
365 
366 
367 } // namespace SG
368 
369 
371 
372 
373 #endif // not ATHCONTAINERS_AUXTYPEVECTOR_H
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SG::AuxTypeVectorHolder::insertMove1
void insertMove1(typename CONT::iterator pos, element_type *beg, element_type *end, std::true_type)
Helper for insertMove.
SG::IAuxTypeVector::isLinked
bool isLinked() const
Return true if this variable is linked from another one.
Definition: IAuxTypeVector.h:221
SG::AuxTypeVectorHolder::vector_type
CONT vector_type
Type of the STL vector used for storage.
Definition: AuxTypeVector.h:54
PackedContainer.h
Container to hold aux data to be stored in a packed form.
fitman.sz
sz
Definition: fitman.py:527
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::AuxAllocator_t
std::allocator< T > AuxAllocator_t
The default allocator type to use for auxiliary variables.
Definition: AuxDataTraits.h:28
SG::AuxTypeVectorHolder::element_type
AuxDataTraits< T >::element_type element_type
Type that the user sees.
Definition: AuxTypeVector.h:57
SG::AuxTypeVectorHolder::toPacked
virtual std::unique_ptr< IAuxTypeVector > toPacked() override
Try to convert this aux vector to a PackedContainer.
SG::AuxTypeVectorT::Base
HOLDER Base
Definition: AuxTypeVector.h:305
SG::AuxTypeVectorT::clone
virtual std::unique_ptr< IAuxTypeVector > clone() const override
Make a copy of this vector.
SG::AuxTypeVectorHolder::AuxTypeVectorHolder
AuxTypeVectorHolder(const AuxTypeVectorHolder &other)
Copy constructor.
SG::AuxTypeVectorHolder::SCALE
static const int SCALE
1 for the usual case of V being vector<T>.
Definition: AuxTypeVector.h:66
SG::AuxTypeVectorHolder::operator=
AuxTypeVectorHolder & operator=(const AuxTypeVectorHolder &other)
Assignment.
AuxTypeVector.icc
SG::AuxTypeVectorHolder::size
virtual size_t size() const override
Return the size of the vector.
SG::AuxDataTraits::vector_type
std::vector< T, allocator_type > vector_type
Container type used to store this variable.
Definition: AuxDataTraits.h:53
SG::AuxTypeVectorHolder::toPtr
virtual const void * toPtr() const override
Return a pointer to the start of the vector's data.
SG::AuxTypeVectorHolder::insertMove
virtual bool insertMove(size_t pos, void *beg, void *end, IAuxStore &srcStore) override
Insert elements into the vector via move semantics.
IAuxTypeVector.h
Abstract interface for manipulating vectors of arbitrary types.
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
SG::AuxTypeVectorHolder::~AuxTypeVectorHolder
~AuxTypeVectorHolder()
Destructor.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::AuxTypeVectorT::AuxTypeVectorT
AuxTypeVectorT(AuxTypeVectorT &&other)
Move constructor.
SG::AuxTypeVectorT
Implementation of IAuxTypeVector holding a vector instance.
Definition: AuxTypeVector.h:303
SG::AuxTypeVectorT::AuxTypeVectorT
AuxTypeVectorT(auxid_t auxid, size_t size, size_t capacity, bool isLinked)
Constructor.
SG::AuxTypeVectorHolder::m_ownFlag
bool m_ownFlag
True if we need to delete the object.
Definition: AuxTypeVector.h:285
AuxDataTraits.h
Allow customizing how aux data types are treated.
SG::AuxTypeVectorHolder::m_vecPtr
vector_type * m_vecPtr
The contained vector.
Definition: AuxTypeVector.h:282
SG::AuxTypeVectorHolder::vector_value_type
vector_type::value_type vector_value_type
Vector element type.
Definition: AuxTypeVector.h:60
SG::AuxTypeVectorT::element_type
typename Base::element_type element_type
Definition: AuxTypeVector.h:307
SG::AuxDataOption
Hold information about an option setting request.
Definition: AuxDataOption.h:37
SG::AuxTypeVectorHolder::resize
virtual bool resize(size_t sz) override
Change the size of the vector.
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
SG::AuxDataTraits::element_type
T element_type
The type the user sees.
Definition: AuxDataTraits.h:43
SG::AuxTypeVectorHolder::insertMove1
void insertMove1(typename CONT::iterator pos, element_type *beg, element_type *end, std::false_type)
Helper for insertMove.
SG::AuxTypeVectorHolder::AuxTypeVectorHolder
AuxTypeVectorHolder(AuxTypeVectorHolder &&other)
Move constructor.
SG::IAuxTypeVector::auxid
auxid_t auxid() const
Return the auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:227
SG::AuxTypeVectorHolder::setOption
virtual bool setOption(const AuxDataOption &option) override
Make an option setting.
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
SG::AuxTypeVectorT::vector_value_type
typename Base::vector_value_type vector_value_type
Definition: AuxTypeVector.h:308
IAuxSetOption.h
Abstract interface for setting a option on a aux data container.
SG::AuxTypeVectorHolder::objType
virtual const std::type_info * objType() const override
Return the type of the payload object for this instance.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::AuxTypeVectorHolder::reserve
virtual void reserve(size_t sz) override
Change the capacity of the vector.
SG::AuxTypeVectorT::operator=
AuxTypeVectorT & operator=(const AuxTypeVectorT &other)
Assignment.
SG::AuxTypeVectorHolder::AuxTypeVectorHolder
AuxTypeVectorHolder(auxid_t auxid, vector_type *vecPtr, bool ownFlag, bool isLinked)
Constructor.
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:40
SG::AuxTypeVectorHolder::toVector
virtual void * toVector() override
Return a pointer to the STL vector itself.
SG::AuxTypeVectorHolder::toPtr
virtual void * toPtr() override
Return a pointer to the start of the vector's data.
SG::AuxTypeVectorT::AuxTypeVectorT
AuxTypeVectorT(const AuxTypeVectorT &other)
Copy constructor.
SG::AuxTypeVectorHolder::clone
virtual std::unique_ptr< IAuxTypeVector > clone() const override
Make a copy of this vector.
SG::AuxTypeVectorT::vector_type
typename Base::vector_type vector_type
Definition: AuxTypeVector.h:306
SG::AuxTypeVectorHolder
Implementation of IAuxTypeVector for specific types.
Definition: AuxTypeVector.h:51
SG::AuxTypeVectorHolder::vec
vector_type & vec()
Return a reference to the payload vector.
SG::AuxTypeVectorHolder::shift
virtual bool shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the vector.
SG::AuxTypeVectorT::m_vec
vector_type m_vec
The contained vector.
Definition: AuxTypeVector.h:355