MOAB: Mesh Oriented datABase
(version 5.2.1)
|
00001 /** \file VarLenDenseTag.hpp 00002 * \author Jason Kraftcheck 00003 * \date 2010-12-14 00004 */ 00005 00006 #ifndef VAR_LEN_DENSE_TAG_HPP 00007 #define VAR_LEN_DENSE_TAG_HPP 00008 00009 #include "TagInfo.hpp" 00010 #include "VarLenTag.hpp" 00011 00012 namespace moab 00013 { 00014 00015 class VarLenTag; 00016 00017 /**\brief Dense storage of variable-length tag data 00018 * 00019 * Implement variable-length dense tag. 00020 */ 00021 class VarLenDenseTag : public TagInfo 00022 { 00023 private: 00024 int mySequenceArray; //!< Array index in SequenceManager used to store tag data. 00025 00026 VarLenTag meshValue; 00027 00028 VarLenDenseTag( int array_index, const char* name, DataType type, const void* default_value, 00029 int default_value_len ); 00030 00031 public: 00032 static VarLenDenseTag* create_tag( SequenceManager* seqman, Error* error_handler, const char* name, DataType type, 00033 const void* default_value, int default_value_len ); 00034 00035 virtual ~VarLenDenseTag(); 00036 00037 virtual TagType get_storage_type() const; 00038 00039 /**\brief Remove/clear tag data for all entities 00040 * 00041 * Remove tag values from entities. 00042 * 00043 *\param delete_pending If true, then release any global 00044 * data associated with the tag in preparation for deleting 00045 * the tag itself. 00046 * 00047 *\Note Invalidates tag if \c tag_delete_pending is true. The only 00048 * valid method that can be invoked that is is the destructor. 00049 * 00050 *\param seqman Pointer to mesh entity database 00051 */ 00052 virtual ErrorCode release_all_data( SequenceManager* seqman, Error* error_handler, bool delete_pending ); 00053 00054 /**\brief Get tag value for passed entities 00055 * 00056 * Get tag values for specified entities. 00057 * 00058 *\Note Will fail for variable-length data. 00059 *\param seqman Pointer to mesh entity database 00060 *\param entities Entity handles for which to retrieve tag data 00061 *\param num_entities Length of \c entities array 00062 *\param data Pointer to memory in which to store consecutive tag values, 00063 * one for each passed entity. 00064 */ 00065 virtual ErrorCode get_data( const SequenceManager* seqman, Error* error_handler, const EntityHandle* entities, 00066 size_t num_entities, void* data ) const; 00067 00068 /**\brief Get tag value for passed entities 00069 * 00070 * Get tag values for specified entities. 00071 * 00072 *\Note Will fail for variable-length data. 00073 *\param seqman Pointer to mesh entity database 00074 *\param entities Entity handles for which to retrieve tag data 00075 *\param data Pointer to memory in which to store consecutive tag values, 00076 * one for each passed entity. 00077 */ 00078 virtual ErrorCode get_data( const SequenceManager* seqman, Error* error_handler, const Range& entities, 00079 void* data ) const; 00080 00081 /**\brief Get tag value for passed entities 00082 * 00083 * Get tag values for specified entities. 00084 * 00085 *\param seqman Pointer to mesh entity database 00086 *\param entities Entity handles for which to retrieve tag data 00087 *\param num_entities Length of \c entities array 00088 *\param data_ptrs Array of pointers to tag values, one pointer 00089 * for each passed entity. 00090 *\param data_lengths One value for each entity specifying the 00091 * length of the tag value for the corresponding 00092 * entity. 00093 */ 00094 virtual ErrorCode get_data( const SequenceManager* seqman, Error* error_handler, const EntityHandle* entities, 00095 size_t num_entities, const void** data_ptrs, int* data_lengths ) const; 00096 00097 /**\brief Get tag value for passed entities 00098 * 00099 * Get tag values for specified entities. 00100 * 00101 *\param seqman Pointer to mesh entity database 00102 *\param entities Entity handles for which to retrieve tag data 00103 *\param data_ptrs Array of pointers to tag values, one pointer 00104 * for each passed entity. 00105 *\param data_lengths One value for each entity specifying the 00106 * length of the tag value for the corresponding 00107 * entity. 00108 */ 00109 virtual ErrorCode get_data( const SequenceManager* seqman, Error* error_handler, const Range& entities, 00110 const void** data_ptrs, int* data_lengths ) const; 00111 00112 /**\brief Set tag value for passed entities 00113 * 00114 * Store tag data or update stored tag values 00115 *\Note Will fail for variable-length data. 00116 *\param seqman Pointer to mesh entity database 00117 *\param entities Entity handles for which to store tag data 00118 *\param num_entities Length of \c entities array 00119 *\param data Pointer to memory holding consecutive tag values, 00120 * one for each passed entity. 00121 */ 00122 virtual ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const EntityHandle* entities, 00123 size_t num_entities, const void* data ); 00124 00125 /**\brief Set tag value for passed entities 00126 * 00127 * Store tag data or update stored tag values 00128 *\Note Will fail for variable-length data. 00129 *\param seqman Pointer to mesh entity database 00130 *\param entities Entity handles for which to store tag data 00131 *\param data Pointer to memory holding consecutive tag values, 00132 * one for each passed entity. 00133 */ 00134 virtual ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const Range& entities, 00135 const void* data ); 00136 00137 /**\brief Set tag value for passed entities 00138 * 00139 * Store tag data or update stored tag values 00140 * 00141 *\param seqman Pointer to mesh entity database 00142 *\param entities Entity handles for which to store tag data 00143 *\param num_entities Length of \c entities array 00144 *\param data_ptrs Array of pointers to tag values, one pointer 00145 * for each passed entity. 00146 *\param data_lengths One value for each entity specifying the 00147 * length of the tag value for the corresponding 00148 * entity. Array is required for variable-length 00149 * tags and is ignored for fixed-length tags. 00150 */ 00151 virtual ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const EntityHandle* entities, 00152 size_t num_entities, void const* const* data_ptrs, const int* data_lengths ); 00153 00154 /**\brief Set tag value for passed entities 00155 * 00156 * Store tag data or update stored tag values 00157 * 00158 *\param seqman Pointer to mesh entity database 00159 *\param entities Entity handles for which to store tag data 00160 *\param data_ptrs Array of pointers to tag values, one pointer 00161 * for each passed entity. 00162 *\param data_lengths One value for each entity specifying the 00163 * length of the tag value for the corresponding 00164 * entity. Array is required for variable-length 00165 * tags and is ignored for fixed-length tags. 00166 */ 00167 virtual ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const Range& entities, 00168 void const* const* data_ptrs, const int* data_lengths ); 00169 00170 /**\brief Set tag value for passed entities 00171 * 00172 * Store tag data or update stored tag values. 00173 * 00174 *\param seqman Pointer to mesh entity database 00175 *\param entities Entity handles for which to store tag data 00176 *\param num_entities Length of \c entities array 00177 *\param value_ptr Pointer to a single tag value which is to be 00178 * stored for each of the passed entities. 00179 *\param value_len Length of tag value in bytes. Ignored for 00180 * fixed-length tags. Required for variable- 00181 * length tags. 00182 */ 00183 virtual ErrorCode clear_data( SequenceManager* seqman, Error* error_handler, const EntityHandle* entities, 00184 size_t num_entities, const void* value_ptr, int value_len = 0 ); 00185 00186 /**\brief Set tag value for passed entities 00187 * 00188 * Store tag data or update stored tag values. 00189 * 00190 *\param seqman Pointer to mesh entity database 00191 *\param entities Entity handles for which to store tag data 00192 *\param value_ptr Pointer to a single tag value which is to be 00193 * stored for each of the passed entities. 00194 *\param value_len Length of tag value in bytes. Ignored for 00195 * fixed-length tags. Required for variable- 00196 * length tags. 00197 */ 00198 virtual ErrorCode clear_data( SequenceManager* seqman, Error* error_handler, const Range& entities, 00199 const void* value_ptr, int value_len = 0 ); 00200 00201 /**\brief Remove/clear tag data for entities 00202 * 00203 * Remove tag values from entities. 00204 * 00205 *\param seqman Pointer to mesh entity database 00206 *\param entities Entity handles for which to store tag data 00207 *\param num_entities Length of \c entities array 00208 */ 00209 virtual ErrorCode remove_data( SequenceManager* seqman, Error* error_handler, const EntityHandle* entities, 00210 size_t num_entities ); 00211 00212 /**\brief Remove/clear tag data for entities 00213 * 00214 * Remove tag values from entities. 00215 * 00216 *\param seqman Pointer to mesh entity database 00217 *\param entities Entity handles for which to store tag data 00218 */ 00219 virtual ErrorCode remove_data( SequenceManager* seqman, Error* error_handler, const Range& entities ); 00220 00221 /**\brief Access tag data via direct pointer into contiguous blocks 00222 * 00223 * Iteratively obtain direct access to contiguous blocks of tag 00224 * storage. This function cannot be used with bit tags because 00225 * of the compressed bit storage. This function cannot be used 00226 * with variable length tags because it does not provide a mechanism 00227 * to determine the length of the value for each entity. This 00228 * function may be used with sparse tags, but if it is used, it 00229 * will return data for a single entity at a time. 00230 * 00231 *\param iter As input, the first entity for which to return 00232 * data. As output, one past the last entity for 00233 * which data was returned. 00234 *\param end One past the last entity for which data is desired 00235 *\param data_ptr Output: pointer to tag storage. 00236 *\param allocate If true, space for this tag will be allocated, if not it wont 00237 * 00238 *\Note If this function is called for entities for which no tag value 00239 * has been set, but for which a default value exists, it will 00240 * force the allocation of explicit storage for each such entity 00241 * even though MOAB would normally not explicitly store tag values 00242 * for such entities. 00243 */ 00244 virtual ErrorCode tag_iterate( SequenceManager* seqman, Error* error_handler, Range::iterator& iter, 00245 const Range::iterator& end, void*& data_ptr, bool allocate ); 00246 00247 /**\brief Get all tagged entities 00248 * 00249 * Get the list of entities for which the a tag value has been set, 00250 * or a close approximation if the tag storage scheme cannot 00251 * accurately determine exactly which entities have explicit values. 00252 * 00253 *\param seqman Pointer to entity storage database 00254 *\param output_entities Results *appended* to this range 00255 *\param type Optional entity type. If specified, search is 00256 * limited to entities of specified type. 00257 *\param intersect Optional intersect list. If specified, 00258 * search is restricted to entities in this list. 00259 */ 00260 virtual ErrorCode get_tagged_entities( const SequenceManager* seqman, Range& output_entities, 00261 EntityType type = MBMAXTYPE, const Range* intersect = 0 ) const; 00262 00263 /**\brief Count all tagged entities 00264 * 00265 * Count the entities for which the a tag value has been set, 00266 * or a close approximation if the tag storage scheme cannot 00267 * accurately determine exactly which entities have explicit values. 00268 * 00269 *\param seqman Pointer to entity storage database 00270 *\param output_count This is *incremented* for each detected entity. 00271 *\param type Optional entity type. If specified, search is 00272 * limited to entities of specified type. 00273 *\param intersect Optional intersect list. If specified, 00274 * search is restricted to entities in this list. 00275 */ 00276 virtual ErrorCode num_tagged_entities( const SequenceManager* seqman, size_t& output_count, 00277 EntityType type = MBMAXTYPE, const Range* intersect = 0 ) const; 00278 00279 /**\brief Get all tagged entities with tag value 00280 * 00281 * Get the list of entities which have the specified tag value. 00282 * 00283 *\param seqman Pointer to entity storage database 00284 *\param output_entities Results *appended* to this range 00285 *\param value Pointer to tag value 00286 *\param value_bytes Size of tag value in bytes. 00287 *\param type Optional entity type. If specified, search is 00288 * limited to entities of specified type. 00289 *\param intersect_entities Optional intersect list. If specified, 00290 * search is restricted to entities in this list. 00291 */ 00292 virtual ErrorCode find_entities_with_value( const SequenceManager* seqman, Error* error, Range& output_entities, 00293 const void* value, int value_bytes = 0, EntityType type = MBMAXTYPE, 00294 const Range* intersect_entities = 0 ) const; 00295 00296 /**\brief Check if entity is tagged */ 00297 virtual bool is_tagged( const SequenceManager*, EntityHandle h ) const; 00298 00299 /**\brief Get memory use for tag data. 00300 * 00301 */ 00302 virtual ErrorCode get_memory_use( const SequenceManager* seqman, unsigned long& total, 00303 unsigned long& per_entity ) const; 00304 00305 private: 00306 VarLenDenseTag( const VarLenDenseTag& ); 00307 VarLenDenseTag& operator=( const VarLenDenseTag& ); 00308 00309 /**\brief Get or allocated tag storage 00310 * 00311 *\param h First entity for which to return storage. 00312 *\param ptr Pointer to dag storage. This pointer will be set 00313 * to null and \c MB_SUCCESS will be returned if the handle 00314 * is valid but no tag storage has been allocated. 00315 *\param count Number of consecutive entities for which tag storage 00316 * is returned. This value will be valid even if null 00317 * is returned for \c ptr and indicates the number of 00318 * consecutive entities for which no tag storage has been 00319 * allocated. 00320 *\param allocate If true storage will be allocated and initialized 00321 * if it has not already been allocated. 00322 *\return MB_SUCCESS if handle is valid (regardless of whether 00323 * or not any tag storage is allocated). 00324 */ 00325 inline ErrorCode get_array( SequenceManager* seqman, Error* error_handler, EntityHandle h, VarLenTag*& ptr, 00326 size_t& count, bool allocate ); 00327 00328 /**\brief Get tag storage 00329 * 00330 *\param h First entity for which to return storage. 00331 *\param ptr Pointer to dag storage. This pointer will be set 00332 * to null and \c MB_SUCCESS will be returned if the handle 00333 * is valid but no tag storage has been allocated. 00334 *\param count Number of consecutive entities for which tag storage 00335 * is returned. This value will be valid even if null 00336 * is returned for \c ptr and indicates the number of 00337 * consecutive entities for which no tag storage has been 00338 * allocated. 00339 *\return MB_SUCCESS if handle is valid (regardless of whether 00340 * or not any tag storage is allocated). 00341 */ 00342 inline ErrorCode get_array( const SequenceManager* seqman, Error* error_handler, EntityHandle h, 00343 const VarLenTag*& ptr, size_t& count ) const; 00344 00345 /**\brief Common implementation of set_data, and clear_data 00346 *\param allocate If false and no storage is currently allocated for 00347 * an entity then leave entity tag unallocated. 00348 *\param one_value If true, pointers and lengths are assumed to be 00349 * arrays of length 1 and all entities are set to the 00350 * corresponding value 00351 */ 00352 inline ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const EntityHandle* entities, 00353 size_t num_entities, bool one_value, void const* const* pointers, const int* lengths ); 00354 00355 /**\brief Common implementation of set_data, and clear_data 00356 *\param allocate If false and no storage is currently allocated for 00357 * an entity then leave entity tag unallocated. 00358 *\param one_value If true, pointers and lengths are assumed to be 00359 * arrays of length 1 and all entities are set to the 00360 * corresponding value 00361 */ 00362 inline ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const Range& entities, bool one_value, 00363 void const* const* pointers, const int* lengths ); 00364 }; 00365 00366 } // namespace moab 00367 00368 #endif // VAR_LEN_DENSE_TAG_HPP