moab
moab::VarLenDenseTag Class Reference

Dense storage of variable-length tag data. More...

#include <VarLenDenseTag.hpp>

Inheritance diagram for moab::VarLenDenseTag:
moab::TagInfo

List of all members.

Public Member Functions

virtual ~VarLenDenseTag ()
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)
 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, 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.

Static Public Member Functions

static VarLenDenseTagcreate_tag (SequenceManager *seqman, Error *error_handler, const char *name, DataType type, const void *default_value, int default_value_len)

Private Member Functions

 VarLenDenseTag (int array_index, const char *name, DataType type, const void *default_value, int default_value_len)
 VarLenDenseTag (const VarLenDenseTag &)
VarLenDenseTagoperator= (const VarLenDenseTag &)
ErrorCode get_array (SequenceManager *seqman, Error *error_handler, EntityHandle h, VarLenTag *&ptr, size_t &count, bool allocate)
 Get or allocated tag storage.
ErrorCode get_array (const SequenceManager *seqman, Error *error_handler, EntityHandle h, const VarLenTag *&ptr, size_t &count) const
 Get tag storage.
ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, bool one_value, void const *const *pointers, const int *lengths)
 Common implementation of set_data, and clear_data.
ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, bool one_value, void const *const *pointers, const int *lengths)
 Common implementation of set_data, and clear_data.

Private Attributes

int mySequenceArray
 Array index in SequenceManager used to store tag data.
VarLenTag meshValue

Detailed Description

Dense storage of variable-length tag data.

Implement variable-length dense tag.

Definition at line 20 of file VarLenDenseTag.hpp.


Constructor & Destructor Documentation

moab::VarLenDenseTag::VarLenDenseTag ( int  array_index,
const char *  name,
DataType  type,
const void *  default_value,
int  default_value_len 
) [private]

Definition at line 40 of file VarLenDenseTag.cpp.

  : TagInfo( name, MB_VARIABLE_LENGTH, type, default_value, default_value_size ), 
    mySequenceArray(index)
  {}

Definition at line 64 of file VarLenDenseTag.cpp.

{
  assert( mySequenceArray < 0 );
}

Member Function Documentation

ErrorCode moab::VarLenDenseTag::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 381 of file VarLenDenseTag.cpp.

{ 
  if (!value_ptr || !value_len)
    return remove_data( seqman, error, entities, num_entities );
  else
    return set_data( seqman, error, entities, num_entities, true, &value_ptr, &value_len );
}
ErrorCode moab::VarLenDenseTag::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 394 of file VarLenDenseTag.cpp.

{
  if (!value_ptr || !value_len)
    return remove_data( seqman, error, entities );
  else
    return set_data( seqman, error, entities, true, &value_ptr, &value_len );
}
VarLenDenseTag * moab::VarLenDenseTag::create_tag ( SequenceManager seqman,
Error error_handler,
const char *  name,
DataType  type,
const void *  default_value,
int  default_value_len 
) [static]

Definition at line 49 of file VarLenDenseTag.cpp.

{
  int index; 
  if (MB_SUCCESS != seqman->reserve_tag_array( error, MB_VARIABLE_LENGTH, index ))
    return 0;
  
  return new VarLenDenseTag( index, name, type, default_value, default_value_size );
}
ErrorCode moab::VarLenDenseTag::find_entities_with_value ( const SequenceManager seqman,
Error error,
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_entitiesOpotional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 565 of file VarLenDenseTag.cpp.

{
  if (!intersect_entities) {
    std::pair<EntityType,EntityType> range = type_range(type);
    TypeSequenceManager::const_iterator i;
    for (EntityType t = range.first; t != range.second; ++i) {
      const TypeSequenceManager& map = seqman->entity_map(t);
      for (i = map.begin(); i != map.end(); ++i) {
        const void* data = (*i)->data()->get_tag_data( mySequenceArray );
        if (data) {
          ByteArrayIterator start( (*i)->data()->start_handle(), data, *this );
          ByteArrayIterator end( (*i)->end_handle() + 1, 0, 0 );
          start += (*i)->start_handle() - (*i)->data()->start_handle();
          find_tag_varlen_values_equal( *this, value, value_bytes, start, end, output_entities );
        }
      }
    }
  }
  else {
    const VarLenTag* array;
    size_t count;
    ErrorCode rval;
     
    Range::const_pair_iterator p = intersect_entities->begin();
    if (type != MBMAXTYPE) {
      p = intersect_entities->lower_bound(type);
      assert(TYPE_FROM_HANDLE(p->first) == type);
    }
    for (; 
         p != intersect_entities->const_pair_end() && 
         (MBMAXTYPE == type || TYPE_FROM_HANDLE(p->first) == type); 
         ++p) {

      EntityHandle start = p->first;
      while (start <= p->second) {
        rval = get_array( seqman, error, start, array, count );
        if (MB_SUCCESS != rval)
          return rval; 
        
        if (p->second - start < count-1)
          count = p->second - start + 1;
        
        if (array) {
          ByteArrayIterator istart( start, array, *this );
          ByteArrayIterator iend( start+count, 0, 0 );
          find_tag_varlen_values_equal( *this, value, value_bytes, istart, iend, output_entities );
        }
        start += count;
      }
    }
  }    
  
  return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::get_array ( SequenceManager seqman,
Error error_handler,
EntityHandle  h,
VarLenTag *&  ptr,
size_t &  count,
bool  allocate 
) [inline, private]

Get or allocated tag storage.

Parameters:
hFirst entity for which to return storage.
ptrPointer to dag storage. This pointer will be set to null and MB_SUCCESS will be returned if the handle is valid but no tag storage has been allocated.
countNumber of consecutive entities for which tag storage is returned. This value will be valid even if null is returned for ptr and indicates the number of consecutive entities for which no tag storage has been allocated.
allocateIf true storage will be allocated and initialized if it has not already been allocated.
Returns:
MB_SUCCESS if handle is valid (regardless of whether or not any tag storage is allocated).

Definition at line 117 of file VarLenDenseTag.cpp.

{
  EntitySequence* seq = 0;
  ErrorCode rval = seqman->find( h, seq );
  if (MB_SUCCESS != rval) {
    if (!h) { // root set
      ptr = &meshValue;
      count = 1;
      return MB_SUCCESS;
    }
    else {
      ptr = 0;
      count = 0;
      return not_found( error, get_name(), h );
    }
  }
  
  void* mem = seq->data()->get_tag_data( mySequenceArray );
  if (!mem && allocate) {
    mem = seq->data()->allocate_tag_array( mySequenceArray, sizeof(VarLenTag) );
    if (!mem) {
      error->set_last_error( "Memory allocation for var-len tag data failed" );
      return MB_MEMORY_ALLOCATION_FAILED;
    }
    
    memset( mem, 0, sizeof(VarLenTag) * seq->data()->size() );
  }
  
  ptr = reinterpret_cast<VarLenTag*>(mem);
  count = seq->data()->end_handle() - h + 1;
  if (ptr)
    ptr += h - seq->data()->start_handle();
  return MB_SUCCESS;

}
ErrorCode moab::VarLenDenseTag::get_array ( const SequenceManager seqman,
Error error_handler,
EntityHandle  h,
const VarLenTag *&  ptr,
size_t &  count 
) const [inline, private]

Get tag storage.

Parameters:
hFirst entity for which to return storage.
ptrPointer to dag storage. This pointer will be set to null and MB_SUCCESS will be returned if the handle is valid but no tag storage has been allocated.
countNumber of consecutive entities for which tag storage is returned. This value will be valid even if null is returned for ptr and indicates the number of consecutive entities for which no tag storage has been allocated.
Returns:
MB_SUCCESS if handle is valid (regardless of whether or not any tag storage is allocated).

Definition at line 87 of file VarLenDenseTag.cpp.

{
  const EntitySequence* seq = 0;
  ErrorCode rval = seqman->find( h, seq );
  if (MB_SUCCESS != rval) {
    if (!h) { // root set
      ptr = &meshValue;
      count = 1;
      return MB_SUCCESS;
    }
    else {
      ptr = 0;
      count = 0;
      return not_found( error, get_name(), h );
    }
  }
  
  const void* mem = seq->data()->get_tag_data( mySequenceArray );
  ptr = reinterpret_cast<const VarLenTag*>(mem);
  count = seq->data()->end_handle() - h + 1;
  if (ptr)
    ptr += h - seq->data()->start_handle();

  return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::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 158 of file VarLenDenseTag.cpp.

{
  return not_var_len(error, get_name());
}
ErrorCode moab::VarLenDenseTag::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 168 of file VarLenDenseTag.cpp.

{
  return not_var_len(error, get_name());
}
ErrorCode moab::VarLenDenseTag::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 176 of file VarLenDenseTag.cpp.

{
  if (!lengths)
    return not_var_len(error, get_name());

  ErrorCode result = MB_SUCCESS, rval;
  const EntityHandle *const end = entities + num_entities;
  size_t junk;
  const VarLenTag* ptr;

  for (const EntityHandle* i = entities; i != end; ++i, ++pointers, ++lengths) {
    rval = get_array( seqman, error, *i, ptr, junk );
    if (MB_SUCCESS != rval) 
      return rval;
  
    if (ptr && ptr->size()) {
      *pointers = ptr->data();
      *lengths = ptr->size();
    }
    else if (get_default_value()) {
      *pointers = get_default_value();
      *lengths = get_default_value_size();
    }
    else {
      *pointers = 0;
      *lengths = 0;
      result = not_found( error, get_name(), *i );;
    }
  }
  
  return result;
}
ErrorCode moab::VarLenDenseTag::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 215 of file VarLenDenseTag.cpp.

{
  if (!lengths)
    return not_var_len(error, get_name());

  ErrorCode rval;
  size_t avail;
  const VarLenTag* array = 0;
  
  for (Range::const_pair_iterator p = entities.const_pair_begin(); 
       p != entities.const_pair_end(); ++p) {
       
    EntityHandle start = p->first;
    while (start <= p->second) {
      rval = get_array( seqman, error, start, array, avail );
      if (MB_SUCCESS != rval) 
        return rval;
      
      const size_t count = std::min<size_t>(p->second - start + 1, avail);

      if (!array) {
        const void* defval = get_default_value();
        const int len = get_default_value_size();
        SysUtil::setmem( pointers, &defval, sizeof(void*), count );
        SysUtil::setmem( lengths, &len, sizeof(int), count );
        pointers += count;
        lengths += count;
        if (!defval)
          return not_found( error, get_name(), start );
      }
      
      const VarLenTag* end_data = array + count;
      while (array != end_data) {
        if (array->size()) {
          *pointers = array->data();
          *lengths = array->size();
        }
        else if (get_default_value()) {
          *pointers = get_default_value();
          *lengths = get_default_value_size();
        }
        else {
          *pointers = 0;
          *lengths = 0;
          return not_found( error, get_name(), start );
        }
        ++pointers;
        ++lengths;
        ++array;
        ++start;
      }
    }
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::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 634 of file VarLenDenseTag.cpp.

{
  total = 0;
  per_entity = 0;
  size_t count = 0;
  for (EntityType t = MBVERTEX; t <= MBENTITYSET; ++t) {
    const TypeSequenceManager& map = seqman->entity_map(t);
    const SequenceData* prev_data = 0;
    for (TypeSequenceManager::const_iterator i = map.begin(); i != map.end(); ++i) {
      const void* mem = (*i)->data()->get_tag_data(mySequenceArray);
      if (!mem) 
        continue;
      
      if ((*i)->data() != prev_data) {
        total += (*i)->data()->size();
        prev_data = (*i)->data();
      }
      
      count += (*i)->size();
      const VarLenTag* array = reinterpret_cast<const VarLenTag*>(mem);
      for (int j = 0; j < (*i)->size(); ++j)
        per_entity += array[j].mem();
    }
  }
  total *= sizeof(VarLenTag);
  total += per_entity + sizeof(*this) + TagInfo::get_memory_use();
  total += meshValue.mem() + sizeof(meshValue);
  if (count)
    per_entity /= count;
  per_entity += sizeof(VarLenTag);
      
  return MB_SUCCESS;
}

Implements moab::TagInfo.

Definition at line 69 of file VarLenDenseTag.cpp.

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

Get all tagged entities.

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.
intersectOpotional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 546 of file VarLenDenseTag.cpp.

{
  return get_tagged( seqman, mySequenceArray, entities, type, intersect );
}
bool moab::VarLenDenseTag::is_tagged ( const SequenceManager seqman,
EntityHandle  h 
) const [virtual]

Check if entity is tagged.

Implements moab::TagInfo.

Definition at line 626 of file VarLenDenseTag.cpp.

{
  const VarLenTag* ptr;
  size_t count;
  return MB_SUCCESS == get_array( seqman, 0, h, ptr, count ) 
          && 0 != ptr && 0 != ptr->data();
}
ErrorCode moab::VarLenDenseTag::num_tagged_entities ( const SequenceManager seqman,
size_t &  output_count,
EntityType  type = MBMAXTYPE,
const Range intersect = 0 
) const [virtual]

Count all tagged entities.

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.
intersectOpotional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 554 of file VarLenDenseTag.cpp.

{
  InsertCount counter( output_count );
  ErrorCode rval = get_tagged( seqman, mySequenceArray, counter, type, intersect );
  output_count = counter.end();
  return rval;
}
VarLenDenseTag& moab::VarLenDenseTag::operator= ( const VarLenDenseTag ) [private]
ErrorCode moab::VarLenDenseTag::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 72 of file VarLenDenseTag.cpp.

{
  Range all_ents;
  seqman->get_entities( all_ents );
  ErrorCode rval = remove_data( seqman, error, all_ents );
  if (MB_SUCCESS == rval) {
    rval = seqman->release_tag_array( error, mySequenceArray, delete_pending );
    if (MB_SUCCESS == rval && delete_pending)
      mySequenceArray = -1;
  }
  return rval;
}
ErrorCode moab::VarLenDenseTag::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 406 of file VarLenDenseTag.cpp.

{
  const EntityHandle* const end = entities + num_entities;
  VarLenTag* array;
  size_t junk;
  ErrorCode rval;
  
  for (const EntityHandle* i = entities; i != end; ++i ) {
    rval = get_array( seqman, error, *i, array, junk, false );
    if (MB_SUCCESS != rval)
      return rval;
    
    if (array) 
      array->clear();
  }

  return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::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 428 of file VarLenDenseTag.cpp.

{
  VarLenTag* array;
  size_t avail;
  ErrorCode rval;

  for (Range::const_pair_iterator p = entities.const_pair_begin(); 
       p != entities.const_pair_end(); ++p) {
       
    EntityHandle start = p->first;
    while (start <= p->second) {
      rval = get_array( seqman, error, start, array, avail, false );
      if (MB_SUCCESS != rval)
        return rval;
      
      const EntityHandle end = std::min<EntityHandle>(p->second + 1, start + avail );
      if (array) {
        while (start != end) {
          array->clear();
          ++start;
          ++array;
        }
      }
      else {
        start = end;
      }
    }
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::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 276 of file VarLenDenseTag.cpp.

{
  return not_var_len(error, get_name());
}
ErrorCode moab::VarLenDenseTag::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 285 of file VarLenDenseTag.cpp.

{
  return not_var_len(error, get_name());
}
ErrorCode moab::VarLenDenseTag::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 361 of file VarLenDenseTag.cpp.

{
  return set_data( seqman, error, entities, num_entities, false, pointers, lengths );
}
ErrorCode moab::VarLenDenseTag::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 372 of file VarLenDenseTag.cpp.

{
  return set_data( seqman, error, entities, false, pointers, lengths );
}
ErrorCode moab::VarLenDenseTag::set_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
bool  one_value,
void const *const *  pointers,
const int *  lengths 
) [inline, private]

Common implementation of set_data, and clear_data.

Parameters:
allocateIf false and no storage is currently allocated for an entity then leave entity tag unallocated.
one_valueIf true, pointers and lengths are assumed to be arrays of length 1 and all entities are set to the corresponding value

Definition at line 293 of file VarLenDenseTag.cpp.

{
  ErrorCode rval = validate_lengths( error, lengths, one_value ?  1 : num_entities );
  if (MB_SUCCESS != rval)
    return rval;
  
  const EntityHandle* const end = entities + num_entities;
  VarLenTag* array;
  size_t junk;
  const size_t step = one_value ? 0 : 1;
  
  for (const EntityHandle* i = entities; i != end; ++i ) {
    rval = get_array( seqman, error, *i, array, junk, true );
    if (MB_SUCCESS != rval)
      return rval;
    
    array->set( *pointers, *lengths );
    pointers += step;
    lengths += step;
  }

  return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::set_data ( SequenceManager seqman,
Error error_handler,
const Range entities,
bool  one_value,
void const *const *  pointers,
const int *  lengths 
) [inline, private]

Common implementation of set_data, and clear_data.

Parameters:
allocateIf false and no storage is currently allocated for an entity then leave entity tag unallocated.
one_valueIf true, pointers and lengths are assumed to be arrays of length 1 and all entities are set to the corresponding value

Definition at line 323 of file VarLenDenseTag.cpp.

{
  ErrorCode rval = validate_lengths( error, lengths, one_value ?  1 : entities.size() );
  if (MB_SUCCESS != rval)
    return rval;
  
  VarLenTag* array;
  size_t avail;
  const size_t step = one_value ? 0 : 1;

  for (Range::const_pair_iterator p = entities.const_pair_begin(); 
       p != entities.const_pair_end(); ++p) {
       
    EntityHandle start = p->first;
    while (start <= p->second) {
      rval = get_array( seqman, error, start, array, avail, true );
      if (MB_SUCCESS != rval)
        return rval;
      
      const EntityHandle end = std::min<EntityHandle>(p->second + 1, start + avail );
      while (start != end) {
        array->set( *pointers, *lengths );
        ++start;
        ++array;
        pointers += step;
        lengths += step;
      }
    }
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::tag_iterate ( SequenceManager seqman,
Error error_handler,
Range::iterator iter,
const Range::iterator end,
void *&  data_ptr,
bool  allocate 
) [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.
allocateIf true, space for this tag will be allocated, if not it wont

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 463 of file VarLenDenseTag.cpp.

{
  error->set_last_error( "Cannot iterate over variable-length tag data" );
  return MB_VARIABLE_DATA_LENGTH;
}

Member Data Documentation

Definition at line 25 of file VarLenDenseTag.hpp.

Array index in SequenceManager used to store tag data.

Definition at line 23 of file VarLenDenseTag.hpp.


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