ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
xAOD::AuxPersInfo< T > Class Template Reference

Class managing concrete persistent variables. More...

#include <AuxPersInfo.h>

Inheritance diagram for xAOD::AuxPersInfo< T >:
Collaboration diagram for xAOD::AuxPersInfo< T >:

Public Types

typedef T & info_type
 Convenience type definition. More...
 

Public Member Functions

 AuxPersInfo (SG::auxid_t auxid, info_type info, SG::IAuxStore *)
 Constructor. More...
 
virtual std::unique_ptr< SG::IAuxTypeVectorclone () const override
 Make a copy of this vector. More...
 
virtual void * toPtr () override
 Return a pointer to the start of the vector's data. More...
 
virtual const void * toPtr () const override
 Return a pointer to the start of the vector's data. More...
 
virtual void * toVector () override
 Return a pointer to the STL vector itself. More...
 
virtual size_t size () const override
 Return the size of the vector. More...
 
virtual bool resize (size_t sz) override
 Change the size of the vector. More...
 
virtual void reserve (size_t sz) override
 Change the capacity of the vector. More...
 
virtual bool shift (size_t, ptrdiff_t) override
 Shift the elements of the vector. More...
 
virtual bool insertMove (size_t, void *, size_t, size_t, SG::IAuxStore &) override
 Insert elements into the vector via move semantics. More...
 
virtual const std::type_info * objType () const override
 Return the type of the complete object to be saved. More...
 
virtual SG::AuxDataSpanBase getDataSpanImpl () const override final
 Return a span object describing the current vector. More...
 
virtual bool setOption (const AuxDataOption &)
 Set an option for this variable. More...
 
virtual std::unique_ptr< IAuxTypeVectortoPacked ()
 Make a packed version of the variable. More...
 
virtual std::unique_ptr< IAuxTypeVectorlinkedVector ()
 Return IAuxTypeVector of a linked variable, if there is one. More...
 
bool isLinked () const
 Return true if this variable is linked from another one. More...
 
auxid_t auxid () const
 Return the auxid of the variable this vector represents. More...
 
const AuxDataSpanBase & getDataSpan () const
 Return a reference to a description of this vector's start+size. More...
 

Protected Member Functions

void storeDataSpan (void *beg, size_t size)
 Update the stored span. More...
 
void resetDataSpan ()
 Invalidate the stored span. More...
 

Private Attributes

info_type m_info
 Reference to the info being handled. More...
 
auxid_t m_auxid
 The auxid of the variable this vector represents. More...
 
bool m_isLinked
 True if this variable is linked from another one. More...
 
CxxUtils::CachedValue< AuxDataSpanBase > m_span
 Description of the vector start+size. More...
 

Detailed Description

template<class T>
class xAOD::AuxPersInfo< T >

Class managing concrete persistent variables.

This class is used internally by the "special" auxiliary store objects to manage the auxiliary variables handled by them. User code probably doesn't want to touch it directly...

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Revision
793737
Date
2017-01-24 21:11:10 +0100 (Tue, 24 Jan 2017)

Definition at line 32 of file AuxPersInfo.h.

Member Typedef Documentation

◆ info_type

template<class T >
typedef T& xAOD::AuxPersInfo< T >::info_type

Convenience type definition.

Definition at line 36 of file AuxPersInfo.h.

Constructor & Destructor Documentation

◆ AuxPersInfo()

template<class T >
xAOD::AuxPersInfo< T >::AuxPersInfo ( SG::auxid_t  auxid,
info_type  info,
SG::IAuxStore  
)
inline

Constructor.

Definition at line 39 of file AuxPersInfo.h.

39  :
40  IAuxTypeVector( auxid, false ), m_info( info ) {}

Member Function Documentation

◆ auxid()

auxid_t SG::IAuxTypeVector::auxid ( ) const
inlineinherited

Return the auxid of the variable this vector represents.

Definition at line 232 of file IAuxTypeVector.h.

233  {
234  return m_auxid;
235  }

◆ clone()

template<class T >
virtual std::unique_ptr<SG::IAuxTypeVector> xAOD::AuxPersInfo< T >::clone ( ) const
inlineoverridevirtual

Make a copy of this vector.

