ug4
ug::AttachmentAccessor< TElem, TAttachment, TElemHandler > Class Template Reference

Used to access data that has been attached to an attachment pipe. More...

#include <attachment_pipe.h>

+ Inheritance diagram for ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >:

Public Types

typedef attachment_traits< TElem, TElemHandler > atraits
 
typedef TAttachment attachment
 
typedef AttachmentPipe< TElem, TElemHandler > attachment_pipe
 
typedef TAttachment::ContainerType ContainerType
 
typedef TElem element
 
typedef TElemHandler ElemHandler
 
typedef TAttachment::ValueType ValueType
 

Public Member Functions

bool access (attachment_pipe &attachmentPipe, TAttachment &attachment)
 
 AttachmentAccessor ()
 
 AttachmentAccessor (AttachmentPipe< TElem, TElemHandler > &attachmentPipe, TAttachment &attachment)
 
 AttachmentAccessor (const AttachmentAccessor &aa)
 
size_t element_data_index (typename atraits::ConstElemPtr elem)
 returns the data index of the given element regarding the associated container. More...
 
void invalidate ()
 
attachment_value_traits< ValueType >::reference operator[] (typename atraits::ConstElemPtr elem)
 
attachment_value_traits< ValueType >::const_reference operator[] (typename atraits::ConstElemPtr elem) const
 
ValueTyperaw_data ()
 returns the raw pointer to the data of the associated container More...
 
void swap (AttachmentAccessor< TElem, TAttachment, TElemHandler > &acc)
 calls swap on associated containers More...
 
bool valid () const
 

Protected Attributes

ContainerTypem_pContainer
 
TElemHandler * m_pHandler
 

Detailed Description

template<class TElem, class TAttachment, class TElemHandler>
class ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >

Used to access data that has been attached to an attachment pipe.

Once initialized, an AttachmentAccessor can be used to access the data stored in the given Attachment at the given AttachmentPipe. The reference type of the associated value is taken from attachment_value_traits. By default this is the standard reference type.

To initialize an AttachmentAccessor, you may either use its constructor or its access method, which returns false if the specified attachment is not present in the specified attachment pipe.

Note that data-access using an attachment accessor is cheap. Setting up a new attachment accessor however involves some work. While this is generally fast, too, it would introduce an unnecessary overhead inside inner loops or frequently called methods. You should thus try to minimize calls to access or to the accessors constructor.

Member Typedef Documentation

◆ atraits

template<class TElem , class TAttachment , class TElemHandler >
typedef attachment_traits<TElem, TElemHandler> ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::atraits

◆ attachment

template<class TElem , class TAttachment , class TElemHandler >
typedef TAttachment ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::attachment

◆ attachment_pipe

template<class TElem , class TAttachment , class TElemHandler >
typedef AttachmentPipe<TElem, TElemHandler> ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::attachment_pipe

◆ ContainerType

template<class TElem , class TAttachment , class TElemHandler >
typedef TAttachment::ContainerType ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::ContainerType

◆ element

template<class TElem , class TAttachment , class TElemHandler >
typedef TElem ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::element

◆ ElemHandler

template<class TElem , class TAttachment , class TElemHandler >
typedef TElemHandler ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::ElemHandler

◆ ValueType

template<class TElem , class TAttachment , class TElemHandler >
typedef TAttachment::ValueType ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::ValueType

Constructor & Destructor Documentation

◆ AttachmentAccessor() [1/3]

template<class TElem , class TAttachment , class TElemHandler >
ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::AttachmentAccessor

◆ AttachmentAccessor() [2/3]

template<class TElem , class TAttachment , class TElemHandler >
ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::AttachmentAccessor ( const AttachmentAccessor< TElem, TAttachment, TElemHandler > &  aa)

◆ AttachmentAccessor() [3/3]

template<class TElem , class TAttachment , class TElemHandler >
ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::AttachmentAccessor ( AttachmentPipe< TElem, TElemHandler > &  attachmentPipe,
TAttachment &  attachment 
)

Member Function Documentation

◆ access()

template<class TElem , class TAttachment , class TElemHandler >
bool ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::access ( attachment_pipe attachmentPipe,
TAttachment &  attachment 
)

◆ element_data_index()

template<class TElem , class TAttachment , class TElemHandler >
size_t ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::element_data_index ( typename atraits::ConstElemPtr  elem)
inline

returns the data index of the given element regarding the associated container.

Note that the data index does not stay constant all the time. If the associated container is, e.g., defragmented, the data index may change.

References ug::attachment_traits< TElem, TElemHandler >::get_data_index().

◆ invalidate()

◆ operator[]() [1/2]

template<class TElem , class TAttachment , class TElemHandler >
attachment_value_traits<ValueType>::reference ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::operator[] ( typename atraits::ConstElemPtr  elem)
inline

◆ operator[]() [2/2]

template<class TElem , class TAttachment , class TElemHandler >
attachment_value_traits<ValueType>::const_reference ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::operator[] ( typename atraits::ConstElemPtr  elem) const
inline

◆ raw_data()

template<class TElem , class TAttachment , class TElemHandler >
ValueType* ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::raw_data ( )
inline

returns the raw pointer to the data of the associated container

ATTENTION: Use this method with extreme care! Returns NULL if no container was associated.

◆ swap()

template<class TElem , class TAttachment , class TElemHandler >
void ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::swap ( AttachmentAccessor< TElem, TAttachment, TElemHandler > &  acc)
inline

◆ valid()

Member Data Documentation

◆ m_pContainer

template<class TElem , class TAttachment , class TElemHandler >
ContainerType* ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::m_pContainer
protected

◆ m_pHandler

template<class TElem , class TAttachment , class TElemHandler >
TElemHandler* ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::m_pHandler
protected

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