[MOAB-dev] r5785 - in MOAB/trunk: src src/io src/moab test
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Wed Oct 10 23:47:21 CDT 2012
Author: tautges
Date: 2012-10-10 23:47:21 -0500 (Wed, 10 Oct 2012)
New Revision: 5785
Added:
MOAB/trunk/src/io/ReadTemplate.cpp
MOAB/trunk/src/io/ReadTemplate.hpp
Modified:
MOAB/trunk/src/Core.cpp
MOAB/trunk/src/ReaderWriterSet.cpp
MOAB/trunk/src/io/Makefile.am
MOAB/trunk/src/io/WriteTemplate.cpp
MOAB/trunk/src/io/WriteTemplate.hpp
MOAB/trunk/src/moab/Core.hpp
MOAB/trunk/src/moab/Interface.hpp
MOAB/trunk/src/moab/ReaderIface.hpp
MOAB/trunk/src/moab/ReaderWriterSet.hpp
MOAB/trunk/test/MBTest.cpp
MOAB/trunk/test/Makefile.am
Log:
Implemented a ReadTemplate class, to guide those writing new readers.
Also implemented the ability to have multiple readers handle the same file extension. If one reader
fails to read a given file, other readers that can read the file with that extension will be tried
until one succeeds or they all fail. This is to support reading netcdf files of varying formats
that come from the climate community, without having to read all the different formats in the same
class (which makes the reader really really complicated).
Specific changes are too numerous to list here. But, make check runs, in serial and in parallel.
Modified: MOAB/trunk/src/Core.cpp
===================================================================
--- MOAB/trunk/src/Core.cpp 2012-10-10 18:46:45 UTC (rev 5784)
+++ MOAB/trunk/src/Core.cpp 2012-10-11 04:47:21 UTC (rev 5785)
@@ -645,27 +645,38 @@
return rval;
// otherwise try using the file extension to select a reader
- ReaderIface* reader = set->get_file_extension_reader( file_name );
- if (reader)
+ std::string ext = set->extension_from_filename( file_name );
+
+ // Try all the readers
+ ReaderWriterSet::iterator iter;
+ rval = MB_FAILURE;
+ bool tried_one = false;
+ for (iter = set->begin(); iter != set->end(); ++iter)
{
- rval = reader->load_file( file_name, file_set, opts, subsets, id_tag );
- delete reader;
+ if (!iter->reads_extension(ext.c_str())) continue;
+
+ ReaderIface *reader = iter->make_reader( this );
+ if (NULL != reader)
+ {
+ tried_one = true;
+ rval = reader->load_file( file_name, file_set, opts, subsets, id_tag );
+ delete reader;
+ if (MB_SUCCESS == rval)
+ break;
+ clean_up_failed_read( initial_ents, initial_tags );
+ }
}
- else
- {
- // Try all the readers
- ReaderWriterSet::iterator iter;
+
+ if (MB_SUCCESS != rval && !tried_one) {
+ // didn't recognize the extension; try all of them now
for (iter = set->begin(); iter != set->end(); ++iter)
{
- reader = iter->make_reader( this );
- if (NULL != reader)
- {
- rval = reader->load_file( file_name, file_set, opts, subsets, id_tag );
- delete reader;
- if (MB_SUCCESS == rval)
- break;
- clean_up_failed_read( initial_ents, initial_tags );
- }
More information about the moab-dev
mailing list