MOAB: Mesh Oriented datABase  (version 5.2.1)
moab::VarLenSparseTag Class Reference

Sparse tag variable-length data. More...

#include <VarLenSparseTag.hpp>

+ Inheritance diagram for moab::VarLenSparseTag:
+ Collaboration diagram for moab::VarLenSparseTag:

Public Types

typedef
MOAB_UNORDERED_MAP_NS::unordered_map
< EntityHandle, VarLenTag
MapType
 map of entity id and tag data

Public Member Functions

 VarLenSparseTag (const char *name, DataType type, const void *default_value, int default_value_bytes)
 ~VarLenSparseTag ()
virtual TagType get_storage_type () const
virtual ErrorCode release_all_data (SequenceManager *seqman, Error *error_handler, bool delete_pending)
 Remove/clear tag data for all entities.
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, void *data) const
 Get tag value for passed entities.
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, void *data) const
 Get tag value for passed entities.
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void **data_ptrs, int *data_lengths) const
 Get tag value for passed entities.
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, const void **data_ptrs, int *data_lengths) const
 Get tag value for passed entities.
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void *data)
 Set tag value for passed entities.
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *data)
 Set tag value for passed entities.
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, void const *const *data_ptrs, const int *data_lengths)
 Set tag value for passed entities.
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, void const *const *data_ptrs, const int *data_lengths)
 Set tag value for passed entities.
virtual ErrorCode clear_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void *value_ptr, int value_len=0)
 Set tag value for passed entities.
virtual ErrorCode clear_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *value_ptr, int value_len=0)
 Set tag value for passed entities.
virtual ErrorCode remove_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities)
 Remove/clear tag data for entities.
virtual ErrorCode remove_data (SequenceManager *seqman, Error *error_handler, const Range &entities)
 Remove/clear tag data for entities.
virtual ErrorCode tag_iterate (SequenceManager *seqman, Error *error_handler, Range::iterator &iter, const Range::iterator &end, void *&data_ptr, bool allocate=true)
 Access tag data via direct pointer into contiguous blocks.
virtual ErrorCode get_tagged_entities (const SequenceManager *seqman, Range &output_entities, EntityType type=MBMAXTYPE, const Range *intersect=0) const
 Get all tagged entities.
virtual ErrorCode num_tagged_entities (const SequenceManager *seqman, size_t &output_count, EntityType type=MBMAXTYPE, const Range *intersect=0) const
 Count all tagged entities.
virtual ErrorCode find_entities_with_value (const SequenceManager *seqman, Error *error_handler, Range &output_entities, const void *value, int value_bytes=0, EntityType type=MBMAXTYPE, const Range *intersect_entities=0) const
 Get all tagged entities with tag value.
virtual bool is_tagged (const SequenceManager *, EntityHandle h) const
 Check if entity is tagged.
virtual ErrorCode get_memory_use (const SequenceManager *seqman, unsigned long &total, unsigned long &per_entity) const
 Get memory use for tag data.
unsigned long get_number_entities ()
 get number of entities

Private Member Functions

 VarLenSparseTag (const VarLenSparseTag &)
VarLenSparseTagoperator= (const VarLenSparseTag &)
ErrorCode get_data_ptr (Error *error_handler, EntityHandle entity_handle, const void *&data, int &size) const
 get the variable-length data for an entity id

Private Attributes

MapType mData

Detailed Description

Sparse tag variable-length data.

Definition at line 45 of file VarLenSparseTag.hpp.


Member Typedef Documentation

typedef MOAB_UNORDERED_MAP_NS::unordered_map< EntityHandle, VarLenTag > moab::VarLenSparseTag::MapType

map of entity id and tag data

Definition at line 328 of file VarLenSparseTag.hpp.


Constructor & Destructor Documentation

moab::VarLenSparseTag::VarLenSparseTag ( const char *  name,
DataType  type,
const void *  default_value,
int  default_value_bytes 
)

Definition at line 30 of file VarLenSparseTag.cpp.

    : TagInfo( name, MB_VARIABLE_LENGTH, type, default_value, default_value_bytes )
{
}

Definition at line 35 of file VarLenSparseTag.cpp.

References release_all_data().

{
    release_all_data( 0, 0, true );
}

Member Function Documentation

ErrorCode moab::VarLenSparseTag::clear_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
const void *  value_ptr,
int  value_len = 0 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
num_entitiesLength of entities array
value_ptrPointer to a single tag value which is to be stored for each of the passed entities.
value_lenLength of tag value in bytes. Ignored for fixed-length tags. Required for variable- length tags.

Implements moab::TagInfo.

