
On Fri, Feb 29, 2008 at 7:47 PM, Tobias Schwinger <tschwinger@isonews2.com> wrote:
I'm writing to gauge interest in an 'abstract factory', very similar to the recently accepted functional/factory.
Why not simply use factory/function combination?
typedef boost::function< A*(string, int) > AFactory; typedef boost::factory< B* > BFactory;
That's quite nice... I didn't know you could do that. But this is no good for modularization, correct? Please note that in this case, BFactory is the "concrete factory" but it
does not know about that role. It's "virtualized from the outside".
[...]
For the transform you might get away without the dynamic call (that is if you don't need type erasure on the factory for modularization):
This was actually half the motivation for creating abstract_factory. I needed a way of reducing cyclic linker dependencies (VC++). A simple way of doing that is to virtualize methods, but of course you can't do that for constructors. I needed a virtual constructor of some sort. The other reason came from working with the Loki::AbstractFactory but becoming frustrated with not being able to pass parameters into the Create method. abstract_factory can be used a a component to create a Loki::AbstractFactory without this limitation. I've put abstract_factory.hpp in the vault if you'd like to take a look, along with an example that uses Loki::AbstractFactory, here: http://www.boost-consulting.com/vault/index.php?action=downloadfile&filename=abstract_factory.zip&directory=& Cheers, Stathi