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

#include <WriteAccessor.h>

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

Detailed Description

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

A WriteAccessor 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 some containers.

Other advantadges of using a WriteAccessor 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.
  • 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

container_typevref
 

Public Member Functions

 WriteAccessor (container_type &container)
 
const_reference ref () const
 
reference wref ()
 
 operator const_reference () const
 
const_pointer operator-> () const
 
const_reference operator* () const
 
 operator reference ()
 
pointer operator-> ()
 
reference operator* ()
 
template<class T2 >
void operator= (const T2 &v)
 

Attribute details

◆ vref

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

Constructor details

◆ WriteAccessor()

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

Function details

◆ operator const_reference()

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

◆ operator reference()

template<class T , class Enable = void>
sofa::helper::WriteAccessor< T, Enable >::operator reference ( )
inline

◆ operator*() [1/2]

template<class T , class Enable = void>
reference sofa::helper::WriteAccessor< T, Enable >::operator* ( )
inline

◆ operator*() [2/2]

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

◆ operator->() [1/2]

template<class T , class Enable = void>
pointer sofa::helper::WriteAccessor< T, Enable >::operator-> ( )
inline

◆ operator->() [2/2]

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

◆ operator=()

template<class T , class Enable = void>
template<class T2 >
void sofa::helper::WriteAccessor< T, Enable >::operator= ( const T2 &  v)
inline

◆ ref()

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

◆ wref()

template<class T , class Enable = void>
reference sofa::helper::WriteAccessor< T, Enable >::wref ( )
inline