Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SvcFactory.h
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/SvcFactory.h,v 1.11 2008/10/09 21:00:37 marcocle Exp $
2 #ifndef KERNEL_SVCFACTORY_H
3 #define KERNEL_SVCFACTORY_H
4 
5 #include "Reflex/PluginService.h"
6 #include "RVersion.h"
7 
8 // The following is needed to be backward compatible with the old factories of Gaudi. Otherwise the components
9 // having the constructor/destructor protected will not be working
10 
11 class IService;
12 class ISvcLocator;
13 
14 template <typename T> class SvcFactory {
15 public:
16  static IService* create(const std::string& name, ISvcLocator *svcloc) {
17  return new T(name, svcloc );
18  }
19 };
20 
21 namespace {
22  template < typename P > class Factory<P, IService*(std::string, ISvcLocator*)> {
23  public:
24 #if ROOT_VERSION_CODE < ROOT_VERSION(5,21,6)
25  static void* Func( void*, const std::vector<void*>& arg, void*) {
26  return SvcFactory<P>::create(*(std::string*)(arg[0]), (ISvcLocator*)(arg[1]));
27  }
28 #else
29  static void Func( void *retaddr, void*, const std::vector<void*>& arg, void*) {
30  *(IService**) retaddr = SvcFactory<P>::create(*(std::string*)(arg[0]), (ISvcLocator*)(arg[1]));
31  }
32 #endif
33  };
34 }
35 
36 // Macros to declare component factories
37 
38 #define DECLARE_SERVICE_FACTORY(x) PLUGINSVC_FACTORY(x,IService*(std::string, ISvcLocator*))
39 #define DECLARE_NAMED_SERVICE_FACTORY(x,n) PLUGINSVC_FACTORY_WITH_ID(x,std::string(#n), IService*(std::string, ISvcLocator*))
40 #define DECLARE_NAMESPACE_SERVICE_FACTORY(n,x) using n::x; PLUGINSVC_FACTORY(x,IService*(std::string, ISvcLocator*))
41 #define DECLARE_SERVICE(x) /*dummy*/
42 #define DECLARE_NAMESPACE_SERVICE(n,x) /*dummy*/
43 
44 
45 #endif // GAUDIKERNEL_SVCFACTORY_H

Generated at Wed Jan 30 2013 17:13:40 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004