[Clam-devel] refactoring the Factory
Pau Arumi
parumi at iua.upf.edu
Thu May 31 01:21:15 PDT 2007
Andreas Calvo wrote:
> First steps towards getting an homogeneous plugin instantiation
> interfacion go through registering the ladspa plugins inside the
> CLAM::Factory (now it's doing using LadspaFactory, which it's slide
> different).
> So taking a close look to that, I've seen that the Factory it's a
> template (obviously) but it does have two sub-classes, Registry and
> Registrator (which I think are used to store and map the creators).
> I just wanted to make sure that's right, and if there is anything I've
> to take into consideration in order to start coding.
Hi Andreas,
Your question was gave me the perfect opportunity to document
those two Factory inner classes. (Commit 10161).
I paste it here:
/**
* This class is an implementation class of the Factory. It is
basically
* a container that maps keys with creators. It is not ment to
be used
* directly by the user.
*/
class Registry
/**
* This class provides a convenient way to add items (creators)
into a factory.
* To add class A (subclass of Base) to the factory it's useful to
declare a static
* Registrator object like this: static
Factory<Base>::Registrator<A> reg("key");
* The Registrator constructor called at load-time is in charge to
insert the creator
* to the factory.
* Various constructors exists giving the user options like using
either
* the singleton factory or a given one.
*/
template< typename ConcreteProductType>
class Registrator
About other things to take into account, well yes, my advice is
to start refactoring Factory (specifically Registry) to make
Creators classes instead of static methods.
With this we should be able to drop the current LadspaFactory
class and use the common one instead.
Further steps will consists on adding metadata (tags?) on the
ProcessingFactory and methods to list processing of a given
cathegory, and so on. That will probably ask for a
ProcessingFactory subclass since enriching the common factory is
not necessarily good (Simple Design). Anyway that's for later.
pau
More information about the clam-devel
mailing list