MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::ExtraDataUser< T > Class Template Reference

Manage extra data attached to PatchData instances. More...

#include <ExtraDataUser.hpp>

+ Inheritance diagram for MBMesquite::ExtraDataUser< T >:

Public Types

typedef T DataType

Public Member Functions

 ExtraDataUser ()
virtual ~ExtraDataUser ()
Tget_data_ptr (PatchData &patch)
Tget_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

Detailed Description

template<typename T>
class MBMesquite::ExtraDataUser< T >

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.


Member Typedef Documentation

template<typename T>
typedef T MBMesquite::ExtraDataUser< T >::DataType

Definition at line 66 of file ExtraDataUser.hpp.


Constructor & Destructor Documentation

template<typename T >
MBMesquite::ExtraDataUser< T >::ExtraDataUser ( )

Definition at line 143 of file ExtraDataUser.hpp.

                                  : listHead( 0 )
{
}
template<typename T >
MBMesquite::ExtraDataUser< T >::~ExtraDataUser ( ) [virtual]

Definition at line 148 of file ExtraDataUser.hpp.

{
    while( ExtraUserData< T >* dead_ptr = listHead )
    {
        listHead           = dead_ptr->userNext;
        dead_ptr->userNext = 0;
        delete dead_ptr;
    }
}

Member Function Documentation

template<typename T >
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;
}
template<typename T >
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;
}
template<typename T>
virtual void MBMesquite::ExtraDataUser< T >::notify_new_patch ( PatchData patch,
T data 
) [pure virtual]
template<typename T>
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;
}
template<typename T>
virtual void MBMesquite::ExtraDataUser< T >::notify_patch_destroyed ( T data) [pure virtual]
template<typename T>
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]
template<typename T>
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 );
}

Member Data Documentation

template<typename T>
ExtraUserData< T >* MBMesquite::ExtraDataUser< T >::listHead [private]

Definition at line 90 of file ExtraDataUser.hpp.

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines