Dynamically creating classed by name?

Is there any way that, using Boost, you can dynamically create classes by name, similar to the MFC RUNTIME_CLASS macros? I was hoping that the boost::serialize libs might be able to help with this. For example, I want to be able to do something like: CMyClass* pClass = CREATE_CLASS_BY_NAME("CMyClass"); Can Boost help me to achieve this?

boost-users-bounces@lists.boost.org wrote:
Is there any way that, using Boost, you can dynamically create classes by name, similar to the MFC RUNTIME_CLASS macros? I was hoping that the boost::serialize libs might be able to help with this.
For example, I want to be able to do something like:
CMyClass* pClass = CREATE_CLASS_BY_NAME("CMyClass");
Can Boost help me to achieve this?
Is there any problem in using a conventional Factory solution and writing the macro yourself? I would suggest using the factory template introduced by Andrei Alexandrescu in his book "Modern C++ Design" and available with the Loki lib. See 'http://sourceforge.net/projects/loki-lib/' for details. Oliver

Note that a component of the serialization library "extended_type_info" addresses this issue (as it must) in order to de-serialize pointers. You might look in the serialization documentation. Robert Ramey Rob Caldecott wrote:
Is there any way that, using Boost, you can dynamically create classes by name, similar to the MFC RUNTIME_CLASS macros? I was hoping that the boost::serialize libs might be able to help with this.
For example, I want to be able to do something like:
CMyClass* pClass = CREATE_CLASS_BY_NAME("CMyClass");
Can Boost help me to achieve this?
participants (3)
-
Oliver Mutz
-
Rob Caldecott
-
Robert Ramey