ATLAS Offline Software
Classes | Namespaces | Functions
DataVectorWithAlloc.h File Reference

DataVector using a custom allocator for the elements. More...

#include "AthAllocators/ArenaHeapSTLAllocator.h"
#include "AthAllocators/maybeUnprotect.h"
#include "AthContainers/DataVector.h"
#include "AthContainers/DataVectorWithAllocFwd.h"
#include "AthenaKernel/ClassID_traits.h"
#include "AthContainers/DataVectorWithAlloc.icc"
Include dependency graph for DataVectorWithAlloc.h:

Go to the source code of this file.

Classes

class  DataVectorWithAlloc< DV, ALLOC >
 DataVector using a custom allocator for the elements. More...
 
class  DataVectorWithAlloc< DV, ALLOC >::UPDeleter
 Internal helper to serve as a deleter for our unique_ptr class. More...
 
class  DataVectorWithAlloc< DV, ALLOC >::Ptr
 unique_ptr holding an element for this vector. More...
 
class  DataVectorWithAlloc< DV, ALLOC >::ContainerUniquePtr
 Helper for unique_ptr conversions. More...
 
class  DataVectorWithAlloc< DV, ALLOC >::HeapDeleter
 Internal helper to delete vector elements. More...
 
struct  ClassID_traits< DataVectorWithAlloc< DV, ALLOC > >
 Specialize ClassID_traits for DataVectorWithAlloc so that they will be automatically made const when recorded in StoreGate. More...
 
class  SG::DVLDataVectorWithAllocBucket< DV, ALLOC >
 DataBucket class for DataVectorWithAlloc. More...
 
struct  SG::DataBucketTrait< DataVectorWithAlloc< DV, ALLOC >, U >
 Metafunction to find the proper DataBucket class for the first template argument. More...
 
class  SG::BaseInfo< DataVectorWithAlloc< DV, ALLOC > >
 Let the BaseInfo for DataVectorWithAlloc forward to that of the base DataVector. More...
 

Namespaces

 SG
 Forward declaration.
 

Functions

template<class DV , class ALLOC >
void swap (DataVectorWithAlloc< DV, ALLOC > &a, DataVectorWithAlloc< DV, ALLOC > &b)
 See DataVector<T, BASE>::swap(). More...
 

Detailed Description

DataVector using a custom allocator for the elements.

Author
scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
Date
Aug, 2021 This is a DataVector that uses a custom allocator to for the elements of the vector. The DataVectorWithAlloc type takes the allocator type as a second template argument. Something satisfying the STL allocator interface should work, as should the Arena*STLAllocator types from AthAllocators. If the second argument is defaulted, then AthenaHeapSTLAllocator is used.

The main difference in usage from an ordinary DataVector is that you need to allocate elements with the allocate() method, rather than using new. This will return a unique_ptr-like type Ptr, which should then be passed to the methods adding an element to the container

Vec v ...;
v.push_back (v.allocate());
Vec::Ptr p = v.allocate (123);
v[0] = std::move (p);

Similarly to ConstDataVector, the DataVector methods that take bare pointers are hidden via private inheritance, and the first template argument is the base DataVector type, or something deriving from it. A DataVectorWithAlloc<DV> may be converted to a const DV using asDataVector, or by recording it in StoreGate. Once recorded, it may be retrieved as a const DV, and it will also act as this for purposes of I/O.

It may be interesting to use the protect() methods of the AthAllocators classes to write-protect the contents of the vector. If that is done, the memory will automatically be unprotected when the vector is destroyed. For this to work, of course, the contents must be really immutable, not just const.

Definition in file DataVectorWithAlloc.h.

Function Documentation

◆ swap()

template<class DV , class ALLOC >
void swap ( DataVectorWithAlloc< DV, ALLOC > &  a,
DataVectorWithAlloc< DV, ALLOC > &  b 
)

See DataVector<T, BASE>::swap().

Definition at line 784 of file DataVectorWithAlloc.h.

785 {
786  a.swap (b);
787 }
DataVectorWithAlloc
DataVector using a custom allocator for the elements.
Definition: DataVectorWithAlloc.h:67
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
python.PyAthena.v
v
Definition: PyAthena.py:154
a
TList * a
Definition: liststreamerinfos.cxx:10