DataModel_detail::ElementProxy< DVL > Class Template Reference

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

#include <ElementProxy.h>

List of all members.

Public Types

typedef
ROOT_SELECTION_NS::DataModel_detail::ElementProxy
< DVL >::self 
self
typedef ElementProxy< DVL > self

Public Member Functions

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

Public Attributes

ROOT_SELECTION_NS::MemberAttributes
< kTransient > 
m_proxied
ROOT_SELECTION_NS::MemberAttributes
< kTransient > 
m_container

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.


Constructor & Destructor Documentation

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

Constructor.

Parameters:
i The underlying container iterator pointing at the element which we're proxying.
container The container that the iterator references.

Member Function Documentation

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

Conversion to a (const) pointer.

We just need to do a cast here.

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

Conversion to a (const) pointer.

We just need to do a cast here.

template<class DVL >
ElementProxy< DVL > & DataModel_detail::ElementProxy< DVL >::operator= ( typename DVL::value_type  rhs  )  [inline]

Assignment operator, from a pointer.

Parameters:
rhs The 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.

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

Assignment operator, from an Element proxy.

Parameters:
rhs The 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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1