Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
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, VarLenTagMapType
 map of entity id and tag data More...
 

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. More...
 
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. More...
 
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, void *data) const
 Get tag value for passed entities. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *data)
 Set tag value for passed entities. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual ErrorCode remove_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities)
 Remove/clear tag data for entities. More...
 
virtual ErrorCode remove_data (SequenceManager *seqman, Error *error_handler, const Range &entities)
 Remove/clear tag data for entities. More...
 
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. More...
 
virtual ErrorCode get_tagged_entities (const SequenceManager *seqman, Range &output_entities, EntityType type=MBMAXTYPE, const Range *intersect=0) const
 Get all tagged entities. More...
 
virtual ErrorCode num_tagged_entities (const SequenceManager *seqman, size_t &output_count, EntityType type=MBMAXTYPE, const Range *intersect=0) const
 Count all tagged entities. More...
 
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. More...
 
virtual bool is_tagged (const SequenceManager *, EntityHandle h) const
 Check if entity is tagged. More...
 
virtual ErrorCode get_memory_use (const SequenceManager *seqman, unsigned long &total, unsigned long &per_entity) const
 Get memory use for tag data. More...
 
unsigned long get_number_entities ()
 get number of entities More...
 
- Public Member Functions inherited from moab::TagInfo
 TagInfo ()
 constructor More...
 
 TagInfo (const char *name, int size, DataType type, const void *default_value, int default_value_size)
 constructor that takes all parameters More...
 
virtual ~TagInfo ()
 
void set_name (const std::string &name)
 set the name of the tag More...
 
const std::string & get_name () const
 get the name of the tag More...
 
int get_default_value_size () const
 get length of default value More...
 
const void * get_default_value () const
 get the default data More...
 
bool equals_default_value (const void *data, int size=-1) const
 compare the passed value to the default value. returns false if no default value. More...
 
DataType get_data_type () const
 
int get_size () const
 get the size of the data in bytes More...
 
bool variable_length () const
 Check if variable-length tag. More...
 
bool check_valid_sizes (const int *sizes, int num_sizes) const
 
ErrorCode validate_lengths (Error *error_handler, const int *lengths, size_t num_lengths) const
 

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 More...
 

Private Attributes

MapType mData
 

Additional Inherited Members

- Static Public Member Functions inherited from moab::TagInfo
static int size_from_data_type (DataType t)
 
- Protected Member Functions inherited from moab::TagInfo
unsigned long get_memory_use () const
 

Detailed Description

Sparse tag variable-length data.

Definition at line 45 of file VarLenSparseTag.hpp.

Member Typedef Documentation

◆ MapType

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

map of entity id and tag data

Definition at line 373 of file VarLenSparseTag.hpp.

Constructor & Destructor Documentation

◆ VarLenSparseTag() [1/2]

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

Definition at line 30 of file VarLenSparseTag.cpp.

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

◆ ~VarLenSparseTag()

moab::VarLenSparseTag::~VarLenSparseTag ( )

Definition at line 35 of file VarLenSparseTag.cpp.

36 {
37  release_all_data( 0, 0, true );
38 }

References release_all_data().

◆ VarLenSparseTag() [2/2]

moab::VarLenSparseTag::VarLenSparseTag ( const VarLenSparseTag )
private

Member Function Documentation

◆ clear_data() [1/2]

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 210 of file VarLenSparseTag.cpp.

216 {
217  if( 0 == value_len )
218  {
219  remove_data( seqman, 0, entities, num_entities );
220  return MB_SUCCESS;
221  }
222 
223  ErrorCode rval = validate_lengths( NULL, &value_len, 1 );MB_CHK_ERR( rval );
224 
225  rval = seqman->check_valid_entities( NULL, entities, num_entities, true );MB_CHK_ERR( rval );
226 
227  for( size_t i = 0; i < num_entities; ++i )
228  mData[entities[i]].set( value_ptr, value_len );
229 
230  return MB_SUCCESS;
231 }

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

◆ clear_data() [2/2]

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 233 of file VarLenSparseTag.cpp.

238 {
239  if( 0 == value_len )
240  {
241  remove_data( seqman, 0, entities );
242  return MB_SUCCESS;
243  }
244 
245  ErrorCode rval = validate_lengths( NULL, &value_len, 1 );MB_CHK_ERR( rval );
246 
247  rval = seqman->check_valid_entities( NULL, entities );MB_CHK_ERR( rval );
248 
249  Range::const_iterator i;
250  for( i = entities.begin(); i != entities.end(); ++i )
251  mData[*i].set( value_ptr, value_len );
252 
253  return MB_SUCCESS;
254 }

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

◆ find_entities_with_value()

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 379 of file VarLenSparseTag.cpp.

