Inside the function, a plugin is expected to tell MotionSampler how to construct each of the modules that the plugin implements. This is done using a special structure called a factory. A factory has one main purpose: it constructs classes of a specific type when its Fabricate() method is called. Just as each module is a subclass of PDLSource, PDLFilter, or PDLSink, a factory is a subclass of PDLSourceFactory, PDLFilterFactory, or PDLSinkFactory.
At start-up, plugins add a factory corresponding to each module they implement to the catalog pointer provided as an argument. The catalog is a list of module factories.
MotionSampler has three module catalogs: one for sources, one for filters, and one for sinks. At start-up, MotionSampler loads all the plugins it finds and calls each plugin's PDLInitializePlugin(). With each plugin, one or more factories are added to one of the module catalogs. When MotionSampler is finished starting, no modules have actually been constructed, but all the factories are available to create them when needed. MotionSampler creates the module lists in the pipeline editor by looking in each factory catalog and gathering module type names. A module is not actually constructed until you add it to a pipeline or until a pipeline including that module is retrieved from a file.
The following example adds to the last example by defining a factory capable of constructing a very basic filter class.
class ExampleFilt : public PDLFilter
struct ExFiltFactory : public PDLFilterFactory
PDLDeclarePluginID(PDL_FILTER_ID);
PDLInitializePlugin(void* catalog)
ExampleFilt::ExampleFilt(const char* n)
Each factory base class (PDLSourceFactory, PDLFilterFactory, PDLSinkFactory) provides a static method called AddPlugin() which is used to add the module factory to the catalog.
AddPlugin() takes three arguments:
PDLInitializePlugin(void* catalog)
(catalog, "ExampleFilt", new ExFiltFactory);
PDLFilterFactory::AddPlugin
(catalog, "ExampleFilt2", new ExFilt2Factory);
PDLFilterFactory::AddPlugin
(catalog, "ExampleFilt3", new ExFilt3Factory);
Copyright © 1997, Alias|Wavefront, a Silicon Graphics Company. All rights reserved.