00001
00002 #ifndef KERNEL_SVCFACTORY_H
00003 #define KERNEL_SVCFACTORY_H
00004
00005 #include "Reflex/PluginService.h"
00006 #include "RVersion.h"
00007
00008
00009
00010
00011 class IService;
00012 class ISvcLocator;
00013
00014 template <typename T> class SvcFactory {
00015 public:
00016 static IService* create(const std::string& name, ISvcLocator *svcloc) {
00017 return new T(name, svcloc );
00018 }
00019 };
00020
00021 namespace {
00022 template < typename P > class Factory<P, IService*(std::string, ISvcLocator*)> {
00023 public:
00024 #if ROOT_VERSION_CODE < ROOT_VERSION(5,21,6)
00025 static void* Func( void*, const std::vector<void*>& arg, void*) {
00026 return SvcFactory<P>::create(*(std::string*)(arg[0]), (ISvcLocator*)(arg[1]));
00027 }
00028 #else
00029 static void Func( void *retaddr, void*, const std::vector<void*>& arg, void*) {
00030 *(IService**) retaddr = SvcFactory<P>::create(*(std::string*)(arg[0]), (ISvcLocator*)(arg[1]));
00031 }
00032 #endif
00033 };
00034 }
00035
00036
00037
00038 #define DECLARE_SERVICE_FACTORY(x) PLUGINSVC_FACTORY(x,IService*(std::string, ISvcLocator*))
00039 #define DECLARE_NAMED_SERVICE_FACTORY(x,n) PLUGINSVC_FACTORY_WITH_ID(x,std::string(#n), IService*(std::string, ISvcLocator*))
00040 #define DECLARE_NAMESPACE_SERVICE_FACTORY(n,x) using n::x; PLUGINSVC_FACTORY(x,IService*(std::string, ISvcLocator*))
00041 #define DECLARE_SERVICE(x)
00042 #define DECLARE_NAMESPACE_SERVICE(n,x)
00043
00044
00045 #endif // GAUDIKERNEL_SVCFACTORY_H