| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# SvcFactory.h

Go to the documentation of this file.

    00001 // $Header: /local/reps/Gaudi/GaudiKernel/GaudiKernel/SvcFactory.h,v 1.11 2008/10/09 21:00:37 marcocle Exp $
    00002 #ifndef KERNEL_SVCFACTORY_H
    00003 #define KERNEL_SVCFACTORY_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 IService;
    00011 class ISvcLocator;
    00012
    00013 template <typename T> class SvcFactory {
    00014         public: static IService* create(const std::string& name, ISvcLocator *svcloc) {
    00015     return new T(name, svcloc );
    00016   }
    00017 };
    00018
    00019 namespace {
    00020   template < typename P > class Factory<P, IService*(std::string, ISvcLocator*)> {
    00021     public: static void* Func( void*, const std::vector<void*>& arg, void*) {
    00022       return SvcFactory<P>::create(*(std::string*)(arg[0]), (ISvcLocator*)(arg[1]));
    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 // Macros to declare component factories
    00042
    00043 #define DECLARE_SERVICE_FACTORY(x)              PLUGINSVC_FACTORY(x,IService*(std::string, ISvcLocator*))
    00044 #define DECLARE_NAMED_SERVICE_FACTORY(x,n)      PLUGINSVC_FACTORY_WITH_ID(x,std::string(#n), IService*(std::string, ISvcLocator*))
    00045 #define DECLARE_NAMESPACE_SERVICE_FACTORY(n,x)  using n::x; PLUGINSVC_FACTORY(x,IService*(std::string, ISvcLocator*))
    00046 #define DECLARE_SERVICE(x)  /*dummy*/
    00047 #define DECLARE_NAMESPACE_SERVICE(n,x) /*dummy*/
    00048
    00049
    00050 #endif // GAUDIKERNEL_SVCFACTORY_H