[MOAB-dev] Reader/Writer filename extension access

Robert Smith smithrm at mcs.anl.gov
Thu Apr 29 15:49:54 CDT 2010


I'm looking for some comments on Ticket #142 and my thoughts below.

Ticket #142 asks for 3 things from the Reader/Writer interface:

       1) Given an extension or filename, get the name or actual  
reader/writer that can handle it
     2a) Get the extensions a reader/writer handles and
     2b) possibly all the readers/writers registered.

I believe 1) is covered by the existing interface on ReaderWriterSet.   
The get_file_extension_reader/ get_file_extension_writer functions do  
this.

For 2b) this could be done fairly easily.  Just return a vector of  
ReaderIface* or WriterIface*.  I'm not sure what this would be used  
for but it could be done.

It is 2a) that is more tricky.  Currently the extensions are  
registered with a Reader and/or Writer factory method directly in the  
ReaderWriterSet constructor.  This is the only place the extensions  
are known.   What 2a) is asking is to go from an object instance of a  
subclass of ReaderIface or WriterIface and retrieve these associated  
extensions.

I see 2 possibilities:

     A - have a function that searches through the ReaderWriterSet  
list of registered factory methods and matches the factory method on a  
particular subclass of ReaderIface/WriterIface.

     B - move the extensions to the actual Reader/Writer classes as a  
static data member that could be returned by either a static member  
function (for use in registration in ReaderWriterSet) or a virtual  
function defined on ReaderIface (for use to solve 2a) above).

I'm not sure 'A' really works but it seems as though it should.   
ReaderIface/WriterIface would have new virtual functions to request  
the information.  These would be implemented in the Reader/Writer  
classes as requests to the ReaderWriterSet passing in the function  
pointer of their own static factory function.

For 'B' the technical aspects of the implementation are  
straightforward.  The complication comes from the fact that you can  
register a Reader, a Writer or both for a set of extensions.  To do  
'B' simply we could put the static extension data into both a Reader  
and Writer class if both existed.  And then in ReaderWriterSet just  
choose which one you would use in the registration.

This is not ideal as we have duplicated data.  A possible solution  
would be to add in IoXxx classes (I'm open to better names).  For  
example, create an IoGmsh class.  It would have the extensions as  
static data and methods to access them.  This IoGmsh class could also  
contain the format name string and description strings also.   
ReaderGmsh/WriterGmsh would then inherit from this IoGmsh class in  
addition to ReaderIface.  See attached file for example code.

This implementation could also handle the instances of multiple  
extension sets and format names as is the case for ReadCGM by making  
the extensions an array of arrays of char* and the format an array of  
char*.

My preferred approach would be 'A' as it involves little disruption to  
the current design.  But I'm not sure it will work.  Option 'B'  
involves more changes and multiple inheritance.

I'm also wondering at the utility of this functionality in the first  
place.  When would someone have a ReaderIface* to a Reader/Writer  
object and want to know the extensions it supports?

Any thoughts would be appreciated.

--Bob

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ReadWriteExtensions.txt
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20100429/3aa2b44a/attachment.txt>
-------------- next part --------------





More information about the moab-dev mailing list