ATLAS Offline Software
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
ViewVector< DV > Class Template Reference

Identify view containers to be made persistent. More...

#include <ViewVector.h>

Inheritance diagram for ViewVector< DV >:
Collaboration diagram for ViewVector< DV >:

Public Types

typedef DV::size_type size_type
 Basic types, forwarded from the base. More...
 
typedef DV::difference_type difference_type
 
typedef DV::allocator_type allocator_type
 
typedef DV::base_value_type base_value_type
 
typedef DV::BaseContainer BaseContainer
 
typedef DV::DVL_BASE DVL_BASE
 
typedef DV::const_iterator const_iterator
 
typedef DV::const_reverse_iterator const_reverse_iterator
 
typedef DV::value_type value_type
 
typedef DV::const_value_type const_value_type
 
typedef DV::reference reference
 
typedef DV::const_reference const_reference
 
typedef DV::pointer pointer
 
typedef DV::const_pointer const_pointer
 
typedef DV::unique_type unique_type
 
typedef std::vector< ElementLink< DV > > Pers_t
 The old persistent form of this class. More...
 

Public Member Functions

void clearPersistent ()
 Clear the persistent data. More...
 
void setClearOnPersistent ()
 Set a flag to declare that the vector should be cleared on the next call to toPersistent(). More...
 

Static Public Attributes

static constexpr bool must_own = DV::must_own
 If true, then this type must own its contents. More...
 

Protected Member Functions

template<class DV >
void doToPersistent1 (DV &v, const std::true_type &)
 Convert to persistent form. More...
 
template<class DV >
void doToPersistent1 (DV &, const std::false_type &)
 Convert to persistent form. More...
 
template<class DV >
void doToPersistent (DV &v)
 Convert to persistent form. More...
 
template<class DV >
void doToTransient2 (DV &v, const std::true_type &)
 Convert to transient form. More...
 
template<class DV >
void doToTransient2 (DV &, const std::false_type &)
 Convert to transient form. More...
 
template<class DV >
void doToTransient1 (DV &v, const std::true_type &)
 Convert to persistent form. More...
 
template<class DV >
void doToTransient1 (DV &, const std::false_type &)
 Convert to transient form. More...
 
template<class DV >
void doToTransient (DV &v)
 Convert to persistent form. More...
 

Private Attributes

std::vector< sgkey_t > m_persKey
 The persistent form. (sgkey, index) More...
 
std::vector< unsigned int > m_persIndex
 
bool m_clearOnPersistent = false
 If true, the vector should be cleared when doPersistent is called. More...
 

