
Good Day, For the past few years, I have been exposed to both C++ software development as well as Java software development. I have been lucky enough to get to use many different frameworks from both languages (ACE in C++ and countless othes in Java). Introductions aside, I would like to ask whether a generic object factory implementation would be best put in a framework or a library. What I am looking for is something to the effect of the Spring [1] framework but in C++. With the issues like late/dynamic binding having many different implementations in many different platforms, the best I could conceptualize is a static template for different object types. What I'm looking for is something that will be able to allow me to forget about reimplementing the static factory every time I need it, and use a generic template instead. Something that will allow me the following functionalities: <code> // return a reference to a _huge_ statically allocated object, // too impractical to always instantiate whenever an instance of it // is needed: static_factory<Object> ObjectFactory; ... Object & object1 = ObjectFactory.getObject(); ... // later perhaps Object & object2 = ObjectFactory.getObject(); ... // later still Object & object3 = ObjectFactory.getObject(); </code> For other cases when I want a different instance returned every time I need a reference to something new, there's a dynamic_factory -- returning a pointer or reference to an object: <code> dynamic_factory<Object> ObjectFactory; Object instance1 = ObjectFactory.getObject(); std::auto_ptr<Object> instance2 (ObjectFactory.getObject()); </code> -- Of course, it is assumed that `Object' has a default constructor in both dynamic_factory and static_factory. Do you know of anything similar to these already? Otherwise, I would be most glad to put up a sample implementation soon. TIA PS. Perhaps XML definition files may be used to provide object registration when the factory is used dynamically to load object definitions from dynamic libraries. -- Dean Michael C. Berris <mikhailberis@free.net.ph> GPG Key: 0x08AE6EAC http://mikhailberis.blogspot.com Mobile: +63 921 7841815

On Sun, 10 Jul 2005 21:04:19 +0800, Dean Michael Berris wrote
Good Day,
...snip..
Do you know of anything similar to these already? Otherwise, I would be most glad to put up a sample implementation soon.
Might have a look in the 'vault': http://boost-sandbox.sourceforge.net/vault/ There is a proposed factory (factory3.zip looks to be the latest) which might do what you need. You can search back thru the mailing list to see discussions as well. Jeff

On Sun, 2005-07-10 at 07:00 -0700, Jeff Garland wrote:
Might have a look in the 'vault':
http://boost-sandbox.sourceforge.net/vault/
There is a proposed factory (factory3.zip looks to be the latest) which might do what you need. You can search back thru the mailing list to see discussions as well.
Wow, thanks for the reply. I'll take a look at this soon. Thanks for the link! :D -- Dean Michael C. Berris <mikhailberis@free.net.ph> GPG Key: 0x08AE6EAC http://mikhailberis.blogspot.com Mobile: +63 921 7841815

Introductions aside, I would like to ask whether a generic object factory implementation would be best put in a framework or a library. What I am looking for is something to the effect of the Spring [1] framework but in C++. With the issues like late/dynamic binding having many different implementations in many different platforms, the best I could conceptualize is a static template for different object types.
I've also implemented something of a smaller scale, when implementing reflection for win32gui. You can take a look at: http://www.torjo.com/win32gui/ (download v1.6.6. or v1.6.7) Then, take a look at reflection/detail/runtime_class.hpp Best, John -- John Torjo, Contributing editor, C/C++ Users Journal -- "Win32 GUI Generics" -- generics & GUI do mix, after all -- http://www.torjo.com/win32gui/ -v1.6.3 (Resource Splitter) -- http://www.torjo.com/cb/ - Click, Build, Run!

On Tue, 2005-07-19 at 22:09 +0200, John Torjo wrote:
I've also implemented something of a smaller scale, when implementing reflection for win32gui.
You can take a look at: http://www.torjo.com/win32gui/ (download v1.6.6. or v1.6.7)
Then, take a look at reflection/detail/runtime_class.hpp
Thanks. However, I was looking for something non-platform specific (or at least portable) -- more like how the STL is portable. The link is very much appreciated. :) -- Dean Michael C. Berris <mikhailberis@free.net.ph> GPG Key: 0x08AE6EAC http://mikhailberis.blogspot.com Mobile: +63 921 7841815
participants (3)
-
Dean Michael Berris
-
Jeff Garland
-
John Torjo