Definition at line 181 of file VarLenSparseTag.cpp.

References moab::SequenceManager::check_valid_entities(), MB_CHK_ERR, MB_SUCCESS, mData, remove_data(), and moab::TagInfo::validate_lengths().

{
    if( 0 == value_len )
    {
        remove_data( seqman, 0, entities, num_entities );
        return MB_SUCCESS;
    }

    ErrorCode rval = validate_lengths( NULL, &value_len, 1 );MB_CHK_ERR( rval );

    rval = seqman->check_valid_entities( NULL, entities, num_entities, true );MB_CHK_ERR( rval );

    for( size_t i = 0; i < num_entities; ++i )
        mData[entities[i]].set( value_ptr, value_len );

    return MB_SUCCESS;
}
ErrorCode moab::VarLenSparseTag::clear_data ( SequenceManager seqman,
Error error_handler,
const Range entities,
const void *  value_ptr,
int  value_len = 0 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
value_ptrPointer to a single tag value which is to be stored for each of the passed entities.
value_lenLength of tag value in bytes. Ignored for fixed-length tags. Required for variable- length tags.

Implements moab::TagInfo.

Definition at line 200 of file VarLenSparseTag.cpp.

References moab::Range::begin(), moab::SequenceManager::check_valid_entities(), moab::Range::end(), MB_CHK_ERR, MB_SUCCESS, mData, remove_data(), and moab::TagInfo::validate_lengths().

{
    if( 0 == value_len )
    {
        remove_data( seqman, 0, entities );
        return MB_SUCCESS;
    }

    ErrorCode rval = validate_lengths( NULL, &value_len, 1 );MB_CHK_ERR( rval );

    rval = seqman->check_valid_entities( NULL, entities );MB_CHK_ERR( rval );

    Range::const_iterator i;
    for( i = entities.begin(); i != entities.end(); ++i )
        mData[*i].set( value_ptr, value_len );

    return MB_SUCCESS;
}
ErrorCode moab::VarLenSparseTag::find_entities_with_value ( const SequenceManager seqman,
Error error_handler,
Range output_entities,
const void *  value,
int  value_bytes = 0,
EntityType  type = MBMAXTYPE,
const Range intersect_entities = 0 
) const [virtual]

Get all tagged entities with tag value.

Get the list of entities which have the specified tag value.

Parameters:
seqmanPointer to entity storage database
output_entitiesResults *appended* to this range
valuePointer to tag value
value_bytesSize of tag value in bytes.
typeOptional entity type. If specified, search is limited to entities of specified type.
intersect_entitiesOptional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 329 of file VarLenSparseTag.cpp.

References moab::Range::begin(), moab::CREATE_HANDLE(), moab::Range::end(), moab::Range::equal_range(), moab::find_map_varlen_values_equal(), moab::find_tag_varlen_values_equal(), moab::TagInfo::get_size(), MB_END_ID, MB_INVALID_SIZE, MB_START_ID, MB_SUCCESS, MBMAXTYPE, and mData.

{
    if( value_bytes && value_bytes != get_size() ) return MB_INVALID_SIZE;

    MapType::const_iterator iter, end;
#ifdef MOAB_HAVE_UNORDERED_MAP
    if( intersect_entities )
    {
        std::pair< Range::iterator, Range::iterator > r;
        if( type == MBMAXTYPE )
        {
            r.first  = intersect_entities->begin();
            r.second = intersect_entities->end();
        }
        else
        {
            r = intersect_entities->equal_range( type );
        }

        find_map_varlen_values_equal( *this, value, get_size(), r.first, r.second, mData, output_entities );
    }
    else if( type == MBMAXTYPE )
    {
        find_tag_varlen_values_equal( *this, value, get_size(), mData.begin(), mData.end(), output_entities );
    }
    else
    {
        Range tmp;
        seqman->get_entities( type, tmp );
        find_map_varlen_values_equal( *this, value, get_size(), tmp.begin(), tmp.end(), mData, output_entities );
    }
#else
    if( intersect_entities )
    {
        for( Range::const_pair_iterator p = intersect_entities->begin(); p != intersect_entities->end(); ++p )
        {
            iter = mData.lower_bound( p->first );
            end = mData.upper_bound( p->second );
            find_tag_varlen_values_equal( *this, value, get_size(), iter, end, output_entities );
        }
    }
    else
    {
        if( type == MBMAXTYPE )
        {
            iter = mData.begin();
            end = mData.end();
        }
        else
        {
            iter = mData.lower_bound( CREATE_HANDLE( type, MB_START_ID ) );
            end = mData.upper_bound( CREATE_HANDLE( type, MB_END_ID ) );
        }
        find_tag_varlen_values_equal( *this, value, get_size(), iter, end, output_entities );
    }
#endif

    return MB_SUCCESS;
}
ErrorCode moab::VarLenSparseTag::get_data ( const SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
void *  data 
) const [virtual]

Get tag value for passed entities.

Get tag values for specified entities.

Will fail for variable-length data.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to retrieve tag data
num_entitiesLength of entities array
dataPointer to memory in which to store consecutive tag values, one for each passed entity.

Implements moab::TagInfo.

Definition at line 72 of file VarLenSparseTag.cpp.

References moab::TagInfo::get_name(), MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
}
ErrorCode moab::VarLenSparseTag::get_data ( const SequenceManager seqman,
Error error_handler,
const Range entities,
void *  data 
) const [virtual]

