![]() |
|
|
Generated: 24 Nov 2008 |
00001 // $Header: /local/reps/Gaudi/GaudiKernel/GaudiKernel/ToolFactory.h,v 1.9 2007/01/23 09:13:07 mato Exp $ 00002 #ifndef GAUDI_KERNEL_TOOLFACTORY_H 00003 #define GAUDI_KERNEL_TOOLFACTORY_H 00004 00005 #include "Reflex/PluginService.h" 00006 00007 // The following is needed to be backward compatible with the old factories of Gaudi. Otherwise the components 00008 // having the constructor/destructor protected will not be working 00009 00010 class IAlgTool; 00011 class IInterface; 00012 00013 template <typename T> class ToolFactory { 00014 public: static IAlgTool* create(const std::string& type, const std::string& name, IInterface *parent) { 00015 return new T(type, name, parent ); 00016 } 00017 }; 00018 00019 namespace { 00020 template < typename P > class Factory<P, IAlgTool*(std::string, std::string, const IInterface*)> { 00021 public: static void* Func( void*, const std::vector<void*>& arg, void*) { 00022 return ToolFactory<P>::create(*(std::string*)(arg[0]), *(std::string*)(arg[1]), (IInterface*)(arg[2])); 00023 } 00024 }; 00025 } 00026 00027 //---Specialization needed to overcome a problem with Reflex..... 00028 #ifndef TYPEDISTILLER_STRING_SPECIALIZATION 00029 #define TYPEDISTILLER_STRING_SPECIALIZATION 00030 namespace ROOT { 00031 namespace Reflex { 00032 template<> class TypeDistiller<std::string> { 00033 public: 00034 static Type Get() { 00035 return TypeBuilder("std::basic_string<char>"); 00036 } 00037 }; 00038 } 00039 } 00040 #endif 00041 00042 // Macros to declare components 00043 #define DECLARE_ALGTOOL(x) /*dummy*/ 00044 #define DECLARE_NAMESPACE_ALGTOOL(n,x) /*dummy*/ 00045 #define DECLARE_TOOL(x) /*dummy*/ 00046 #define DECLARE_NAMESPACE_TOOL(n,x) /*dummy*/ 00047 00048 // Macros to declare component factories 00049 #define DECLARE_TOOL_FACTORY(x) PLUGINSVC_FACTORY(x,IAlgTool*(std::string, std::string, const IInterface*)) 00050 #define DECLARE_NAMESPACE_TOOL_FACTORY(n,x) using n::x; PLUGINSVC_FACTORY(x,IAlgTool*(std::string, std::string, const IInterface*)) 00051 00052 #endif // GAUDI_KERNEL_TOOLFACTORY_H