#include <RawDataCnvSvc.h>
Inheritance diagram for RawDataCnvSvc:
Public Member Functions | |
virtual StatusCode | initialize () |
virtual StatusCode | finalize () |
virtual StatusCode | declareObject (const IRawDataCnvSvc::Leaf &leaf) |
Associates a path on TDS with a particular converter. | |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface) |
Override inherited queryInterface due to enhanced interface. | |
virtual StatusCode | createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) |
virtual StatusCode | createAddress (long storageType, const CLID &clid, const std::string &, IOpaqueAddress *&refpAddress) |
Protected Member Functions | |
virtual StatusCode | addConverters ()=0 |
StatusCode | updateServiceState (IOpaqueAddress *pAddress) |
Update state of the service. | |
RawDataCnvSvc (const std::string &name, ISvcLocator *svc, long storageTyp) | |
virtual | ~RawDataCnvSvc () |
Private Types | |
typedef std::map< std::string, Leaf * > | LeafMap |
Map with leaf entries containing TDS paths. | |
Private Attributes | |
LeafMap | m_leaves |
Friends | |
class | SvcFactory< RawDataCnvSvc > |
When a component requests an item not yet available on the TDS, the RawDataCnvSvc is called to find the appropriate converter to gain access to the data and put it on the TDS.
Based on GLAST's EfbCnvSvc
Definition at line 23 of file RawDataCnvSvc.h.
typedef std::map<std::string, Leaf*> RawDataCnvSvc::LeafMap [private] |
RawDataCnvSvc::RawDataCnvSvc | ( | const std::string & | name, | |
ISvcLocator * | svc, | |||
long | storageTyp | |||
) | [protected] |
virtual RawDataCnvSvc::~RawDataCnvSvc | ( | ) | [inline, protected, virtual] |
virtual StatusCode RawDataCnvSvc::addConverters | ( | ) | [protected, pure virtual] |
StatusCode RawDataCnvSvc::createAddress | ( | long | storageType, | |
const CLID & | clid, | |||
const std::string & | , | |||
IOpaqueAddress *& | refpAddress | |||
) | [virtual] |
Definition at line 184 of file RawDataCnvSvc.cxx.
References createAddress().
00188 { 00189 return createAddress(storageType, clid, NULL, NULL, refpAddress); 00190 }
StatusCode RawDataCnvSvc::createAddress | ( | long | svc_type, | |
const CLID & | clid, | |||
const std::string * | par, | |||
const unsigned long * | ip, | |||
IOpaqueAddress *& | refpAddress | |||
) | [virtual] |
Definition at line 162 of file RawDataCnvSvc.cxx.
References calibUtil::ERROR, and msgSvc().
Referenced by createAddress(), and updateServiceState().
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 }
StatusCode RawDataCnvSvc::declareObject | ( | const IRawDataCnvSvc::Leaf & | leaf | ) | [virtual] |
Associates a path on TDS with a particular converter.
Implements IRawDataCnvSvc.
Definition at line 83 of file RawDataCnvSvc.cxx.
References m_leaves, IRawDataCnvSvc::Leaf::path, and dchain::value_type().
Referenced by PackedRawDataCnvSvc::addConverters().
00083 { 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 }
StatusCode RawDataCnvSvc::finalize | ( | ) | [virtual] |
Definition at line 74 of file RawDataCnvSvc.cxx.
References m_leaves.
00074 { 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 }
StatusCode RawDataCnvSvc::initialize | ( | ) | [virtual] |
Reimplemented in PackedRawDataCnvSvc.
Definition at line 28 of file RawDataCnvSvc.cxx.
References addConverters(), calibUtil::ERROR, for, ganga-rec::j, m_leaves, and deljobs::string.
Referenced by PackedRawDataCnvSvc::initialize().
00028 { 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 }
StatusCode RawDataCnvSvc::queryInterface | ( | const InterfaceID & | riid, | |
void ** | ppvInterface | |||
) | [virtual] |
Override inherited queryInterface due to enhanced interface.
Reimplemented in PackedRawDataCnvSvc.
Definition at line 150 of file RawDataCnvSvc.cxx.
References IID_IRawDataCnvSvc().
00150 { 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 }
StatusCode RawDataCnvSvc::updateServiceState | ( | IOpaqueAddress * | pAddress | ) | [protected] |
Update state of the service.
Reimplemented in PackedRawDataCnvSvc.
Definition at line 96 of file RawDataCnvSvc.cxx.
References createAddress(), if(), ir, m_leaves, msgSvc(), and deljobs::string.
Referenced by PackedRawDataCnvSvc::updateServiceState().
00096 { 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 }
friend class SvcFactory< RawDataCnvSvc > [friend] |
Definition at line 25 of file RawDataCnvSvc.h.
LeafMap RawDataCnvSvc::m_leaves [private] |
Definition at line 29 of file RawDataCnvSvc.h.
Referenced by declareObject(), finalize(), initialize(), and updateServiceState().