[MOAB-dev] r3509 - MOAB/trunk

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Fri Jan 29 10:23:40 CST 2010


Author: kraftche
Date: 2010-01-29 10:23:40 -0600 (Fri, 29 Jan 2010)
New Revision: 3509

Modified:
   MOAB/trunk/MBReaderWriterSet.cpp
Log:
Fix some bugs in MBReaderWriterSet

o One registration of CCMIO reader and writer, rather than separate 
  registration of each.
  
o Report an error if there are two registrations with the same 
  string name.

o Fix case-insensitive comparison of file name extensions.



Modified: MOAB/trunk/MBReaderWriterSet.cpp
===================================================================
--- MOAB/trunk/MBReaderWriterSet.cpp	2010-01-29 05:24:00 UTC (rev 3508)
+++ MOAB/trunk/MBReaderWriterSet.cpp	2010-01-29 16:23:40 UTC (rev 3509)
@@ -117,8 +117,7 @@
 
 #ifdef CCMIO_FILE  
   const char* ccmio_sufxs[] = { "ccm", "ccmg", NULL };
-  register_factory( NULL, WriteCCMIO::factory, "CCMIO files", ccmio_sufxs, "CCMIO");
-  register_factory( ReadCCMIO::factory, NULL, "CCMIO files", ccmio_sufxs, "CCMIO");
+  register_factory( ReadCCMIO::factory, WriteCCMIO::factory, "CCMIO files", ccmio_sufxs, "CCMIO");
 #endif
 
   register_factory( NULL, WriteGMV::factory, "GMV", "gmv", "GMV" );
@@ -147,12 +146,20 @@
 {
   if (!reader && !writer)
     return MB_FAILURE;
+    
+    // check for duplicate names
+  iterator h = handler_by_name( name );
+  if (h != end()) {
+    mbError->set_last_error( "Conflicting string name for file formats: \"%s\"",
+                             name );
+    return MB_FAILURE;
+  }
   
     // count extensions and check for duplicates
   const char* const* iter;
   for (iter = extensions; *iter; ++iter)
   {
-    iterator h = handler_from_extension( *iter );
+    h = handler_from_extension( *iter );
     if (h != end())
     {
       if (NULL != reader && h->have_reader())
@@ -245,8 +252,8 @@
     // try case-insensitive compare
   for (iter = begin(); iter != end(); ++iter)
   {
-    if ((with_reader && iter->have_reader()) ||
-        (with_writer && iter->have_writer()))
+    if ((with_reader && !iter->have_reader()) ||
+        (with_writer && !iter->have_writer()))
       continue;
  
     for (siter = iter->mExtensions.begin(); siter != iter->mExtensions.end(); ++siter)



More information about the moab-dev mailing list