moab
TagInfo.hpp
Go to the documentation of this file.
00001 #ifndef TAG_INFO_HPP
00002 #define TAG_INFO_HPP
00003 
00004 #include "moab/Range.hpp"
00005 #include <string>
00006 
00007 namespace moab {
00008 
00009 class SequenceManager;
00010 class Range;
00011 class Error;
00012 
00013 // ! stores information about a tag
00014 class TagInfo
00015 {
00016 public:
00017 
00019   TagInfo() : mDefaultValue(0),
00020               mDefaultValueSize(0),
00021               mDataSize(0), 
00022               dataType(MB_TYPE_OPAQUE)
00023               {}
00024 
00026   TagInfo( const char * name, 
00027            int size, 
00028            DataType type, 
00029            const void * default_value,
00030            int default_value_size);
00031   
00032   virtual ~TagInfo();
00033 
00047   virtual ErrorCode release_all_data( SequenceManager* seqman,
00048                                       Error* error_handler,
00049                                       bool tag_delete_pending ) = 0;
00050   
00052   void set_name( const std::string& name) { mTagName = name; }
00053 
00055   const std::string& get_name() const { return mTagName; }
00056 
00058   int get_default_value_size() const { return mDefaultValueSize; }
00059 
00061   const void *get_default_value() const { return mDefaultValue; }
00062   
00065   bool equals_default_value( const void* data, int size = -1 ) const;
00066   
00067   inline DataType get_data_type() const     { return dataType; }
00068 
00070   int get_size() const { return mDataSize; }
00071   
00073   bool variable_length() const { return get_size() == MB_VARIABLE_LENGTH; }
00074 
00075   static int size_from_data_type( DataType t );
00076   
00077     // Check that all lengths are valid multiples of the type size.
00078     // Returns true if all lengths are valid, false othersize.
00079   bool check_valid_sizes( const int* sizes, int num_sizes ) const;
00080 
00089   ErrorCode validate_lengths( Error* error_handler,
00090                               const int* lengths, 
00091                               size_t num_lengths ) const;
00092 
00093   virtual
00094   TagType get_storage_type() const = 0;
00095 
00107   virtual
00108   ErrorCode get_data( const SequenceManager* seqman,
00109                       Error* error_handler,
00110                       const EntityHandle* entities,
00111                       size_t num_entities,
00112                       void* data ) const = 0;
00113   
00124   virtual
00125   ErrorCode get_data( const SequenceManager* seqman,
00126                       Error* error_handler,
00127                       const Range& entities,
00128                       void* data ) const = 0;
00129                       
00143   virtual
00144   ErrorCode get_data( const SequenceManager* seqman,
00145                       Error* error_handler,
00146                       const EntityHandle* entities,
00147                       size_t num_entities,
00148                       const void** data_ptrs,
00149                       int* data_lengths ) const = 0;
00150                       
00151                       
00164   virtual
00165   ErrorCode get_data( const SequenceManager* seqman,
00166                       Error* error_handler,
00167                       const Range& entities,
00168                       const void** data_ptrs,
00169                       int* data_lengths ) const = 0;
00170   
00181   virtual
00182   ErrorCode set_data( SequenceManager* seqman,
00183                       Error* error_handler,
00184                       const EntityHandle* entities,
00185                       size_t num_entities,
00186                       const void* data ) = 0;
00187   
00197   virtual
00198   ErrorCode set_data( SequenceManager* seqman,
00199                       Error* error_handler,
00200                       const Range& entities,
00201                       const void* data ) = 0;
00202                       
00217   virtual
00218   ErrorCode set_data( SequenceManager* seqman,
00219                       Error* error_handler,
00220                       const EntityHandle* entities,
00221                       size_t num_entities,
00222                       void const* const* data_ptrs,
00223                       const int* data_lengths ) = 0;
00224                       
00225                       
00239   virtual
00240   ErrorCode set_data( SequenceManager* seqman,
00241                       Error* error_handler,
00242                       const Range& entities,
00243                       void const* const* data_ptrs,
00244                       const int* data_lengths ) = 0;
00245                       
00259   virtual
00260   ErrorCode clear_data( SequenceManager* seqman,
00261                         Error* error_handler,
00262                         const EntityHandle* entities,
00263                         size_t num_entities,
00264                         const void* value_ptr,
00265                         int value_len = 0 ) = 0;
00266                       
00279   virtual
00280   ErrorCode clear_data( SequenceManager* seqman,
00281                         Error* error_handler,
00282                         const Range& entities,
00283                         const void* value_ptr,
00284                         int value_len = 0 ) = 0;
00285 
00294   virtual ErrorCode remove_data( SequenceManager* seqman,
00295                                  Error* error_handler,
00296                                  const EntityHandle* entities,
00297                                  size_t num_entities ) = 0;
00298 
00306   virtual ErrorCode remove_data( SequenceManager* seqman,
00307                                  Error* error_handler,
00308                                  const Range& entities ) = 0;
00309 
00333   virtual
00334   ErrorCode tag_iterate( SequenceManager* seqman,
00335                          Error* error_handler,
00336                          Range::iterator& iter,
00337                          const Range::iterator& end,
00338                          void*& data_ptr,
00339                          bool allocate = true) = 0;
00340 
00354   virtual
00355   ErrorCode get_tagged_entities( const SequenceManager* seqman,
00356                                  Range& output_entities,
00357                                  EntityType type = MBMAXTYPE,
00358                                  const Range* intersect = 0 ) const = 0;
00359 
00373   virtual
00374   ErrorCode num_tagged_entities( const SequenceManager* seqman,
00375                                  size_t& output_count,
00376                                  EntityType type = MBMAXTYPE,
00377                                  const Range* intersect = 0 ) const = 0;
00378   
00392   virtual
00393   ErrorCode find_entities_with_value( const SequenceManager* seqman,
00394                                       Error* error_handler,
00395                                       Range& output_entities,
00396                                       const void* value,
00397                                       int value_bytes = 0,
00398                                       EntityType type = MBMAXTYPE,
00399                                       const Range* intersect_entities = 0 ) const = 0;
00400   
00402   virtual
00403   bool is_tagged( const SequenceManager* seqman, EntityHandle entity ) const = 0;
00404   
00408   virtual
00409   ErrorCode get_memory_use( const SequenceManager* seqman,
00410                             unsigned long& total,
00411                             unsigned long& per_entity ) const = 0;
00412 
00413 protected:    
00414 
00415   unsigned long get_memory_use() const
00416   {
00417     return get_default_value_size() + get_name().size();
00418   }
00419 
00420 private:
00421   
00422   TagInfo( const TagInfo& copy );
00423   
00424   TagInfo& operator=( const TagInfo& copy );
00425 
00427   void* mDefaultValue;
00428   
00430   void* mMeshValue;
00431   
00436   int mDefaultValueSize, mMeshValueSize;
00437 
00439   int mDataSize;
00440   
00442   DataType dataType;
00443 
00445   std::string mTagName;
00446 };
00447 
00448 } // namespace moab
00449 
00450 #endif // TAG_INFO_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines