[Insight-developers] One possible framework for Image
I/O...
Bill Hoffman
bill.hoffman@kitware.com
Tue, 19 Dec 2000 10:29:35 -0500
--=====================_926947469==_.ALT
Content-Type: text/plain; charset="us-ascii"
Hi Parag,
I have been looking at your Maker class. The article on
pluggable factories was quite good. I do think that with
slight modification the ObjectFactory could be used for
what you want. This would avoid the confusion of having several
ways of doing something in the same system.
Although the ObjectFactory can use RTTI, it is not required.
At the end of the day, all you need is the virtual function
itkObject* CreateInstance(const char*);
I have recently added some features to the vtk object factory,
that I plan to add to the itk object factory. Would it be sufficient
for your needs if ObjectFactory allowed you to register creation
objects based on a string, that CreateInstance would use?
Why does your key have to be templated?
/**
* protected function used by sub classes of ObjectFactory to register
* creation objects with a given string name. This would be put
* into a map, and used when CreateInstance is called with
* classOverride as the string.
*/
void ObjectFactory::RegisterOverride(const char* classOverride,
const char* overrideClassName,
const char* description,
int enableFlag,
CreateObject* createObject);
The CreateObject, would be very similar to the itkCommand object, except
it would have a function that returned objects instead of just an
Execute function.
The advantage of working with the itk ObjectFactory framework , is that \
it supports dynamic loading and registration of factories.
You could create a dll with your MetaImage ObjectFactory sub class, with
all the registered CreateObjects for the keys you want to create, then
just put it in ITK_AUTOLOAD_PATH, and any pre-compiled itk executable
would be able to load MetaImages. It allows the system to be both
Open (you can add stuff at run time) and Closed (the executable is compiled, and the interface is locked in).
-Bill
>2. I felt that itkMaker was necessary because there does not seem to be a
>way to use ObjectFactory to instantiate subclasses based on a user-supplied
>key value. ObjectFactory seems to use RTTI to automatically determine which
>class to instantiate and return.
--=====================_926947469==_.ALT
Content-Type: text/html; charset="us-ascii"
Hi Parag,
I have been looking at your Maker class. The article on
pluggable factories was quite good. I do think that
with
slight modification the ObjectFactory could be used for
what you want. This would avoid the confusion of having
several
ways of doing something in the same system.
Although the ObjectFactory can use RTTI, it is not required.
At the end of the day, all you need is the virtual function
itkObject* CreateInstance(const char*);
I have recently added some features to the vtk object factory,
that I plan to add to the itk object factory. Would it be
sufficient
for your needs if ObjectFactory allowed you to register creation
objects based on a string, that CreateInstance would use?
Why does your key have to be templated?
/**
* protected function used by sub classes of
ObjectFactory to register
* creation objects with a given string
name. This would be put
* into a map, and used when CreateInstance is called
with
* classOverride as the string.
*/
void ObjectFactory::RegisterOverride(const char* classOverride,
const char* overrideClassName,
const char* description,
int enableFlag,
CreateObject* createObject);
The CreateObject, would be very similar to the itkCommand object,
except
it would have a function that returned objects instead of just an
Execute function.
The advantage of working with the itk ObjectFactory framework , is that
\
it supports dynamic loading and registration of factories.
You could create a dll with your MetaImage ObjectFactory sub class,
with
all the registered CreateObjects for the keys you want to create,
then
just put it in ITK_AUTOLOAD_PATH, and any pre-compiled itk executable
would be able to load MetaImages. It allows the system to be
both
Open (you can add stuff at run time) and Closed (the executable is
compiled, and the interface is locked in).
-Bill
2. I felt that itkMaker was necessary because
there does not seem to be a
way to use ObjectFactory to instantiate subclasses based on a
user-supplied
key value. ObjectFactory seems to use RTTI to automatically determine
which
class to instantiate and return.