ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
DataModel_detail::ElementProxy< DVL > Class Template Reference

Proxy for lvalue access to DataVector/DataList elements. More...

#include <ElementProxy.h>

Collaboration diagram for DataModel_detail::ElementProxy< DVL >:

Public Types

typedef ROOT::Meta::Selection::DataModel_detail::ElementProxy< DVL >::self self
 

Public Member Functions

 ElementProxy (typename DVL::BaseContainer::iterator i, DVL *container)
 Constructor. More...
 
 ElementProxy (const ElementProxy &)=default
 Default copy. More...
 
ElementProxyoperator= (const ElementProxy &rhs)
 Assignment operator, from an Element proxy. More...
 
 operator= (typename DVL::value_type rhs)
 Assignment operator, from a pointer. More...
 
ElementProxyoperator= (typename DVL::unique_type rhs)
 Assignment operator, from a unique_ptr. More...
 
 operator typename DVL::value_type const () const
 Conversion to a (const) pointer. More...
 
DVL::value_type const operator-> () const
 Conversion to a (const) pointer. More...
 
DVL * container ()
 Return the container holding the element that this object proxies. More...
 
const DVL * container () const
 Return the container holding the element that this object proxies. More...
 

Private Attributes

DVL::BaseContainer::iterator m_proxied
 Iterator pointing at the proxied element. More...
 
DVL * m_container
 The container that it references. More...
 

Detailed Description

template<class DVL>
class DataModel_detail::ElementProxy< DVL >

Proxy for lvalue access to DataVector/DataList elements.

We need to be careful with lvalue references to DataVector/List elements. If the DataVector/List owns its elements, then if we write into the DataVector/List via an lvalue, the old element should be deleted (and the DataVector/List then takes ownership of the new value). We implement this by having the lvalue references return a proxy object rather than a raw reference. The proxy handles ownership issues. To do this, the proxy stores a pointer to the original container.

When inheritance is used with DataVector/List, we have the additional restriction that we can only write into the DataVector/List using the most-derived DataVector/List class. We also need to enforce that in ElementProxy when there's an attempt to write via an lvalue. We can also get this information from the original container.

Definition at line 53 of file ElementProxy.h.

Member Typedef Documentation

◆ self

Definition at line 143 of file ElementProxy.h.

Constructor & Destructor Documentation

◆ ElementProxy() [1/2]

template<class DVL >
DataModel_detail::ElementProxy< DVL >::ElementProxy ( typename DVL::BaseContainer::iterator  i,
DVL *  container 
)

Constructor.

Parameters
iThe underlying container iterator pointing at the element which we're proxying.
containerThe container that the iterator references.

◆ ElementProxy() [2/2]

template<class DVL >
DataModel_detail::ElementProxy< DVL >::ElementProxy ( const ElementProxy< DVL > &  )
default

Default copy.

Member Function Documentation

◆ container() [1/2]

template<class DVL >
DVL* DataModel_detail::ElementProxy< DVL >::container ( )

Return the container holding the element that this object proxies.

◆ container() [2/2]

template<class DVL >
const DVL* DataModel_detail::ElementProxy< DVL >::container ( ) const

Return the container holding the element that this object proxies.

◆ operator typename DVL::value_type const()

template<class DVL >
DataModel_detail::ElementProxy< DVL >::operator typename DVL::value_type const ( ) const

Conversion to a (const) pointer.

We just need to do a cast here.

◆ operator->()

template<class DVL >
DVL::value_type const DataModel_detail::ElementProxy< DVL >::operator-> ( ) const

Conversion to a (const) pointer.

We just need to do a cast here.

◆ operator=() [1/3]

template<class DVL >
ElementProxy& DataModel_detail::ElementProxy< DVL >::operator= ( const ElementProxy< DVL > &  rhs)

Assignment operator, from an Element proxy.

Parameters
rhsThe proxy from which we're assigning.

If rhs is the same as the element we're proxying, then we don't need to do anything. Otherwise, can_insert must be true. If the parent DataVector/List owns its elements, we then need to delete the proxied object before making the assignment. We also disallow copying between two DataVector/List's, both of which own their elements.

◆ operator=() [2/3]

template<class DVL >
ElementProxy& DataModel_detail::ElementProxy< DVL >::operator= ( typename DVL::unique_type  rhs)

Assignment operator, from a unique_ptr.

Parameters
rhsThe pointer from which we're assigning.

If rhs is the same as the element we're proxying, then we don't need to do anything. Otherwise, can_insert must be true. The container must own its elements in order to use this interface.

◆ operator=() [3/3]

template<class DVL >
DataModel_detail::ElementProxy< DVL >::operator= ( typename DVL::value_type  rhs)

Assignment operator, from a pointer.

Parameters
rhsThe pointer from which we're assigning.

If rhs is the same as the element we're proxying, then we don't need to do anything. Otherwise, can_insert must be true. If the parent DataVector/List owns its elements, we then need to delete the proxied object before making the assignment.

Member Data Documentation

◆ m_container

template<class DVL >
DVL* DataModel_detail::ElementProxy< DVL >::m_container
private

The container that it references.

Definition at line 151 of file ElementProxy.h.

◆ m_proxied

template<class DVL >
DVL::BaseContainer::iterator DataModel_detail::ElementProxy< DVL >::m_proxied
private

Iterator pointing at the proxied element.

Definition at line 148 of file ElementProxy.h.


The documentation for this class was generated from the following file: