MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Manage extra data attached to PatchData instances. More...
#include <ExtraDataUser.hpp>
Public Types | |
typedef T | DataType |
Public Member Functions | |
ExtraDataUser () | |
virtual | ~ExtraDataUser () |
T * | get_data_ptr (PatchData &patch) |
T & | get_data (PatchData &patch) |
void | set_data (PatchData &patch, const T &data) |
void | notify_patch_destroyed (ExtraUserData< T > *data) |
virtual void | notify_patch_destroyed (T &data)=0 |
virtual void | notify_new_patch (PatchData &patch, T &data)=0 |
virtual void | notify_sub_patch (PatchData &patch, T &data, PatchData &sub_patch, const size_t *vertex_index_map, const size_t *element_index_map, MsqError &err)=0 |
Private Attributes | |
ExtraUserData< T > * | listHead |
Manage extra data attached to PatchData instances.
This class manages the details of using the ExtraData mechanism for attaching data to and/or observing a PatchData. The template parameter is the type definint the data to be stored on the PatchData.
To use this class, define a type (struct or whatever) to contain the data that will be stored on PatchData instances, and create a subclass of this class, where the template parameter for this class is the data type. Provide implementations of the pure virtual (abstract) methods for notification of changes to the PatchData.
Definition at line 59 of file ExtraDataUser.hpp.
typedef T MBMesquite::ExtraDataUser< T >::DataType |
Definition at line 66 of file ExtraDataUser.hpp.
MBMesquite::ExtraDataUser< T >::ExtraDataUser | ( | ) |
Definition at line 143 of file ExtraDataUser.hpp.
: listHead( 0 ) { }
MBMesquite::ExtraDataUser< T >::~ExtraDataUser | ( | ) | [virtual] |
Definition at line 148 of file ExtraDataUser.hpp.
T & MBMesquite::ExtraDataUser< T >::get_data | ( | PatchData & | patch | ) |
creates data if doesn't exist
Definition at line 167 of file ExtraDataUser.hpp.
References T.
{ T* ptr = get_data_ptr( patch ); if( !ptr ) { listHead = new ExtraUserData< T >( patch, this, listHead ); ptr = &( listHead->userData ); } return *ptr; }
T * MBMesquite::ExtraDataUser< T >::get_data_ptr | ( | PatchData & | patch | ) |
returns null if data hasn't been set via set_data
Definition at line 159 of file ExtraDataUser.hpp.
References MBMesquite::ExtraUserData< T >::userNext.
{ for( ExtraUserData< T >* ptr = listHead; ptr; ptr = ptr->userNext ) if( ptr->get_patch_data() == &patch ) return &( ptr->userData ); return 0; }
virtual void MBMesquite::ExtraDataUser< T >::notify_new_patch | ( | PatchData & | patch, |
T & | data | ||
) | [pure virtual] |
Implemented in MBMesquite::CachingTargetCalculator, MBMesquite::TargetReader, and MBMesquite::WeightReader.
void MBMesquite::ExtraDataUser< T >::notify_patch_destroyed | ( | ExtraUserData< T > * | data | ) |
Definition at line 189 of file ExtraDataUser.hpp.
References MBMesquite::ExtraUserData< T >::userData, and MBMesquite::ExtraUserData< T >::userNext.
{ // remove from list assert( listHead != 0 ); if( listHead == data ) listHead = data->userNext; else { ExtraUserData< T >* prev; for( prev = listHead; prev->userNext != data; prev = prev->userNext ) assert( prev->userNext != 0 ); prev->userNext = data->userNext; } data->userNext = 0; // notify concrete class of event notify_patch_destroyed( data->userData ); delete data; }
virtual void MBMesquite::ExtraDataUser< T >::notify_patch_destroyed | ( | T & | data | ) | [pure virtual] |
Implemented in MBMesquite::CachingTargetCalculator, MBMesquite::TargetReader, and MBMesquite::WeightReader.
virtual void MBMesquite::ExtraDataUser< T >::notify_sub_patch | ( | PatchData & | patch, |
T & | data, | ||
PatchData & | sub_patch, | ||
const size_t * | vertex_index_map, | ||
const size_t * | element_index_map, | ||
MsqError & | err | ||
) | [pure virtual] |
Implemented in MBMesquite::CachingTargetCalculator, MBMesquite::TargetReader, and MBMesquite::WeightReader.
void MBMesquite::ExtraDataUser< T >::set_data | ( | PatchData & | patch, |
const T & | data | ||
) |
Definition at line 179 of file ExtraDataUser.hpp.
References T.
{ T* ptr = get_data_ptr( patch ); if( ptr ) *ptr = data; else listHead = new ExtraUserData< T >( patch, this, listHead, data ); }
ExtraUserData< T >* MBMesquite::ExtraDataUser< T >::listHead [private] |
Definition at line 90 of file ExtraDataUser.hpp.