| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- File List
- File Members

# CnvFactory.h

Go to the documentation of this file.

    00001 // $Header: /local/reps/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 "Reflex/PluginService.h"
    00006 #include "GaudiKernel/ClassID.h"
    00007
    00008
    00009 // The following is needed to be backward compatible with the old factories of Gaudi. Otherwise the components
    00010 // having the constructor/destructor protected will not be working
    00011
    00012 class IConverter;
    00013 class ISvcLocator;
    00014
    00015 template <typename T> class CnvFactory {
    00016         public: static IConverter* create(ISvcLocator *svcloc) {
    00017     return new T(svcloc );
    00018   }
    00019 };
    00020
    00021 namespace {
    00022   template < typename P > class Factory<P, IConverter*(ISvcLocator*)> {
    00023     public: static void* Func( void*, const std::vector<void*>& arg, void*) {
    00024       return CnvFactory<P>::create((ISvcLocator*)(arg[0]));
    00025     }
    00026   };
    00027 }
    00028
    00029 // Identified class for converters
    00030
    00031 class ConverterID {
    00032   public:
    00033    ConverterID( long stype, CLID clid ) : m_stype(stype), m_clid(clid) {}
    00034    ~ConverterID() {}
    00035    bool operator ==(const ConverterID& id) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
    00036   private:
    00037    friend std::ostream& operator << ( std::ostream&, const ConverterID&);
    00038    long m_stype;
    00039    CLID m_clid;
    00040 };
    00041
    00042 inline std::ostream& operator << ( std::ostream& s, const ConverterID& id) {
    00043     s << "CNV_" << id.m_stype << "_" << id.m_clid;
    00044     return s;
    00045 }
    00046
    00047 #define DECLARE_GENERIC_CONVERTER(x) /* dummy */
    00048 #define DECLARE_NAMESPACE_GENERIC_CONVERTER(n,x) /* dummy */
    00049 #define DECLARE_CONVERTER(x) /*dummy*/
    00050 #define DECLARE_NAMESPACE_CONVERTER(n,x)   /*dummy */
    00051
    00052 // Macros to declare component factories
    00053 #define DECLARE_CONVERTER_FACTORY(x) \
    00054   PLUGINSVC_FACTORY_WITH_ID(x,ConverterID(x::storageType(),x::classID()),IConverter*(ISvcLocator*))
    00055
    00056 // Macros to declare component factories in a C++ namespace
    00057 #define DECLARE_NAMESPACE_CONVERTER_FACTORY(n,x) \
    00058 using n::x; PLUGINSVC_FACTORY_WITH_ID(x,ConverterID(x::storageType(),x::classID()),IConverter*(ISvcLocator*))
    00059
    00060 #endif // GAUDIKERNEL_CNVFACTORY_H