[vtkusers] Object Factories

Gerald Dalley dalleyg at ee.eng.ohio-state.edu
Wed Aug 9 08:56:54 EDT 2000


I've been using VTK 2.4 (and have the 2.0 users' guide) and expect to
upgrade to 3.1 sometime soon.  One of the features that I've noticed in 3.1
is the object factories.  When using Java, I had grown accustomed to
language features such as reflection and introspection.  They can
effectively act as built-in factories and are used for things such as
JavaBeans.

In the work I'm doing, I have several different applications that must
serialize and deserialize portions of a VTK pipeline.  Right now, I'm using
a rather crude method that requires code such as the following for
deserialization:
	while there are more tokens
		read token
		if token == "vtkAbcFilter" then
			...
			filter = vtkAbcFilter::New();
			...
		else if token == "vtkDefFilter" then
			...
			filter = vtkDefFilter::New();
			...
		...
	end while
This means that every time I create a new filter class, I am required to
tweak the reader code manually.

Instead of the above process, I'd like to do something more like:
	while there are more tokens
		read token
		filter = factor->CreateInstance(token);
		...
	end while
My question now is: If I use the object factories, the VTK_AUTOLOAD_PATH,
etc., can I create new DLLs/shared libraries in the VTK_AUTOLOAD_PATH and
automatically have VTK be able to create all of the VTK objects in them?

--Gerald Dalley
  dalleyg at ee.eng.ohio-state.edu
  dalleyg at dma.org





More information about the vtkusers mailing list