| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# CnvFactory.h

Go to the documentation of this file.

    00001 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/CnvFactory.h,v 1.12 2006/12/06 17:18:03 mato Exp $
    00002 #ifndef GAUDIKERNEL_CNVFACTORY_H
    00003 #define GAUDIKERNEL_CNVFACTORY_H
    00004
    00005 #include "GaudiKernel/Kernel.h"
    00006 #include "Reflex/PluginService.h"
    00007 #include "GaudiKernel/ClassID.h"
    00008 #include "RVersion.h"
    00009
    00010
    00011 // The following is needed to be backward compatible with the old factories of Gaudi. Otherwise the components
    00012 // having the constructor/destructor protected will not be working
    00013
    00014 class IConverter;
    00015 class ISvcLocator;
    00016
    00017 template <typename T> class CnvFactory {
    00018 public:
    00019   static IConverter* create(ISvcLocator *svcloc) {
    00020     return new T(svcloc );
    00021   }
    00022 };
    00023
    00024 namespace {
    00025   template < typename P > class Factory<P, IConverter*(ISvcLocator*)> {
    00026   public:
    00027 #if ROOT_VERSION_CODE < ROOT_VERSION(5,21,6)
    00028     static void* Func( void*, const std::vector<void*>& arg, void*) {
    00029       return CnvFactory<P>::create((ISvcLocator*)(arg[0]));
    00030     }
    00031 #else
    00032     static void Func( void *retaddr, void*, const std::vector<void*>& arg, void*) {
    00033       *(IConverter**) retaddr = CnvFactory<P>::create((ISvcLocator*)(arg[0]));
    00034     }
    00035 #endif
    00036   };
    00037 }
    00038
    00039 // Identified class for converters
    00040
    00041 class GAUDI_API ConverterID {
    00042   public:
    00043    ConverterID( long stype, CLID clid ) : m_stype(stype), m_clid(clid) {}
    00044    ~ConverterID() {}
    00045    bool operator ==(const ConverterID& id) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
    00046   private:
    00047    friend std::ostream& operator << ( std::ostream&, const ConverterID&);
    00048    long m_stype;
    00049    CLID m_clid;
    00050 };
    00051
    00052 inline std::ostream& operator << ( std::ostream& s, const ConverterID& id) {
    00053     s << "CNV_" << id.m_stype << "_" << id.m_clid;
    00054     return s;
    00055 }
    00056
    00057 #define DECLARE_GENERIC_CONVERTER(x) /* dummy */
    00058 #define DECLARE_NAMESPACE_GENERIC_CONVERTER(n,x) /* dummy */
    00059 #define DECLARE_CONVERTER(x) /*dummy*/
    00060 #define DECLARE_NAMESPACE_CONVERTER(n,x)   /*dummy */
    00061
    00062 // Macros to declare component factories
    00063 #define DECLARE_CONVERTER_FACTORY(x) \
    00064   PLUGINSVC_FACTORY_WITH_ID(x,ConverterID(x::storageType(),x::classID()),IConverter*(ISvcLocator*))
    00065
    00066 // Macros to declare component factories in a C++ namespace
    00067 #define DECLARE_NAMESPACE_CONVERTER_FACTORY(n,x) \
    00068 using n::x; PLUGINSVC_FACTORY_WITH_ID(x,ConverterID(x::storageType(),x::classID()),IConverter*(ISvcLocator*))
    00069
    00070 #endif // GAUDIKERNEL_CNVFACTORY_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines