Gaudi Framework, version v22r0

Home   Generated: 9 Feb 2011

PoolDbCnvFactory.h

Go to the documentation of this file.
00001 // $Id: PoolDbCnvFactory.h,v 1.3 2006/11/22 18:10:43 hmd Exp $
00002 //====================================================================
00003 //      IPoolDbCnvFactory and PoolDbCnvFactory definition
00004 //--------------------------------------------------------------------
00005 //
00006 //      Author     : M.Frank
00007 //====================================================================
00008 #ifndef POOLDB_POOLDBCNVFACTORY_H
00009 #define POOLDB_POOLDBCNVFACTORY_H 1
00010 #include "GaudiKernel/ICnvFactory.h"
00011 #include "GaudiKernel/FactoryTable.h"
00012 #include "GaudiKernel/System.h"
00013 #include "StorageSvc/DbType.h"
00014 
00023 class GAUDI_API IPoolDbCnvFactory: virtual public IInterface {
00024 public:
00026   DeclareInterfaceID(IPoolDbCnvFactory,2,0);
00035   virtual IConverter* instantiate(long typ,
00036                                   const CLID& clid,
00037                                   ISvcLocator *svcloc )  const = 0;
00038 };
00039 
00048 template <class ConcreteConverter, int i>
00049 class GAUDI_API PoolDbCnvFactory : public implements2<ICnvFactory, IPoolDbCnvFactory>
00050 {
00052   mutable std::string m_typeName;
00053 public:
00055   typedef ConcreteConverter converter_t;
00056 
00058   PoolDbCnvFactory()  {
00059     m_typeName = "";
00060     FactoryTable::instance()->addFactory( this );
00061   }
00063   virtual ~PoolDbCnvFactory()  {  }
00065   virtual const std::string& typeName()  const    {
00066     // The name MUST be set here, not in the constructor.
00067     // At construction time it is not yet clear if we run from
00068     // an executable or a DLL.
00069     if ( m_typeName == "" )  {
00070       if ( System::moduleType() == System::SHAREDLIB )  {
00071         m_typeName  = System::moduleName();
00072         m_typeName += ":";
00073       }
00074       // Get the class name using the RTTI.
00075       m_typeName += System::typeinfoName( typeid(ConcreteConverter) );
00076     }
00077     return m_typeName;
00078   }
00080   virtual const CLID& objType()  const;
00082   virtual const long repSvcType()   const
00083   {    return pool::POOL_StorageType.type();  }
00084   virtual unsigned long addRef()  const     {     return 1;           }
00085   virtual unsigned long release()   const   {     return 1;           }
00086   virtual const std::string& ident() const  {     return typeName();  }
00087   // IInterface implementation
00088   virtual unsigned long addRef()            {     return 1;           }
00089   virtual unsigned long release()           {     return 1;           }
00090 
00099   virtual IConverter* instantiate(long typ,
00100                                   const CLID& /* clid */,
00101                                   ISvcLocator *svcloc)  const
00102   {    return new ConcreteConverter(typ, svcloc);  }
00103 
00105   virtual IConverter* instantiate( ISvcLocator* /* svcloc */ )  const
00106   {    return 0;  }
00107 
00109   virtual IInterface* instantiate( IInterface* /* parent */ ) const
00110   {    return 0;  }
00111 
00112 };
00113 #endif    // POOLDB_POOLDBCNVFACTORY_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Wed Feb 9 16:24:58 2011 for Gaudi Framework, version v22r0 by Doxygen version 1.6.2 written by Dimitri van Heesch, © 1997-2004