Proxy for lvalue access to DataVector/.
More...DataList elements
#include <ElementProxy.h>
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. | |
| ElementProxy & | operator= (const ElementProxy &rhs) |
Assignment operator, from an Element proxy. | |
| ElementProxy & | operator= (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 |
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.
| DataModel_detail::ElementProxy< DVL >::ElementProxy | ( | typename DVL::BaseContainer::iterator | i, | |
| DVL * | container | |||
| ) | [inline] |
| 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.
| DVL::value_type const DataModel_detail::ElementProxy< DVL >::operator-> | ( | ) | const [inline] |
Conversion to a (const) pointer.
We just need to do a cast here.
| ElementProxy< DVL > & DataModel_detail::ElementProxy< DVL >::operator= | ( | typename DVL::value_type | rhs | ) | [inline] |
Assignment operator, from a pointer.
| 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.
| ElementProxy< DVL > & DataModel_detail::ElementProxy< DVL >::operator= | ( | const ElementProxy< DVL > & | rhs | ) | [inline] |
Assignment operator, from an Element proxy.
| 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.
1.6.1