/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RawDataCnvBase/RawDataCnvBase-01-00-03/src/RawDataCnvSvc.cxx

Go to the documentation of this file.
00001 #include "GaudiKernel/SmartDataPtr.h" 
00002 #include "GaudiKernel/SmartIF.h"
00003 #include "GaudiKernel/SvcFactory.h"
00004 #include "GaudiKernel/CnvFactory.h"
00005 #include "GaudiKernel/MsgStream.h"
00006 
00007 #include "GaudiKernel/ISvcLocator.h"
00008 #include "GaudiKernel/IDataProviderSvc.h"
00009 #include "GaudiKernel/IDataManagerSvc.h"
00010 #include "GaudiKernel/RegistryEntry.h"
00011 #include "GaudiKernel/GenericAddress.h"
00012 
00013 #include "RawDataCnvBase/RawDataBaseCnv.h"
00014 #include "RawDataCnvBase/RawDataCnvSvc.h"
00015 #include "EventModel/EventModel.h"
00016 #include <iostream>
00017 
00018 static const InterfaceID IID_IRawDataCnvSvc("IRawDataCnvSvc", 1 , 0); 
00019 
00020 // RCS Id for identification of object version
00021 // static const char* rcsid = "$Id: RawDataCnvSvc.cxx,v 1.12 2011/02/17 01:14:23 maqm Exp $";
00022 
00023 RawDataCnvSvc::RawDataCnvSvc(const std::string& name, ISvcLocator* svc, long storageType)
00024 : ConversionSvc(name, svc, storageType)              
00025 {
00026 }
00027 
00028 StatusCode RawDataCnvSvc::initialize()     {
00029     // Purpose and Method:  Setup Converter Service.
00030     //   Associate RawDataCnvSvc with the EventDataSvc
00031     //   Associate the list of known converters with this RawDataCnvSvc.
00032 
00033     MsgStream log(messageService(), name());
00034  
00035     StatusCode iret;
00036     StatusCode status = ConversionSvc::initialize();
00037     if ( status.isSuccess() )   {
00038 
00039         IDataProviderSvc *pIDP = 0;
00040         // Set event data service
00041         status = service("EventDataSvc", pIDP, true);
00042         if ( status.isSuccess() )   {
00043             status = setDataProvider ( pIDP );
00044         }
00045         else    {
00046             return status;
00047         }
00048 
00049         // Add converters to the service 
00050         status = addConverters();
00051         if ( !status.isSuccess() )   {
00052           log << MSG::ERROR << "Unable to add converters to the service" << endreq;
00053           return status;
00054         }
00055 
00056         // Now we have to configure the map of leaves
00057         // Which should contain the association of converters with 
00058         // paths on the TDS
00059         for (LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ )   {
00060             std::string path = (*k).first;
00061             for (LeafMap::iterator j = m_leaves.begin(); j != m_leaves.end(); j++ )   {
00062                 std::string pp = (*j).first.substr(0, (*j).first.rfind("/"));
00063                 if ( path == pp && path != (*j).first )   {
00064                     (*k).second->push_back((*j).second);
00065                 }
00066             }
00067         }
00068         
00069     }
00070 
00071     return status;
00072 }
00073 
00074 StatusCode RawDataCnvSvc::finalize()     {
00075     StatusCode status = ConversionSvc::finalize();
00076     for (LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ )   {
00077         delete (*k).second;
00078     }
00079     m_leaves.erase(m_leaves.begin(), m_leaves.end());
00080     return status;
00081 }
00082 
00083 StatusCode RawDataCnvSvc::declareObject(const IRawDataCnvSvc::Leaf& leaf)   {
00084     // Purpose and Method:  Callback from each of the individual converters that allows
00085     //  association of TDS path and converter.
00086     Leaf* ll = new Leaf(leaf);
00087     std::pair<LeafMap::iterator, bool> p = m_leaves.insert(LeafMap::value_type( leaf.path, ll) );
00088     if( p.second )    {
00089         return StatusCode::SUCCESS;
00090     }
00091     delete ll;
00092     return StatusCode::FAILURE;
00093 }
00094 
00096 StatusCode RawDataCnvSvc::updateServiceState(IOpaqueAddress* pAddress)    {
00097     
00098     // not sure about the use of recid or bank...
00099     MsgStream log(msgSvc(), name());
00100     
00101     StatusCode status = INVALID_ADDRESS;
00102     IRegistry* ent = pAddress->registry();
00103 
00104     if ( 0 != ent )   {
00105       SmartIF<IDataManagerSvc> iaddrReg( dataProvider());
00106  //       if ( 0 != iaddrReg )   {
00107       status = StatusCode::SUCCESS;
00108       std::string path = ent->identifier();
00109 
00110       LeafMap::iterator itm = m_leaves.find(path);
00111       if ( itm != m_leaves.end() ) {
00112         IRawDataCnvSvc::Leaf* leaf = (*itm).second;
00113         if ( 0 != leaf )    {
00114           //ipar[0] = leaf->userParameter;
00115           for ( Leaf::iterator il = leaf->begin(); il != leaf->end(); il++ )   {
00116             IOpaqueAddress* newAddr = 0;
00117             unsigned long ipars[2] = {0, 0}; //{(*il)->userParameter, new_rid};
00118             const std::string spars[2] = {"", ""}; //{par[0], (*il)->bank};
00119             /* fix for Gaidi V16r4  -- Weidong Li 2005.10.25 
00120             StatusCode ir =
00121               addressCreator()->createAddress(storageType, 
00122                                               (*il)->clid, 
00123                                               spars, 
00124                                               ipars,
00125                                               newAddr);
00126             */
00127             StatusCode ir = createAddress(repSvcType(), 
00128                                               (*il)->clid, 
00129                                               spars, 
00130                                               ipars,
00131                                               newAddr);
00132             if ( ir.isSuccess() )   {
00133               ir = iaddrReg->registerAddress((*il)->path, newAddr);            
00134               if ( !ir.isSuccess() )    {
00135                 newAddr->release();
00136                 status = ir;
00137               }
00138             }
00139           }
00140         }
00141       }
00142     }
00143     else  {
00144        status = NO_INTERFACE;
00145     }
00146     
00147     return status;
00148 }
00149 
00150 StatusCode RawDataCnvSvc::queryInterface(const InterfaceID& riid, void** ppvInterface)  {
00151     if ( IID_IRawDataCnvSvc == riid )  {
00152         *ppvInterface = (IRawDataCnvSvc*)this;
00153     }
00154     else  {
00155         // Interface is not directly availible: try out a base class
00156         return ConversionSvc::queryInterface(riid, ppvInterface);
00157     }
00158     addRef();
00159     return StatusCode::SUCCESS;
00160 }
00161 
00162 StatusCode RawDataCnvSvc::createAddress(long storageType,
00163                                         const CLID& clid,
00164                                         const std::string*, 
00165                                         const unsigned long*,
00166                                         IOpaqueAddress*& refpAddress) 
00167 {
00168     MsgStream log( msgSvc(), name() );
00169     
00170     if (storageType != repSvcType() ) {
00171         log << MSG::ERROR << "bad storage type" << storageType << endreq;
00172         return StatusCode::FAILURE;
00173     }
00174 
00175     refpAddress = new GenericAddress(storageType,
00176                                      clid,
00177                                      "",  
00178                                      "",
00179                                      0);
00180 
00181     return StatusCode::SUCCESS;
00182 }
00183 
00184 StatusCode RawDataCnvSvc::createAddress(long storageType,
00185                                         const CLID& clid,
00186                                         const std::string&,
00187                                         IOpaqueAddress*& refpAddress)
00188 {
00189   return createAddress(storageType, clid, NULL, NULL, refpAddress);
00190 }

Generated on Tue Nov 29 22:58:34 2016 for BOSS_7.0.2 by  doxygen 1.4.7