Boost logo

Boost :

From: Federico Stella (f.stella_at_[hidden])
Date: 2005-05-04 17:29:48


* martedì 03 maggio 2005, alle 21:56, Robert Geiman scrive:

[...]

> there is another difference between our two implementations. Mine is
> specifically made to register classes dynamically during runtime by
> calling the register() function of the factory object, while yours
> appears (and please correct me if I'm wrong) to be done via compile
> time. In other words, to add a derived3 class you must actually edit
> the boost::factory typedef to specifiy derived3 in the mpl::vector.
Yes, you're right.

[...]

>>Ideas? Comments? Bugs?

> Overall I like it! Quite an interesting approach to a problem I
> spent a lot of time working on.
Very well!

> Two things tho:

> I'm not certain I like the fact that you must create a builder class
> instance for every class you register. Any way to get rid of this or
> hide it in the factory class implementation itself?
Yes, it was boring... The main reason is declaring factory and registering
builders for types before entering main(). I've just upload a new version
(factory3.zip) that adds a new member new_creator<type>() for your needs.
I've also updated tutorial for showing this feature.

> Would it be possible to allow for derived classes to be added
> dynamically without the need to edit the declaration of the factory
> object itself? I know many boost users perfer compile-time solutions
> to run-time solutions, and certainly each of their own uses, but I've
> always like the ability to allow end-users to modify/extend programs
> simply by registering their classes with my factory object (IE, the
> user shouldn't need to recompile my code to do this).
I prefer the compile-time :), but joke aside C++ can't declare class at
runtime so declaring a typedef for all the products at compile-time seems
like a win for less runtime overhead. Maybe you could explain better what
this design lacks?

Fede.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk