| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

AlgFactory.h

Go to the documentation of this file.
00001 // $Header: /local/reps/Gaudi/GaudiKernel/GaudiKernel/AlgFactory.h,v 1.12 2008/11/27 14:21:06 marcocle Exp $
00002 #ifndef GAUDIKERNEL_ALGFACTORY_H
00003 #define GAUDIKERNEL_ALGFACTORY_H
00004 
00005 #include "Reflex/PluginService.h"
00006 #include "RVersion.h"
00007 
00008 // The following is needed to be backward compatible with the old factories of Gaudi. Otherwise the components
00009 // having the constructor/destructor protected will not be working
00010 
00011 class IAlgorithm;
00012 class ISvcLocator;
00013 
00014 template <typename T> class AlgFactory {
00015 public:
00016   static IAlgorithm* 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, IAlgorithm*(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 AlgFactory<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       *(IAlgorithm**) retaddr = AlgFactory<P>::create(*(std::string*)(arg[0]), (ISvcLocator*)(arg[1]));
00031     }
00032 #endif
00033   };
00034 }
00035 
00036 // Macros to declare component factories
00037 #define DECLARE_ALGORITHM_FACTORY(x)          PLUGINSVC_FACTORY(x,IAlgorithm*(std::string, ISvcLocator*))
00038 #define DECLARE_NAMED_ALGORITHM_FACTORY(x,n)  PLUGINSVC_FACTORY_WITH_ID(x,std::string(#n), IAlgorithm*(std::string, ISvcLocator*))
00039 
00040 #define DECLARE_NAMESPACE_ALGORITHM_FACTORY(n,x)  using n::x; PLUGINSVC_FACTORY(x,IAlgorithm*(std::string, ISvcLocator*))
00041 #define DECLARE_ALGORITHM(x)  /*dummy*/
00042 #define DECLARE_NAMESPACE_ALGORITHM(n,x) /*dummy*/
00043 
00044 #endif // GAUDIKERNEL_ALGFACTORY_H
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:56:57 2011 for GaudiKernel by doxygen 1.4.7