On May 23, 2011, at 11:09 AM, Sanatan Rai wrote:

> On 23 May 2011 16:00, Michael Wild <them...@gmail.com> wrote:
>> Everything that relies on static/global initialization to register
>> factories is an implicit scheme. An explicit scheme is where the
>> dependent code (e.g. the main() function) calls a function to do the
>> registration.
> 
>   Ok, got you. However, would this not imply a monolithic build? How is
> main to know that an object of a type belonging to a base class of interest
> exists in linked library?
> 
>   As I mentioned earlier, I did this a little more explicitly in a
> .NET project in the following
> manner:
> 
>  * I had a factory object, whose job it was to hold creator functions
> for objects of classes
>    derived from a base class of interest.
> 
> * The factory was a singleton, and had a static method that could be
> called. The method loaded
>   all linked assemblies, and picked out classes that were derived
> from the base class.
> 
>  * Then it explicitly registered the class with the factory.
> 
> This seems to me to be a hybrid between implicit and explicit
> registration. The actual mechanics
> as one might imagine relied heavily on .NET reflection calls. One of
> the ugliest bits of code I have
> ever written.
> 
> --Sanatan

Take a look at 
http://scm.bluequartz.net/mxa/mxadatamodel/trees/master/Code/MXA/DataImport for 
an example of how I did this in one of my older projects.

The code that ties this together is then in 
http://scm.bluequartz.net/mxa/mxadatamodel/blobs/master/Examples/DataImport/main.cpp

This should short enough for you to follow along. I am not saying mine is the 
utopian example but it does work.

Mike Jackson


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to