Get tag value for passed entities.

Get tag values for specified entities.

Will fail for variable-length data.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to retrieve tag data
dataPointer to memory in which to store consecutive tag values, one for each passed entity.

Implements moab::TagInfo.

Definition at line 78 of file VarLenSparseTag.cpp.

References moab::TagInfo::get_name(), MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
}
ErrorCode moab::VarLenSparseTag::get_data ( const SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
const void **  data_ptrs,
int *  data_lengths 
) const [virtual]

Get tag value for passed entities.

Get tag values for specified entities.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to retrieve tag data
num_entitiesLength of entities array
data_ptrsArray of pointers to tag values, one pointer for each passed entity.
data_lengthsOne value for each entity specifying the length of the tag value for the corresponding entity.

Implements moab::TagInfo.

Definition at line 84 of file VarLenSparseTag.cpp.

References get_data_ptr(), moab::TagInfo::get_name(), MB_SET_ERR, MB_SUCCESS, and MB_VARIABLE_DATA_LENGTH.

{
    if( !lengths )
    { MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" ); }

    ErrorCode rval;
    for( size_t i = 0; i < num_entities; ++i )
    {
        rval = get_data_ptr( NULL, entities[i], pointers[i], lengths[i] );
        if( rval != MB_SUCCESS ) return rval;
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenSparseTag::get_data ( const SequenceManager seqman,
Error error_handler,
const Range entities,
const void **  data_ptrs,
int *  data_lengths 
) const [virtual]

Get tag value for passed entities.

Get tag values for specified entities.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to retrieve tag data
data_ptrsArray of pointers to tag values, one pointer for each passed entity.
data_lengthsOne value for each entity specifying the length of the tag value for the corresponding entity.

Implements moab::TagInfo.

Definition at line 100 of file VarLenSparseTag.cpp.

References moab::Range::begin(), moab::Range::end(), get_data_ptr(), moab::TagInfo::get_name(), MB_SET_ERR, MB_SUCCESS, and MB_VARIABLE_DATA_LENGTH.

{
    if( !lengths )
    { MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" ); }

    ErrorCode rval;
    Range::const_iterator i;
    for( i = entities.begin(); i != entities.end(); ++i, ++pointers, ++lengths )
    {
        rval = get_data_ptr( NULL, *i, *pointers, *lengths );
        if( rval != MB_SUCCESS ) return rval;
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenSparseTag::get_data_ptr ( Error error_handler,
EntityHandle  entity_handle,
const void *&  data,
int &  size 
) const [inline, private]

get the variable-length data for an entity id

Definition at line 51 of file VarLenSparseTag.cpp.

References moab::TagInfo::get_default_value(), moab::TagInfo::get_default_value_size(), MB_SUCCESS, MB_TAG_NOT_FOUND, and mData.

Referenced by get_data().

{
    MapType::const_iterator iter = mData.find( entity_handle );

    if( iter != mData.end() )
    {
        ptr    = iter->second.data();
        length = iter->second.size();
    }
    else if( get_default_value() )
    {
        ptr    = get_default_value();
        length = get_default_value_size();
    }
    else
        return MB_TAG_NOT_FOUND;

    return MB_SUCCESS;
}
ErrorCode moab::VarLenSparseTag::get_memory_use ( const SequenceManager seqman,
unsigned long &  total,
unsigned long &  per_entity 
) const [virtual]

Get memory use for tag data.

Implements moab::TagInfo.

Definition at line 401 of file VarLenSparseTag.cpp.

References moab::TagInfo::get_memory_use(), MB_SUCCESS, and mData.

{
    total = mData.size() * ( 3 * sizeof( void* ) + sizeof( VarLenTag ) );
    for( MapType::const_iterator i = mData.begin(); i != mData.end(); ++i )
        total += i->second.mem();
    if( !mData.empty() ) per_entity = total / mData.size();
    total += sizeof( *this ) + TagInfo::get_memory_use();

    return MB_SUCCESS;
}
unsigned long moab::VarLenSparseTag::get_number_entities ( ) [inline]

get number of entities

Definition at line 321 of file VarLenSparseTag.hpp.

References mData.

    {
        return mData.size();
    }

Implements moab::TagInfo.

Definition at line 40 of file VarLenSparseTag.cpp.

References MB_TAG_SPARSE.

{
    return MB_TAG_SPARSE;
}
ErrorCode moab::VarLenSparseTag::get_tagged_entities ( const SequenceManager seqman,
Range output_entities,
EntityType  type = MBMAXTYPE,
const Range intersect = 0 
) const [virtual]

Get all tagged entities.

Gets all entity handles that match a type and tag.

Get the list of entities for which the a tag value has been set, or a close approximation if the tag storage scheme cannot accurately determine exactly which entities have explicit values.

Parameters:
seqmanPointer to entity storage database
output_entitiesResults *appended* to this range
typeOptional entity type. If specified, search is limited to entities of specified type.
intersectOptional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 312 of file VarLenSparseTag.cpp.

References moab::get_tagged(), MB_SUCCESS, and mData.

{
    get_tagged( mData, entities, type, intersect );
    return MB_SUCCESS;
}
bool moab::VarLenSparseTag::is_tagged ( const SequenceManager ,
EntityHandle  h 
) const [virtual]

Check if entity is tagged.

Implements moab::TagInfo.

Definition at line 396 of file VarLenSparseTag.cpp.

References mData.

{
    return mData.find( h ) != mData.end();
}
ErrorCode moab::VarLenSparseTag::num_tagged_entities ( const SequenceManager seqman,
size_t &  output_count,
EntityType  type = MBMAXTYPE,
const Range intersect = 0 
) const [virtual]

Count all tagged entities.

Gets all entity handles that match a type and tag.

Count the entities for which the a tag value has been set, or a close approximation if the tag storage scheme cannot accurately determine exactly which entities have explicit values.

Parameters:
seqmanPointer to entity storage database
output_countThis is *incremented* for each detected entity.
typeOptional entity type. If specified, search is limited to entities of specified type.
intersectOptional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 320 of file VarLenSparseTag.cpp.

References moab::InsertCount::end(), moab::get_tagged(), MB_SUCCESS, and mData.

{
    InsertCount counter( output_count );
    get_tagged( mData, counter, type, intersect );
    output_count = counter.end();
    return MB_SUCCESS;
}
VarLenSparseTag& moab::VarLenSparseTag::operator= ( const VarLenSparseTag ) [private]
ErrorCode moab::VarLenSparseTag::release_all_data ( SequenceManager seqman,
Error error_handler,
bool  delete_pending 
) [virtual]

Remove/clear tag data for all entities.

Remove tag values from entities.

Parameters:
delete_pendingIf true, then release any global data associated with the tag in preparation for deleting the tag itself.

Invalidates tag if tag_delete_pending is true. The only valid method that can be invoked that is is the destructor.

Parameters:
seqmanPointer to mesh entity database

Implements moab::TagInfo.

Definition at line 45 of file VarLenSparseTag.cpp.

References MB_SUCCESS, and mData.

Referenced by ~VarLenSparseTag().

{
    mData.clear();
    return MB_SUCCESS;
}
ErrorCode moab::VarLenSparseTag::remove_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities 
) [virtual]

Remove/clear tag data for entities.

Remove tag values from entities.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
num_entitiesLength of entities array

Implements moab::TagInfo.

Definition at line 220 of file VarLenSparseTag.cpp.

References MB_SUCCESS, MB_TAG_NOT_FOUND, and mData.

Referenced by clear_data().

{
    ErrorCode result = MB_SUCCESS;
    for( size_t i = 0; i < num_entities; ++i )
    {
        MapType::iterator p = mData.find( entities[i] );
        if( p == mData.end() )
            return MB_TAG_NOT_FOUND;
        else
        {
            p->second.clear();
            mData.erase( p );
        }
    }

    return result;
}
ErrorCode moab::VarLenSparseTag::remove_data ( SequenceManager seqman,
Error error_handler,
const Range entities 
) [virtual]

Remove/clear tag data for entities.

Remove tag values from entities.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data

Implements moab::TagInfo.

Definition at line 239 of file VarLenSparseTag.cpp.

References moab::Range::begin(), moab::Range::end(), MB_SUCCESS, MB_TAG_NOT_FOUND, and mData.

{
    ErrorCode result = MB_SUCCESS;
    for( Range::iterator i = entities.begin(); i != entities.end(); ++i )
    {
        MapType::iterator p = mData.find( *i );
        if( p == mData.end() )
            return MB_TAG_NOT_FOUND;
        else
        {
            p->second.clear();
            mData.erase( p );
        }
    }

    return result;
}
ErrorCode moab::VarLenSparseTag::set_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
const void *  data 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values Will fail for variable-length data.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
num_entitiesLength of entities array
dataPointer to memory holding consecutive tag values, one for each passed entity.

Implements moab::TagInfo.

Definition at line 117 of file VarLenSparseTag.cpp.

References moab::TagInfo::get_name(), MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
}
ErrorCode moab::VarLenSparseTag::set_data ( SequenceManager seqman,
Error error_handler,
const Range entities,
const void *  data 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values Will fail for variable-length data.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
dataPointer to memory holding consecutive tag values, one for each passed entity.

Implements moab::TagInfo.

Definition at line 124 of file VarLenSparseTag.cpp.

References moab::TagInfo::get_name(), MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
}
ErrorCode moab::VarLenSparseTag::set_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
void const *const *  data_ptrs,
const int *  data_lengths 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
num_entitiesLength of entities array
data_ptrsArray of pointers to tag values, one pointer for each passed entity.
data_lengthsOne value for each entity specifying the length of the tag value for the corresponding entity. Array is required for variable-length tags and is ignored for fixed-length tags.

Implements moab::TagInfo.

Definition at line 130 of file VarLenSparseTag.cpp.

References moab::SequenceManager::check_valid_entities(), MB_CHK_ERR, MB_SUCCESS, mData, and moab::TagInfo::validate_lengths().

{
    ErrorCode rval = validate_lengths( NULL, lengths, num_entities );MB_CHK_ERR( rval );

    rval = seqman->check_valid_entities( NULL, entities, num_entities, true );MB_CHK_ERR( rval );

    for( size_t i = 0; i < num_entities; ++i )
    {
        if( lengths[i] )
            mData[entities[i]].set( pointers[i], lengths[i] );
        else
        {
            MapType::iterator iter = mData.find( entities[i] );
            if( iter != mData.end() )
            {
                iter->second.clear();
                mData.erase( iter );
            }
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenSparseTag::set_data ( SequenceManager seqman,
Error error_handler,
const Range entities,
void const *const *  data_ptrs,
const int *  data_lengths 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
data_ptrsArray of pointers to tag values, one pointer for each passed entity.
data_lengthsOne value for each entity specifying the length of the tag value for the corresponding entity. Array is required for variable-length tags and is ignored for fixed-length tags.

Implements moab::TagInfo.

Definition at line 155 of file VarLenSparseTag.cpp.

References moab::Range::begin(), moab::SequenceManager::check_valid_entities(), moab::Range::end(), MB_CHK_ERR, MB_SUCCESS, mData, moab::Range::size(), and moab::TagInfo::validate_lengths().

{
    ErrorCode rval = validate_lengths( NULL, lengths, entities.size() );MB_CHK_ERR( rval );

    rval = seqman->check_valid_entities( NULL, entities );MB_CHK_ERR( rval );

    Range::const_iterator i;
    for( i = entities.begin(); i != entities.end(); ++i, ++pointers, ++lengths )
    {
        if( *lengths )
            mData[*i].set( *pointers, *lengths );
        else
        {
            MapType::iterator iter = mData.find( *i );
            if( iter != mData.end() )
            {
                iter->second.clear();
                mData.erase( iter );
            }
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenSparseTag::tag_iterate ( SequenceManager seqman,
Error error_handler,
Range::iterator iter,
const Range::iterator end,
void *&  data_ptr,
bool  allocate = true 
) [virtual]

Access tag data via direct pointer into contiguous blocks.

Iteratively obtain direct access to contiguous blocks of tag storage. This function cannot be used with bit tags because of the compressed bit storage. This function cannot be used with variable length tags because it does not provide a mechanism to determine the length of the value for each entity. This function may be used with sparse tags, but if it is used, it will return data for a single entity at a time.

Parameters:
iterAs input, the first entity for which to return data. As output, one past the last entity for which data was returned.
endOne past the last entity for which data is desired
data_ptrOutput: pointer to tag storage.

If this function is called for entities for which no tag value has been set, but for which a default value exists, it will force the allocation of explicit storage for each such entity even though MOAB would normally not explicitly store tag values for such entities.

Implements moab::TagInfo.

Definition at line 257 of file VarLenSparseTag.cpp.

References MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "Cannot iterate over variable-length tag data" );
}

Member Data Documentation

List of all members.


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