Implements SG::IAuxTypeVector.

Definition at line 42 of file AuxPersInfo.h.

42  {
43  return std::make_unique<AuxPersInfo<T> >(*this);
44  }

◆ getDataSpan()

const AuxDataSpanBase& SG::IAuxTypeVector::getDataSpan ( ) const
inlineinherited

Return a reference to a description of this vector's start+size.

This returns a reference to an AuxDataSpanBase, which gives the start and size of the vector. This object will be updated if the vector changes.

For low overhead, we want this to be a non-virtual function call. However, for variables being read, the usage pattern is that we first create the @IAuxTypeVector object, give the underlying std::vector object to ROOT, and then ROOT fills the vector without the involvement of the IAuxTypeVector. To be able to have this work correctly, we need to defer initializing the span object until the first time that getDataSpan gets called. We do this with a CachedValue. If the span has already been initialized, we just return it; otherwise, we make a virtual call to fetch the vector from the derived class.

Be aware: this is in principle a const-correctness violation, since AuxDataSpanBase has a non-const pointer to the start of the vector. But doing it properly is kind of painful, and as this interface is only meant to be used internally, it's likely not a real problem.

Definition at line 261 of file IAuxTypeVector.h.

262  {
263  if (!m_span.isValid()) {
264  m_span.set (this->getDataSpanImpl());
265  }
266  return *m_span.ptr();
267  }

◆ getDataSpanImpl()

template<class T >
virtual SG::AuxDataSpanBase xAOD::AuxPersInfo< T >::getDataSpanImpl ( ) const
inlinefinaloverridevirtual

Return a span object describing the current vector.

Used to initialize m_span the first time that getDataSpan is called.

Implements SG::IAuxTypeVector.

Definition at line 86 of file AuxPersInfo.h.

87  {
88  void* beg ATLAS_THREAD_SAFE = &m_info;
89  return SG::AuxDataSpanBase( const_cast<void*> (beg), 1 );
90  }

◆ insertMove()

template<class T >
virtual bool xAOD::AuxPersInfo< T >::insertMove ( size_t  pos,
void *  src,
size_t  src_pos,
size_t  src_n,
SG::IAuxStore srcStore 
)
inlineoverridevirtual

Insert elements into the vector via move semantics.

Parameters
posThe starting index of the insertion.
srcStart of the vector containing the range of elements to insert.
src_posPosition of the first element to insert.
src_nNumber of elements to insert.
srcStoreThe source store.

beg and end define a range of container elements, with length len defined by the difference of the pointers divided by the element size.

The size of the container will be increased by len, with the elements starting at pos copied to pos+len.

The contents of the source range will then be moved to our vector starting at pos. This will be done via move semantics if possible; otherwise, it will be done with a copy.

Returns true if it is known that the vector's memory did not move, false otherwise.

Implements SG::IAuxTypeVector.

Definition at line 75 of file AuxPersInfo.h.

78  {
79  throw std::runtime_error( "Calling insertMove on a non-vector" );
80  }

◆ isLinked()

bool SG::IAuxTypeVector::isLinked ( ) const
inlineinherited

Return true if this variable is linked from another one.

This is inlined here rather than being a virtual function because this is frequently called from loops over auxids.

Definition at line 226 of file IAuxTypeVector.h.

226 { return m_isLinked; }

◆ linkedVector()

virtual std::unique_ptr<IAuxTypeVector> SG::IAuxTypeVector::linkedVector ( )
inlinevirtualinherited

Return IAuxTypeVector of a linked variable, if there is one.

If the variable represented by this vector has a linked variable, then return its IAuxTypeVector. Otherwise, return nullptr. Beware of potential threading issues: the returned object is not locked, so it should not be modified in contexts where the parent container cannot be modified.

This returns a unique_ptr, so it can generally be called only once on a given instance. After that, it will return nullptr.

Definition at line 217 of file IAuxTypeVector.h.

217 { return nullptr; }

◆ objType()

template<class T >
virtual const std::type_info* xAOD::AuxPersInfo< T >::objType ( ) const
inlineoverridevirtual

Return the type of the complete object to be saved.

For example, if the object is a std::vector, then we return the type_info of the vector. But if we're holding a PackedContainer, then we return the type_info of the PackedContainer.

Can return null if the operation is not supported. In that case, I/O will use the type found from the variable registry.

Reimplemented from SG::IAuxTypeVector.

Definition at line 82 of file AuxPersInfo.h.

82  {
83  return &typeid(T);
84  }

◆ reserve()

template<class T >
virtual void xAOD::AuxPersInfo< T >::reserve ( size_t  sz)
inlineoverridevirtual

Change the capacity of the vector.

Parameters
szThe new vector capacity.

Implements SG::IAuxTypeVector.

Definition at line 65 of file AuxPersInfo.h.

65  {
66  if( sz != 1 ) {
67  throw std::runtime_error( "Calling reserve with != 1 on a "
68  "non-vector" );
69  }
70  }

◆ resetDataSpan()

void SG::IAuxTypeVector::resetDataSpan ( )
inlineprotectedinherited

Invalidate the stored span.

Definition at line 297 of file IAuxTypeVector.h.

298  {
299  m_span.reset();
300  }

◆ resize()

template<class T >
virtual bool xAOD::AuxPersInfo< T >::resize ( size_t  sz)
inlineoverridevirtual

Change the size of the vector.

Parameters
szThe new vector size. Returns true if it is known that iterators have not been invalidated; false otherwise. (Will always return false when increasing the size of an empty container.)

Implements SG::IAuxTypeVector.

Definition at line 58 of file AuxPersInfo.h.

58  {
59  if( sz != 1 ) {
60  throw std::runtime_error( "Calling resize with != 1 on a "
61  "non-vector" );
62  }
63  return true;
64  }

◆ setOption()

virtual bool SG::IAuxTypeVector::setOption ( const AuxDataOption )
inlinevirtualinherited

◆ shift()

template<class T >
virtual bool xAOD::AuxPersInfo< T >::shift ( size_t  pos,
ptrdiff_t  offs 
)
inlineoverridevirtual

Shift the elements of the vector.

Parameters
posThe starting index for the shift.
offsThe (signed) amount of the shift.

This operation shifts the elements in the vectors for all aux data items, to implement an insertion or deletion. offs may be either positive or negative.

If offs is positive, then the container is growing. The container size should be increased by offs, the element at pos moved to pos + offs, and similarly for following elements. The elements between pos and pos + offs should be default-initialized.

If offs is negative, then the container is shrinking. The element at pos should be moved to pos + offs, and similarly for following elements. The container should then be shrunk by -offs elements (running destructors as appropriate).

Returns true if it is known that iterators have not been invalidated; false otherwise. (Will always return false when increasing the size of an empty container.)

Implements SG::IAuxTypeVector.

Definition at line 71 of file AuxPersInfo.h.

71  {
72  throw std::runtime_error( "Calling shift on a non-vector" );
73  }

◆ size()

template<class T >
virtual size_t xAOD::AuxPersInfo< T >::size ( ) const
inlineoverridevirtual

Return the size of the vector.

Implements SG::IAuxTypeVector.

Definition at line 55 of file AuxPersInfo.h.

55  {
56  return 1;
57  }

◆ storeDataSpan()

void SG::IAuxTypeVector::storeDataSpan ( void *  beg,
size_t  size 
)
inlineprotectedinherited

Update the stored span.

Parameters
begThe start of the vector.
sizeThe length of the vector.

Definition at line 284 of file IAuxTypeVector.h.

285  {
286  // Only do this if the span is already valid, so that it doesn't
287  // get marked valid before ROOT I/O.
288  if (m_span.isValid()) {
289  m_span.store (AuxDataSpanBase (beg, size));
290  }
291  }

◆ toPacked()

virtual std::unique_ptr<IAuxTypeVector> SG::IAuxTypeVector::toPacked ( )
inlinevirtualinherited

Make a packed version of the variable.

If possible, return a new vector object that stores the data in a PackedContainer. The data itself should be moved to the new container (so that this vector becomes empty). This ensures that pointers to the data are preserved.

