| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# PoolDbKeyedContainerCnv.cpp

Go to the documentation of this file.

    00001 // $Id: PoolDbKeyedContainerCnv.cpp,v 1.8 2008/01/17 13:20:51 marcocle Exp $
    00002 //====================================================================
    00003 //      KeyedContainerCnv implementation
    00004 //--------------------------------------------------------------------
    00005 //
    00006 //      Package    : System ( The LHCb Offline System)
    00007 //
    00008 //  Description: Generic Db data converter for container objects
    00009 //
    00010 //      Author     : M.Frank
    00011 //====================================================================
    00012 #include "GaudiKernel/ObjectList.h"
    00013 #include "GaudiKernel/ObjectVector.h"
    00014 #include "GaudiKernel/KeyedContainer.h"
    00015 #include "GaudiKernel/IUpdateable.h"
    00016 #include "GaudiPoolDb/PoolDbBaseCnv.h"
    00017 #include "GaudiPoolDb/PoolDbKeyedContainerCnv.h"
    00018 #include "GaudiKernel/CnvFactory.h"
    00019 #include "StorageSvc/DbInstanceCount.h"
    00020
    00021
    00022 namespace {
    00023   union ObjectTypes {
    00024     ObjectTypes(DataObject* p) { Object = p; }
    00025     DataObject*                                             Object;
    00026     ObjectContainerBase*                                    Base;
    00027     ObjectList<ContainedObject>*                            List;
    00028     ObjectVector<ContainedObject>*                          Vector;
    00029     KeyedContainer<KeyedObject<long>, Containers::Map>*     KeyMap;
    00030     KeyedContainer<KeyedObject<long>, Containers::HashMap>* KeyHashMap;
    00031     KeyedContainer<KeyedObject<long>, Containers::Array>*   KeyArray;
    00032     StatusCode update(int flag)  {
    00033       IUpdateable* obj = dynamic_cast<IUpdateable*>(Object);
    00034       if ( obj ) {
    00035         return obj->update(flag);
    00036       }
    00037       return StatusCode::FAILURE;
    00038     }
    00039   };
    00040 }
    00041
    00043 PoolDbKeyedContainerCnv::PoolDbKeyedContainerCnv(long typ, const CLID& clid, ISvcLocator* svc)
    00044 : PoolDbBaseCnv( typ, clid, svc )
    00045 {
    00046   pool::DbInstanceCount::increment(this);
    00047 }
    00048
    00050 PoolDbKeyedContainerCnv::~PoolDbKeyedContainerCnv()    {
    00051   pool::DbInstanceCount::decrement(this);
    00052 }
    00053
    00055 StatusCode
    00056 PoolDbKeyedContainerCnv::updateObjRefs(IOpaqueAddress* pAddr, DataObject* pObj)
    00057 {
    00058   StatusCode sc = PoolDbBaseCnv::updateObjRefs(pAddr, pObj);
    00059   if ( sc.isSuccess() )  {
    00060     ObjectTypes obj(pObj);
    00061     const CLID id = (m_objGuid.Data1&0xFFFF0000);
    00062     switch(id) {
    00063     case CLID_ObjectList:              /* ObjectList               */
    00064       return StatusCode::SUCCESS;
    00065     case CLID_ObjectVector:            /* ObjectVector             */
    00066       return StatusCode::SUCCESS;
    00067     case CLID_ObjectVector+0x0030000:  /* Keyed object map         */
    00068       obj.KeyMap->configureDirectAccess();
    00069       return StatusCode::SUCCESS;
    00070     case CLID_ObjectVector+0x0040000:  /* Keyed object hashmap     */
    00071       obj.KeyHashMap->configureDirectAccess();
    00072       return StatusCode::SUCCESS;
    00073     case CLID_ObjectVector+0x0050000:  /* Keyed indirection array  */
    00074       obj.KeyArray->configureDirectAccess();
    00075       return StatusCode::SUCCESS;
    00076     case 0:                            /* Any other object         */
    00077       return StatusCode::SUCCESS;
    00078     default:
    00079       return obj.update(0);
    00080     }
    00081     // cannot reach this point
    00082   }
    00083   return sc;
    00084 }
    00085
    00086 PLUGINSVC_FACTORY_WITH_ID( PoolDbKeyedContainerCnv,
    00087                            ConverterID(POOL_StorageType,CLID_Any + CLID_ObjectVector+0x00030000),
    00088                            IConverter*(long, CLID, ISvcLocator*) )
    00089 PLUGINSVC_FACTORY_WITH_ID( PoolDbKeyedContainerCnv,
    00090                            ConverterID(POOL_StorageType,CLID_Any + CLID_ObjectVector+0x00040000),
    00091                            IConverter*(long, CLID, ISvcLocator*) )
    00092 PLUGINSVC_FACTORY_WITH_ID( PoolDbKeyedContainerCnv,
    00093                            ConverterID(POOL_StorageType,CLID_Any + CLID_ObjectVector+0x00050000),
    00094                            IConverter*(long, CLID, ISvcLocator*) )
    00095 PLUGINSVC_FACTORY_WITH_ID( PoolDbKeyedContainerCnv,
    00096                            ConverterID(POOL_StorageType,CLID_Any | (1<<31)),
    00097                            IConverter*(long, CLID, ISvcLocator*) )