[Insight-users] Pluggable Factories

Luis Ibanez luis.ibanez@kitware.com
Mon, 31 Mar 2003 22:18:02 -0500


Hi Ron,

There are two ways of registering your own ImageIO factories


1) In your main.cxx file (or any file where you
    have your main() function) invoke


    ObjectFactoryBase::RegisterFactory( XYZImageIOFactory::New() );

    where XYZ is the name of your file format.

    This is completly equivalent to call:


    XYZImageIOFactory::RegisterOneFactory();

    (if you see the definition of RegisterOneFactory in
     the .h files in Insight/Code/IO, you will find that
     it simply invoke ObjectFactoryBase::RegisterFactory)




OR



2) You can have your factory be automatically registered
    by modifying the file:

            ImageIOFactory.cxx

    in the directory:

          Insight/Code/IO

    starting in line 95, you will see the other file formats.
    (of course you will have to add the XXXImageIOFactory.h
    file to the #include lines).


Regards,


     Luis


--------------------------------

Ron Inbar wrote:
> Hi all,
> 
>  
> 
> I'm trying to write my own ImageIO subclass.
> 
> So far I just copied MetaImageIO, gave it a new name and changed the 
> file extension test in CanReadFile and CanWriteFile.
> 
> I saw the bit in the Software Guide about "pluggable factories", and I 
> understand from it that it should be possible to register my file type 
> to make ImageFileReader and ImageFileWriter automatically recognize it.  
> My question is: how?  I didn't find any explanation in the Software 
> Guide or elsewhere.
> 
> I tried using <my class>::RegisterOneFactory, but it doesn't seem to work yet, and I'm not sure 
> it's the right method.
> 
> Can you please give me an example of how this is done?
> 
>  
> 
> Thanks in advance,
> 
>  
> 
> Ron
> 
>  
> 
> ** 
> ** 
> *This e-mail message has been sent by MediGuide*
> *and is for the use of the intended recipients only.
> The message may contain privileged or confidential information .
> If you are not the intended recipient you are hereby notified that any use,
> distribution or copying of this communication is strictly prohibited,
> and you are requested to delete the e-mail and any attachments*
> *and notify the sender immediately.*