391 {
392  if( value_bytes && value_bytes != get_size() ) return MB_INVALID_SIZE;
393 
394  MapType::const_iterator iter, end;
395 #ifdef MOAB_HAVE_UNORDERED_MAP
396  if( intersect_entities )
397  {
398  std::pair< Range::iterator, Range::iterator > r;
399  if( type == MBMAXTYPE )
400  {
401  r.first = intersect_entities->begin();
402  r.second = intersect_entities->end();
403  }
404  else
405  {
406  r = intersect_entities->equal_range( type );
407  }
408 
409  find_map_varlen_values_equal( *this, value, get_size(), r.first, r.second, mData, output_entities );
410  }
411  else if( type == MBMAXTYPE )
412  {
413  find_tag_varlen_values_equal( *this, value, get_size(), mData.begin(), mData.end(), output_entities );
414  }
415  else
416  {
417  Range tmp;
418  seqman->get_entities( type, tmp );
419  find_map_varlen_values_equal( *this, value, get_size(), tmp.begin(), tmp.end(), mData, output_entities );
420  }
421 #else
422  if( intersect_entities )
423  {
424  for( Range::const_pair_iterator p = intersect_entities->begin(); p != intersect_entities->end(); ++p )
425  {
426  iter = mData.lower_bound( p->first );
427  end = mData.upper_bound( p->second );
428  find_tag_varlen_values_equal( *this, value, get_size(), iter, end, output_entities );
429  }
430  }
431  else
432  {
433  if( type == MBMAXTYPE )
434  {
435  iter = mData.begin();
436  end = mData.end();
437  }
438  else
439  {
440  iter = mData.lower_bound( CREATE_HANDLE( type, MB_START_ID ) );
441  end = mData.upper_bound( CREATE_HANDLE( type, MB_END_ID ) );
442  }
443  find_tag_varlen_values_equal( *this, value, get_size(), iter, end, output_entities );
444  }
445 #endif
446 
447  return MB_SUCCESS;
448 }

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.

◆ get_data() [1/4]

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 91 of file VarLenSparseTag.cpp.

97 {
98  if( !lengths )
99  {
100  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
101  }
102 
103  ErrorCode rval;
104  for( size_t i = 0; i < num_entities; ++i )
105  {
106  rval = get_data_ptr( NULL, entities[i], pointers[i], lengths[i] );
107  if( rval != MB_SUCCESS ) return rval;
108  }
109 
110  return MB_SUCCESS;
111 }

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

◆ get_data() [2/4]

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.

\Note 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 74 of file VarLenSparseTag.cpp.

79 {
80  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
81 }

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

◆ get_data() [3/4]

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 113 of file VarLenSparseTag.cpp.

118 {
119  if( !lengths )
120  {
121  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
122  }
123 
124  ErrorCode rval;
125  Range::const_iterator i;
126  for( i = entities.begin(); i != entities.end(); ++i, ++pointers, ++lengths )
127  {
128  rval = get_data_ptr( NULL, *i, *pointers, *lengths );
129  if( rval != MB_SUCCESS ) return rval;
130  }
131 
132  return MB_SUCCESS;
133 }

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

◆ get_data() [4/4]

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.

\Note 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 83 of file VarLenSparseTag.cpp.

87 {
88  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
89 }

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

◆ get_data_ptr()

ErrorCode moab::VarLenSparseTag::get_data_ptr ( Error error_handler,
EntityHandle  entity_handle,
const void *&  data,
int &  size 
) const
inlineprivate

get the variable-length data for an entity id

Definition at line 51 of file VarLenSparseTag.cpp.

55 {
56  MapType::const_iterator iter = mData.find( entity_handle );
57 
58  if( iter != mData.end() )
59  {
60  ptr = iter->second.data();
61  length = iter->second.size();
62  }
63  else if( get_default_value() )
64  {
65  ptr = get_default_value();
67  }
68  else
69  return MB_TAG_NOT_FOUND;
70 
71  return MB_SUCCESS;
72 }

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

Referenced by get_data().

◆ get_memory_use()

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 455 of file VarLenSparseTag.cpp.

458 {
459  total = mData.size() * ( 3 * sizeof( void* ) + sizeof( VarLenTag ) );
460  for( MapType::const_iterator i = mData.begin(); i != mData.end(); ++i )
461  total += i->second.mem();
462  if( !mData.empty() ) per_entity = total / mData.size();
463  total += sizeof( *this ) + TagInfo::get_memory_use();
464 
465  return MB_SUCCESS;
466 }

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

◆ get_number_entities()

unsigned long moab::VarLenSparseTag::get_number_entities ( )
inline

get number of entities

Definition at line 366 of file VarLenSparseTag.hpp.

367  {
368  return mData.size();
369  }

