[Insight-developers] IO : itkLoad, and CanReadFile()

Bill Hoffman bill.hoffman@kitware.com
Mon, 22 Oct 2001 00:05:08 -0400


At 09:32 PM 10/20/01 -0400, Luis Ibanez wrote:

>It sees that there are a couple of
>inconsistencies in the way factories
>are used in IO. I just checked in the
>classes:
>
>   itkMetaImageIOFactory and
>   itkMetaImageIO
>
>but run in the following problems:
>
>1) there is a global function itkLoad()
>    in itkPNGImageIOFactory, it returns
>    a pointer to a PNG IO factory casted
>    as a ImageIOFactoryBase.
>
>    Is that function supposed to be a member
>    method ?
>
>    How can other IO factories use it ?

The function has "C" linkage, and is used when the factory is loaded
from a shared library.  This models the photoshop plugin.  So, you can
add new file formats to an already linked executable.   This is how the 
ObjectFactoires work.


>2) the method "CanReadFile()" calls
>     "ReadHeader()" and depending on the
>    status returned by "ReadHeader()" it
>    returns a boolean.
>
>    Should we, then, when writing IOs
>    avoid to print error messages when
>    inconsistencies are found in the headers ?
>    and just return false in that case.
>
>    for example , in the test for MetaImage,
>    error messages appears comming from VOL
>    saying that it is not able to read the
>    header.  Should we maybe separate this
>    task and have a method that only test
>    the file for belonging to the right
>    class ?

CanReadFile should not report errors.   Sometimes it is easier to just
read the header, but if the ReadHeader function prints errors for the wrong
type of header, it should not be used.

For all registered IO factories the CanReadFile method is called to determine
the file type being loaded.   Once an IO object returns true for CanReadFile,
that object is then used for the read operation.


>Thanks
>
>
>Luis
>
>
>
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers@public.kitware.com
>http://public.kitware.com/mailman/listinfo/insight-developers