Gaudi Framework, version v24r2

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

Generated at Wed Dec 4 2013 14:33:08 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004