SOFA API  1c8b807d
Open source framework for multi-physics simuation
sofa::helper::ReadAccessor< T, Enable > Class Template Reference

#include <ReadAccessor.h>

Inheritance diagram for sofa::helper::ReadAccessor< T, Enable >:

Detailed Description

template<class T, class Enable = void>
class sofa::helper::ReadAccessor< T, Enable >

A ReadAccessor is a proxy class, holding a reference to a given container and providing access to its data, using an unified interface (similar to std::vector), hiding API differences within containers.

Other advantadges of using a ReadAccessor are :

  • It can be faster that the default methods and operators of the container, as verifications and changes notifications can be handled in the accessor's constructor and destructor instead of at each item access.
  • No modifications to the container will be done by mistake
  • Accesses can be logged for debugging or task dependencies analysis.

The default implementation provides only minimal set of methods and operators, sufficient for scalar types but which should be overloaded for more complex types. Various template specializations are typically used, especially for core::objectmodel::Data<T>

Protected Attributes

const container_typevref
 

Public Member Functions

 ReadAccessor (const container_type &container)
 
const_reference ref () const
 
 operator const_reference () const
 
const_pointer operator-> () const
 
const_reference operator* () const
 

Attribute details

◆ vref

template<class T , class Enable = void>
const container_type* sofa::helper::ReadAccessor< T, Enable >::vref
protected

Constructor details

◆ ReadAccessor()

template<class T , class Enable = void>
sofa::helper::ReadAccessor< T, Enable >::ReadAccessor ( const container_type container)
inlineexplicit

Function details

◆ operator const_reference()

template<class T , class Enable = void>
sofa::helper::ReadAccessor< T, Enable >::operator const_reference ( ) const
inline

◆ operator*()

template<class T , class Enable = void>
const_reference sofa::helper::ReadAccessor< T, Enable >::operator* ( ) const
inline

◆ operator->()

template<class T , class Enable = void>
const_pointer sofa::helper::ReadAccessor< T, Enable >::operator-> ( ) const
inline

◆ ref()

template<class T , class Enable = void>
const_reference sofa::helper::ReadAccessor< T, Enable >::ref ( ) const
inline