If successful, a newly-allocated object is returned. A null pointer is returned on failure (operation not supported, type can't be packed, type is already packed).

Reimplemented in SG::AuxTypeVectorHolder< T, CONT >, SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< TARG >, AuxDataTraits< PackedLink< TARG >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< PackedLink< CONT >, AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type >, SG::AuxTypeVectorHolder< std::vector< SG::PackedLink< TARG >, VALLOC >, AuxDataTraits< std::vector< SG::PackedLink< TARG >, VALLOC >, VEC::allocator_type >::vector_type >, SG::AuxTypeVectorHolder< T, std::vector< T > >, SG::AuxTypeVectorHolder< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxDataTraits< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type, AuxAllocator_t< typename AuxDataTraits< PackedLink< CONT >, AuxAllocator_t< PackedLink< CONT > > >::vector_type > >::vector_type >, and SG::AuxTypeVectorHolder< JaggedVecElt< T >, AuxDataTraits< JaggedVecElt< T >, AuxAllocator_t< JaggedVecElt< T > > >::vector_type >.

Definition at line 188 of file IAuxTypeVector.h.

188 { return 0; }

◆ toPtr() [1/2]

template<class T >
virtual const void* xAOD::AuxPersInfo< T >::toPtr ( ) const
inlineoverridevirtual

Return a pointer to the start of the vector's data.

Implements SG::IAuxTypeVector.

Definition at line 49 of file AuxPersInfo.h.

49  {
50  return &m_info;
51  }

◆ toPtr() [2/2]

template<class T >
virtual void* xAOD::AuxPersInfo< T >::toPtr ( )
inlineoverridevirtual

Return a pointer to the start of the vector's data.

Implements SG::IAuxTypeVector.

Definition at line 46 of file AuxPersInfo.h.

46  {
47  return &m_info;
48  }

◆ toVector()

template<class T >
virtual void* xAOD::AuxPersInfo< T >::toVector ( )
inlineoverridevirtual

Return a pointer to the STL vector itself.

Implements SG::IAuxTypeVector.

Definition at line 52 of file AuxPersInfo.h.

52  {
53  return &m_info;
54  }

Member Data Documentation

◆ m_auxid

auxid_t SG::IAuxTypeVector::m_auxid
privateinherited

The auxid of the variable this vector represents.

Definition at line 305 of file IAuxTypeVector.h.

◆ m_info

template<class T >
info_type xAOD::AuxPersInfo< T >::m_info
private

Reference to the info being handled.

Definition at line 94 of file AuxPersInfo.h.

◆ m_isLinked

bool SG::IAuxTypeVector::m_isLinked
privateinherited

True if this variable is linked from another one.

Definition at line 308 of file IAuxTypeVector.h.

◆ m_span

CxxUtils::CachedValue<AuxDataSpanBase> SG::IAuxTypeVector::m_span
privateinherited

Description of the vector start+size.

Definition at line 311 of file IAuxTypeVector.h.


The documentation for this class was generated from the following file:
grepfile.info
info
Definition: grepfile.py:38
SG::IAuxTypeVector::m_span
CxxUtils::CachedValue< AuxDataSpanBase > m_span
Description of the vector start+size.
Definition: IAuxTypeVector.h:311
xAOD::AuxPersInfo::m_info
info_type m_info
Reference to the info being handled.
Definition: AuxPersInfo.h:94
fitman.sz
sz
Definition: fitman.py:527
SG::IAuxTypeVector::getDataSpanImpl
virtual AuxDataSpanBase getDataSpanImpl() const =0
Return a span object describing the current vector.
SG::IAuxTypeVector::IAuxTypeVector
IAuxTypeVector(auxid_t auxid, bool isLinked)
Constructor.
Definition: IAuxTypeVector.h:49
SG::AuxDataSpanBase
Minimal span-like object describing the range of an auxiliary variable.
Definition: AuxDataSpan.h:39
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
SG::IAuxTypeVector::auxid
auxid_t auxid() const
Return the auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:232
SG::IAuxTypeVector::m_auxid
auxid_t m_auxid
The auxid of the variable this vector represents.
Definition: IAuxTypeVector.h:305
SG::IAuxTypeVector::m_isLinked
bool m_isLinked
True if this variable is linked from another one.
Definition: IAuxTypeVector.h:308
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
SG::IAuxTypeVector::size
virtual size_t size() const =0
Return the size of the vector.
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35