[MOAB-dev] r4521 - in MOAB/trunk/src: . moab

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed Feb 23 13:51:02 CST 2011


Author: kraftche
Date: 2011-02-23 13:51:02 -0600 (Wed, 23 Feb 2011)
New Revision: 4521

Modified:
   MOAB/trunk/src/Core.cpp
   MOAB/trunk/src/moab/Core.hpp
   MOAB/trunk/src/moab/Interface.hpp
   MOAB/trunk/src/moab/Types.hpp
Log:
Check in some changes to the new tag_get_handle() function discussed with
Tim in January.

Everything compiles and works but this change is incomplete.  Still to 
come someday when I have time: 
  - Change tag-related functions to use number of values rather than
     number of bytes for size arguments.  This would include the
     function to query tag size, the function to get the default 
     value, and functions relating to getting/setting variable-length tags.
  - Rename functions for getting/setting variable-length tags so that
     one doesn't end up accidentally calling the wrong variant because
     of a missing 'const'.
  - No longer accept a NULL handle array pointer as a request for the
     mesh value of a tag.  Accept only root set handles (0-valued handles)
     for that purpose.



Modified: MOAB/trunk/src/Core.cpp
===================================================================
--- MOAB/trunk/src/Core.cpp	2011-02-23 19:46:04 UTC (rev 4520)
+++ MOAB/trunk/src/Core.cpp	2011-02-23 19:51:02 UTC (rev 4521)
@@ -1942,16 +1942,25 @@
 
 ErrorCode Core::tag_get_handle( const char* name,
                                 int size,
-                                TagType storage,
                                 DataType type,
                                 Tag& tag_handle,
                                 unsigned flags,
-                                const void* default_value ) 
+                                const void* default_value,
+                                bool* created ) 
 {
+  if (created) *created = false;
+
   // we always work with sizes in bytes internally
-  if (flags & TAG_COUNT)
+  if (flags & MB_TAG_BYTES) {
+    if (size % TagInfo::size_from_data_type( type ))
+      return MB_INVALID_SIZE;
+  }
+  else {
     size *= TagInfo::size_from_data_type( type );
+  }
 
+  const TagType storage = static_cast<TagType>(flags & 3);
+
   // search for an existing tag
   tag_handle = 0;
   if (name && *name) { // not anonymous tag
@@ -1964,27 +1973,27 @@
   }
  
   if (tag_handle) {
-    if (flags & TAG_EXCL)
+    if (flags & MB_TAG_EXCL)
       return MB_ALREADY_ALLOCATED;
     // user asked that we not check anything
-    if (flags & TAG_ANY)
+    if (flags & MB_TAG_ANY)
       return MB_SUCCESS;
     // user asked that we also match storage types
-    if ((flags & TAG_STORE) && tag_handle->get_storage_type() != storage)
+    if ((flags & MB_TAG_STORE) && tag_handle->get_storage_type() != storage)
       return MB_TYPE_OUT_OF_RANGE;
     // check if data type matches
     const DataType extype = tag_handle->get_data_type();
     if (extype != type) {


More information about the moab-dev mailing list