Constructors, destructors, assignment.

 ViewVector (SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
 Default constructor. More...
 
 ViewVector (size_type n, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
 Sized constructor. More...
 
template<class InputIterator >
 ViewVector (InputIterator first, InputIterator last)
 Constructor from iterators. More...
 
 ViewVector (const ViewVector &)=default
 Use the compiler-generated copy constructor. More...
 
 ViewVector (ViewVector &&rhs)
 Move constructor. More...
 
 ViewVector (const DV &rhs)
 Constructor from base vector. More...
 
 ViewVector (DV &&rhs)
 Move constructor from base vector. More...
 
 ViewVector (std::initializer_list< value_type > l)
 Constructor from an initializer list. More...
 
ViewVectoroperator= (const ViewVector &rhs)=default
 Can use compiler-generated assignment op. More...
 
ViewVectoroperator= (const DV &rhs)
 Assignment operator. More...
 
ViewVectoroperator= (ViewVector &&rhs)
 Move assignment. More...
 
ViewVectoroperator= (DV &&rhs)
 Move assignment from base vector. More...
 
ViewVectoroperator= (std::initializer_list< value_type > l)
 Assignment operator, from an initializer list. More...
 
void clear (SG::OwnershipPolicy ownPolicy)
 
void clear (SG::OwnershipPolicy ownPolicy, SG::IndexTrackingPolicy trackIndices)
 
virtual void toPersistent () override
 Convert the vector to persistent form. More...
 
virtual void toTransient () override
 Convert the vector to transient form. More...
 
void registerBaseInit ()
 Helper to ensure that the inheritance information for this class gets initialized. More...
 

Detailed Description

template<class DV>
class ViewVector< DV >

Identify view containers to be made persistent.

This is a variant of DataVector that can only be constructed as a view vector. This class also holds the persistent representation of the view vector, which is logically equivalent to a std::vector<ElementLink<DV> > (but stored as vector of pairs of integers).

The template parameter DV is the DataVector on which the view is based. ViewVector<DV> acts just like DV except that it will throw an exception if you try to construct it as an owning container. (The ownership mode arguments cannot really be removed from the methods completely, otherwise ConstDataVector<ViewVector<DV> > wouldn't compile.)

To make a ViewVector<DV> object persistent:

Definition at line 65 of file ViewVector.h.

Member Typedef Documentation

◆ allocator_type

template<class DV >
typedef DV::allocator_type ViewVector< DV >::allocator_type

Definition at line 72 of file ViewVector.h.

◆ base_value_type

template<class DV >
typedef DV::base_value_type ViewVector< DV >::base_value_type

Definition at line 73 of file ViewVector.h.

◆ BaseContainer

template<class DV >
typedef DV::BaseContainer ViewVector< DV >::BaseContainer

Definition at line 74 of file ViewVector.h.

◆ const_iterator

template<class DV >
typedef DV::const_iterator ViewVector< DV >::const_iterator

Definition at line 76 of file ViewVector.h.

◆ const_pointer

template<class DV >
typedef DV::const_pointer ViewVector< DV >::const_pointer

Definition at line 83 of file ViewVector.h.

◆ const_reference

template<class DV >
typedef DV::const_reference ViewVector< DV >::const_reference

Definition at line 81 of file ViewVector.h.

◆ const_reverse_iterator

template<class DV >
typedef DV::const_reverse_iterator ViewVector< DV >::const_reverse_iterator

Definition at line 77 of file ViewVector.h.

◆ const_value_type

template<class DV >
typedef DV::const_value_type ViewVector< DV >::const_value_type

Definition at line 79 of file ViewVector.h.

◆ difference_type

template<class DV >
typedef DV::difference_type ViewVector< DV >::difference_type

Definition at line 71 of file ViewVector.h.

◆ DVL_BASE

template<class DV >
typedef DV::DVL_BASE ViewVector< DV >::DVL_BASE

Definition at line 75 of file ViewVector.h.

◆ Pers_t

template<class DV >
typedef std::vector<ElementLink<DV> > ViewVector< DV >::Pers_t

The old persistent form of this class.

Definition at line 91 of file ViewVector.h.

◆ pointer

template<class DV >
typedef DV::pointer ViewVector< DV >::pointer

Definition at line 82 of file ViewVector.h.

◆ reference

template<class DV >
typedef DV::reference ViewVector< DV >::reference

Definition at line 80 of file ViewVector.h.

◆ size_type

template<class DV >
typedef DV::size_type ViewVector< DV >::size_type

Basic types, forwarded from the base.

Definition at line 70 of file ViewVector.h.

◆ unique_type

template<class DV >
typedef DV::unique_type ViewVector< DV >::unique_type

Definition at line 84 of file ViewVector.h.

◆ value_type

template<class DV >
typedef DV::value_type ViewVector< DV >::value_type

Definition at line 78 of file ViewVector.h.

Constructor & Destructor Documentation

◆ ViewVector() [1/8]

template<class DV >
ViewVector< DV >::ViewVector ( SG::OwnershipPolicy  ownPolicy = SG::VIEW_ELEMENTS)
explicit

Default constructor.

Parameters
ownPolicyThe ownership mode for the container. Must be SG::VIEW_ELEMENTS. (Argument present only for interface compatibility.)

◆ ViewVector() [2/8]

template<class DV >
ViewVector< DV >::ViewVector ( size_type  n,
SG::OwnershipPolicy  ownPolicy = SG::VIEW_ELEMENTS 
)
explicit

Sized constructor.

Parameters
nThe size of the container.
ownPolicyThe ownership mode for the container. Must be SG::VIEW_ELEMENTS. (Argument present only for interface compatibility.)

Note that unlike the standard vector constructor, you can't specify an initial value here. The container will be initialized with 0's.

◆ ViewVector() [3/8]

template<class DV >
template<class InputIterator >
ViewVector< DV >::ViewVector ( InputIterator  first,
InputIterator  last 
)

Constructor from iterators.

Parameters
firstThe start of the range to put in the new container.
lastThe end of the range to put in the new container.

◆ ViewVector() [4/8]

template<class DV >
ViewVector< DV >::ViewVector ( const ViewVector< DV > &  )
default

Use the compiler-generated copy constructor.

◆ ViewVector() [5/8]

template<class DV >
ViewVector< DV >::ViewVector ( ViewVector< DV > &&  rhs)

Move constructor.

Parameters
rhsThe container from which to move.

Any auxiliary data will be moved along with the container contents.

◆ ViewVector() [6/8]

template<class DV >
ViewVector< DV >::ViewVector ( const DV &  rhs)

Constructor from base vector.

Parameters
rhsThe container from which to copy.

◆ ViewVector() [7/8]

template<class DV >
ViewVector< DV >::ViewVector ( DV &&  rhs)

Move constructor from base vector.

Parameters
rhsThe container from which to copy. Must be a view container.

Any auxiliary data will be moved along with the container contents.

◆ ViewVector() [8/8]

template<class DV >
ViewVector< DV >::ViewVector ( std::initializer_list< value_type l)

Constructor from an initializer list.

Parameters
lAn initializer list.

Member Function Documentation

◆ clear() [1/2]

template<class DV >
void ViewVector< DV >::clear ( SG::OwnershipPolicy  ownPolicy)

◆ clear() [2/2]

template<class DV >
void ViewVector< DV >::clear ( SG::OwnershipPolicy  ownPolicy,
SG::IndexTrackingPolicy  trackIndices 
)

◆ clearPersistent()

void SG::ViewVectorBase::clearPersistent ( )
inherited

Clear the persistent data.

◆ doToPersistent()

template<class DV >
void SG::ViewVectorBase::doToPersistent ( DV &  v)
protectedinherited

Convert to persistent form.

Parameters
vThe vector to convert.

This will abort if called for a class with no CLID.

◆ doToPersistent1() [1/2]

template<class DV >
void SG::ViewVectorBase::doToPersistent1 ( DV &  ,
const std::false_type &   
)
protectedinherited

Convert to persistent form.

Parameters
vThe vector to convert.

Called for classes that do not have a CLID. This will simply abort.

◆ doToPersistent1() [2/2]

template<class DV >
void SG::ViewVectorBase::doToPersistent1 ( DV &  v,
const std::true_type &   
)
protectedinherited

Convert to persistent form.

Parameters
vThe vector to convert.

Called for classes that have a CLID.

◆ doToTransient()

template<class DV >
void SG::ViewVectorBase::doToTransient ( DV &  v)
inlineprotectedinherited

Convert to persistent form.

Parameters
vThe vector to convert.

Dispatch based on whether the class has a CLID.

Definition at line 157 of file ViewVectorBase.h.

158  {
159 #ifdef XAOD_STANDALONE
160  doToTransient1 (v, std::true_type());
161 #else
163 #endif
164  }

◆ doToTransient1() [1/2]

template<class DV >
void SG::ViewVectorBase::doToTransient1 ( DV &  ,
const std::false_type &   
)
inlineprotectedinherited

Convert to transient form.

Parameters
vThe vector to fill in.

Called for the case that DV doesn't have a CLID. A no-op.

This is also what will get called for the case of an older version of a schema-evolved vector.

Definition at line 147 of file ViewVectorBase.h.

147 {}

◆ doToTransient1() [2/2]

template<class DV >
void SG::ViewVectorBase::doToTransient1 ( DV &  v,
const std::true_type &   
)
inlineprotectedinherited

Convert to persistent form.

Parameters
vThe vector to convert.

Class has a CLID; dispatch based on whether DV is a ConstDataVector.

Definition at line 131 of file ViewVectorBase.h.

132  {
133  doToTransient2 (v, std::is_same<DV, typename DV::base_data_vector>());
134  }

◆ doToTransient2() [1/2]

template<class DV >
void SG::ViewVectorBase::doToTransient2 ( DV &  ,
const std::false_type &   
)
inlineprotectedinherited

Convert to transient form.

Parameters
vThe vector to fill in.

Called for the case that DV is not a ConstDataVector. A no-op.

Definition at line 121 of file ViewVectorBase.h.

121 {}

◆ doToTransient2() [2/2]

template<class DV >
void SG::ViewVectorBase::doToTransient2 ( DV &  v,
const std::true_type &   
)
protectedinherited

Convert to transient form.

Parameters
vThe vector to fill in.

Called for classes that have a CLID if DV is not a ConstDataVector.

◆ operator=() [1/5]

template<class DV >
ViewVector& ViewVector< DV >::operator= ( const DV &  rhs)

Assignment operator.

Parameters
rhsThe DataVector from which to assign.
Returns
This object.

This is a ‘shallow’ copy; after the completion of this, the DataVector will not own its elements. Any elements it owned prior to this call will be released.

Note: this method may only be called using the most derived DataVector in the hierarchy.

◆ operator=() [2/5]

template<class DV >
ViewVector& ViewVector< DV >::operator= ( const ViewVector< DV > &  rhs)
default

Can use compiler-generated assignment op.

◆ operator=() [3/5]

template<class DV >
ViewVector& ViewVector< DV >::operator= ( DV &&  rhs)

Move assignment from base vector.

Parameters
rhsThe container from which to move. Must be a view vector.

Any auxiliary data will be moved along with the container contents.

◆ operator=() [4/5]

template<class DV >
ViewVector& ViewVector< DV >::operator= ( std::initializer_list< value_type l)

Assignment operator, from an initializer list.

Parameters
lAn initializer list.
Returns
This object.

This is equivalent to assign.

◆ operator=() [5/5]

template<class DV >
ViewVector& ViewVector< DV >::operator= ( ViewVector< DV > &&  rhs)

Move assignment.

Parameters
rhsThe container from which to move.

Any auxiliary data will be moved along with the container contents.

◆ registerBaseInit()

template<class DV >
void ViewVector< DV >::registerBaseInit ( )
private

Helper to ensure that the inheritance information for this class gets initialized.

◆ setClearOnPersistent()

void SG::ViewVectorBase::setClearOnPersistent ( )
inherited

Set a flag to declare that the vector should be cleared on the next call to toPersistent().

This would be used in the case where we make a copy of the object being written.

◆ toPersistent()

template<class DV >
virtual void ViewVector< DV >::toPersistent ( )
overridevirtual

Convert the vector to persistent form.

Implements SG::ViewVectorBase.

◆ toTransient()

template<class DV >
virtual void ViewVector< DV >::toTransient ( )
overridevirtual

Convert the vector to transient form.

Implements SG::ViewVectorBase.

Member Data Documentation

◆ m_clearOnPersistent

bool SG::ViewVectorBase::m_clearOnPersistent = false
privateinherited

If true, the vector should be cleared when doPersistent is called.

Definition at line 176 of file ViewVectorBase.h.

◆ m_persIndex

std::vector<unsigned int> SG::ViewVectorBase::m_persIndex
privateinherited

Definition at line 173 of file ViewVectorBase.h.

◆ m_persKey

std::vector<sgkey_t> SG::ViewVectorBase::m_persKey
privateinherited

The persistent form. (sgkey, index)

Definition at line 172 of file ViewVectorBase.h.

◆ must_own

template<class DV >
constexpr bool ViewVector< DV >::must_own = DV::must_own
staticconstexpr

If true, then this type must own its contents.

Definition at line 88 of file ViewVector.h.


The documentation for this class was generated from the following file:
SG::ViewVectorBase::doToTransient1
void doToTransient1(DV &v, const std::true_type &)
Convert to persistent form.
Definition: ViewVectorBase.h:131
SG::ViewVectorBase::doToTransient2
void doToTransient2(DV &v, const std::true_type &)
Convert to transient form.
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
python.PyAthena.v
v
Definition: PyAthena.py:157