References mData.

◆ get_storage_type()

TagType moab::VarLenSparseTag::get_storage_type ( ) const
virtual

Implements moab::TagInfo.

Definition at line 40 of file VarLenSparseTag.cpp.

41 {
42  return MB_TAG_SPARSE;
43 }

References MB_TAG_SPARSE.

◆ get_tagged_entities()

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 358 of file VarLenSparseTag.cpp.

362 {
363  get_tagged( mData, entities, type, intersect );
364  return MB_SUCCESS;
365 }

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

◆ is_tagged()

bool moab::VarLenSparseTag::is_tagged ( const SequenceManager ,
EntityHandle  h 
) const
virtual

Check if entity is tagged.

Implements moab::TagInfo.

Definition at line 450 of file VarLenSparseTag.cpp.

451 {
452  return mData.find( h ) != mData.end();
453 }

References mData.

◆ num_tagged_entities()

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 368 of file VarLenSparseTag.cpp.

372 {
373  InsertCount counter( output_count );
374  get_tagged( mData, counter, type, intersect );
375  output_count = counter.end();
376  return MB_SUCCESS;
377 }

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

◆ operator=()

VarLenSparseTag& moab::VarLenSparseTag::operator= ( const VarLenSparseTag )
private

◆ release_all_data()

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.

\Note 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.

46 {
47  mData.clear();
48  return MB_SUCCESS;
49 }

References MB_SUCCESS, and mData.

Referenced by ~VarLenSparseTag().

◆ remove_data() [1/2]

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 256 of file VarLenSparseTag.cpp.

260 {
261  ErrorCode result = MB_SUCCESS;
262  for( size_t i = 0; i < num_entities; ++i )
263  {
264  MapType::iterator p = mData.find( entities[i] );
265  if( p == mData.end() )
266  return MB_TAG_NOT_FOUND;
267  else
268  {
269  p->second.clear();
270  mData.erase( p );
271  }
272  }
273 
274  return result;
275 }

References entities, ErrorCode, MB_SUCCESS, MB_TAG_NOT_FOUND, and mData.

Referenced by clear_data().

◆ remove_data() [2/2]

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 277 of file VarLenSparseTag.cpp.

278 {
279  ErrorCode result = MB_SUCCESS;
280  for( Range::iterator i = entities.begin(); i != entities.end(); ++i )
281  {
282  MapType::iterator p = mData.find( *i );
283  if( p == mData.end() )
284  return MB_TAG_NOT_FOUND;
285  else
286  {
287  p->second.clear();
288  mData.erase( p );
289  }
290  }
291 
292  return result;
293 }

References entities, ErrorCode, MB_SUCCESS, MB_TAG_NOT_FOUND, and mData.

◆ set_data() [1/4]

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 \Note 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 135 of file VarLenSparseTag.cpp.

140 {
141  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
142 }

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

◆ set_data() [2/4]

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 152 of file VarLenSparseTag.cpp.

158 {
159  ErrorCode rval = validate_lengths( NULL, lengths, num_entities );MB_CHK_ERR( rval );
160 
161  rval = seqman->check_valid_entities( NULL, entities, num_entities, true );MB_CHK_ERR( rval );
162 
163  for( size_t i = 0; i < num_entities; ++i )
164  {
165  if( lengths[i] )
166  mData[entities[i]].set( pointers[i], lengths[i] );
167  else
168  {
169  MapType::iterator iter = mData.find( entities[i] );
170  if( iter != mData.end() )
171  {
172  iter->second.clear();
173  mData.erase( iter );
174  }
175  }
176  }
177 
178  return MB_SUCCESS;
179 }

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

◆ set_data() [3/4]

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 \Note 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 144 of file VarLenSparseTag.cpp.

148 {
149  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
150 }

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

◆ set_data() [4/4]

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 181 of file VarLenSparseTag.cpp.

186 {
187  ErrorCode rval = validate_lengths( NULL, lengths, entities.size() );MB_CHK_ERR( rval );
188 
189  rval = seqman->check_valid_entities( NULL, entities );MB_CHK_ERR( rval );
190 
191  Range::const_iterator i;
192  for( i = entities.begin(); i != entities.end(); ++i, ++pointers, ++lengths )
193  {
194  if( *lengths )
195  mData[*i].set( *pointers, *lengths );
196  else
197  {
198  MapType::iterator iter = mData.find( *i );
199  if( iter != mData.end() )
200  {
201  iter->second.clear();
202  mData.erase( iter );
203  }
204  }
205  }
206 
207  return MB_SUCCESS;
208 }

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

◆ tag_iterate()

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.

\Note 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 295 of file VarLenSparseTag.cpp.

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

References MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

Member Data Documentation

◆ mData


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