From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-04-29 01:04:22
Stefan Seefeld wrote:
> Vladimir Prus wrote:
>> You might know only base type of plugin and textual name, but don't know
>> the exact type you want to create. You also don't want to invoke
>> constructor by mangled name ;-)
> That's what factories are for. In fact, that's how all C++ plugins I'v
> worked with so far were designed. A single entry point in terms of a C
> linkage function that is *assumed* to return an object of a given type
> (interface), and let that do all the rest.
Right, and that approach is fine. But a library can add some details:
1. You won't have to write boilerplate code that creates a map from string
to function that creates a class, and the entry point that lookups in the
map and calls the function.
2. You will be able to pass arguments to constructor.
3. No portability problems.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk