![]() |
|
|
Generated: 18 Jul 2008 |
#include <NTupleSvc.h>
Inheritance diagram for NTupleSvc:


See the Interface definition files for more detailed documentation of the implementing class. Base class: Gaudi/DataSvc/DataSvc.h Generic N tuple service interface: Gaudi/Interfaces/INTupleSvc.h Generic IAddressCreator interface: Gaudi/Interfaces/IAddressCreator.h Generic IConversionSvc interface: Gaudi/Interfaces/IConversionSvc.h
Definition at line 27 of file NTupleSvc.h.
Public Member Functions | |
| virtual StatusCode | initialize () |
| DataSvc overrides: Initialize the service. | |
| virtual StatusCode | reinitialize () |
| DataSvc overrides: reinitialize service. | |
| virtual StatusCode | finalize () |
| DataSvc overrides: stop the service. | |
| virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface) |
| DataSvc overrides: Query interface. | |
| virtual IConversionSvc * | getDataLoader (IRegistry *pReg) |
| DataSvc overrides: Retrieve data loader. | |
| virtual NTuple::Directory * | createDirectory (DataObject *pParent, const std::string &title) |
| Create Ntuple directory and register it with the data store. | |
| virtual NTuple::Directory * | createDirectory (DataObject *pParent, long id) |
| Create Ntuple directory and register it with the data store. | |
| virtual NTuple::Directory * | createDirectory (const std::string &dirPath, long id) |
| Create Ntuple directory and register it with the data store. | |
| virtual NTuple::Directory * | createDirectory (const std::string &dirPath, const std::string &title) |
| Create Ntuple directory and register it with the data store. | |
| virtual NTuple::Directory * | createDirectory (const std::string &fullPath) |
| Create Ntuple directory and register it with the data store. | |
| virtual StatusCode | create (const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple) |
| Create requested N tuple (Hide constructor). | |
| virtual NTuple::Tuple * | book (const std::string &fullPath, const CLID &type, const std::string &title) |
| Book Ntuple and register it with the data store. | |
| virtual NTuple::Tuple * | book (const std::string &dirPath, const std::string &relPath, const CLID &type, const std::string &title) |
| Book Ntuple and register it with the data store. | |
| virtual NTuple::Tuple * | book (const std::string &dirPath, long id, const CLID &type, const std::string &title) |
| Book Ntuple and register it with the data store. | |
| virtual NTuple::Tuple * | book (DataObject *pParent, const std::string &relPath, const CLID &type, const std::string &title) |
| Book Ntuple and register it with the data store. | |
| virtual NTuple::Tuple * | book (DataObject *pParent, long id, const CLID &type, const std::string &title) |
| Book Ntuple and register it with the data store. | |
| virtual NTuple::Tuple * | access (const std::string &fullPath, const std::string &filename) |
| Access N tuple on disk. | |
| virtual StatusCode | save (const std::string &fullPath) |
| Save N tuple to disk. Must be called in order to close the ntuple file properly. | |
| virtual StatusCode | save (NTuple::Tuple *tuple) |
| Save N tuple to disk. Must be called in order to close the ntuple file properly. | |
| virtual StatusCode | save (DataObject *pParent, const std::string &relPath) |
| Save N tuple to disk. Must be called in order to close the ntuple file properly. | |
| virtual StatusCode | writeRecord (NTuple::Tuple *tuple) |
| Write single record to N tuple. | |
| virtual StatusCode | writeRecord (const std::string &fullPath) |
| Write single record to N tuple. | |
| virtual StatusCode | writeRecord (DataObject *pParent, const std::string &relPath) |
| Write single record to N tuple. | |
| virtual StatusCode | readRecord (NTuple::Tuple *tuple) |
| Read single record from N tuple. | |
| virtual StatusCode | readRecord (const std::string &fullPath) |
| Read single record from N tuple. | |
| virtual StatusCode | readRecord (DataObject *pParent, const std::string &relPath) |
| Read single record from N tuple. | |
| virtual bool | isConnected (const std::string &identifier) const |
| Check if a datasource is connected. | |
| virtual StatusCode | connect (const std::string &ident) |
| Add file to list I/O list. | |
| virtual StatusCode | connect (const std::string &ident, std::string &logname) |
| Add file to list I/O list. | |
| virtual StatusCode | disconnect (const std::string &nam) |
| Close open connection. | |
| virtual StatusCode | disconnectAll () |
| Close all open connections. | |
| NTupleSvc (const std::string &name, ISvcLocator *svc) | |
| Standard Constructor. | |
| virtual | ~NTupleSvc () |
| Standard Destructor. | |
Protected Types | |
| typedef std::vector< std::string > | DBaseEntries |
| typedef std::map< std::string, Connection > | Connections |
| typedef std::pair< std::string, std::string > | Prop |
Protected Member Functions | |
| StatusCode | createService (const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc) |
| Create conversion service. | |
| void | releaseConnection (Connection &c) |
| Finalize single service. | |
| StatusCode | attachTuple (const std::string &filename, const std::string &logname, const char typ, const long t) |
| Attach output/input file. | |
| StatusCode | updateDirectories () |
| Update directory data. | |
Protected Attributes | |
| DBaseEntries | m_output |
| Output streams. | |
| DBaseEntries | m_input |
| Input streams. | |
| Connections | m_connections |
| Container of connection points. | |
Friends | |
| class | SvcFactory< NTupleSvc > |
Classes | |
| struct | Connection |
typedef std::vector< std::string > NTupleSvc::DBaseEntries [protected] |
Definition at line 39 of file NTupleSvc.h.
typedef std::map<std::string, Connection> NTupleSvc::Connections [protected] |
Definition at line 40 of file NTupleSvc.h.
typedef std::pair<std::string,std::string> NTupleSvc::Prop [protected] |
Definition at line 41 of file NTupleSvc.h.
| NTupleSvc::NTupleSvc | ( | const std::string & | name, | |
| ISvcLocator * | svc | |||
| ) |
Standard Constructor.
Definition at line 54 of file NTupleSvc.cpp.
References CLID_DataObject.
00055 : DataSvc(name, svc) 00056 { 00057 declareProperty("Input", m_input); 00058 declareProperty("Output", m_output); 00059 m_rootName = "/NTUPLES"; 00060 m_rootCLID = CLID_DataObject; 00061 }
| NTupleSvc::~NTupleSvc | ( | ) | [virtual] |
| StatusCode NTupleSvc::initialize | ( | ) | [virtual] |
DataSvc overrides: Initialize the service.
Reimplemented from DataSvc.
Reimplemented in TagCollectionSvc.
Definition at line 68 of file NTupleSvc.cpp.
References std::vector< _Tp, _Alloc >::begin(), connect(), std::vector< _Tp, _Alloc >::end(), DataSvc::initialize(), StatusCode::isSuccess(), m_input, m_output, DataSvc::m_rootName, Service::setProperties(), DataSvc::setRoot(), and StatusCode::SUCCESS.
Referenced by TagCollectionSvc::initialize().
00068 { 00069 StatusCode status = DataSvc::initialize(); 00070 if ( status.isSuccess() ) { 00071 status = setProperties(); 00072 if ( status.isSuccess() ) { 00073 StatusCode iret(StatusCode::SUCCESS,true); 00074 DataObject* root = new NTuple::Directory(); 00075 status = setRoot(m_rootName, root); 00076 for ( DBaseEntries::iterator i = m_output.begin(); i != m_output.end(); ++i ) { 00077 iret = connect(*i); 00078 if ( !iret.isSuccess() ) { 00079 status = iret; 00080 } 00081 } 00082 for ( DBaseEntries::iterator j = m_input.begin(); j != m_input.end(); ++j ) { 00083 iret = connect(*j); 00084 if ( !iret.isSuccess() ) { 00085 status = iret; 00086 } 00087 } 00088 } 00089 } 00090 return status; 00091 }
| StatusCode NTupleSvc::reinitialize | ( | ) | [virtual] |
DataSvc overrides: reinitialize service.
Reimplemented from DataSvc.
Definition at line 94 of file NTupleSvc.cpp.
References StatusCode::SUCCESS.
00094 { 00095 return StatusCode::SUCCESS; 00096 }
| StatusCode NTupleSvc::finalize | ( | ) | [virtual] |
DataSvc overrides: stop the service.
Reimplemented from DataSvc.
Reimplemented in TagCollectionSvc.
Definition at line 209 of file NTupleSvc.cpp.
References DataSvc::clearStore(), disconnectAll(), DataSvc::finalize(), and updateDirectories().
Referenced by TagCollectionSvc::finalize().
00209 { 00210 StatusCode status = updateDirectories(); 00211 status = clearStore(); 00212 status = DataSvc::finalize(); 00213 status = disconnectAll(); 00214 return status; 00215 }
| StatusCode NTupleSvc::queryInterface | ( | const InterfaceID & | riid, | |
| void ** | ppvInterface | |||
| ) | [virtual] |
DataSvc overrides: Query interface.
Reimplemented from DataSvc.
Definition at line 218 of file NTupleSvc.cpp.
References IInterface::addRef(), IID_IDataSourceMgr, IID_INTupleSvc, DataSvc::queryInterface(), and StatusCode::SUCCESS.
00218 { 00219 if ( IID_INTupleSvc == riid ) 00220 *ppvInterface = (INTupleSvc*)this; 00221 else if ( IID_IDataSourceMgr == riid ) 00222 *ppvInterface = (IDataSourceMgr*)this; 00223 else // Interface is not directly availible: try out a base class 00224 return DataSvc::queryInterface(riid, ppvInterface); 00225 addRef(); 00226 return StatusCode::SUCCESS; 00227 }
| IConversionSvc * NTupleSvc::getDataLoader | ( | IRegistry * | pReg | ) | [virtual] |
DataSvc overrides: Retrieve data loader.
Reimplemented from DataSvc.
Definition at line 105 of file NTupleSvc.cpp.
References std::basic_string< _CharT, _Traits, _Alloc >::find(), IRegistry::identifier(), std::basic_string< _CharT, _Traits, _Alloc >::length(), m_connections, DataSvc::m_rootName, std::basic_string< _CharT, _Traits, _Alloc >::npos, Gaudi::Utils::Histos::path(), IDataProviderSvc::SEPARATOR, and std::basic_string< _CharT, _Traits, _Alloc >::substr().
Referenced by createDirectory(), readRecord(), updateDirectories(), and writeRecord().
00105 { 00106 if ( 0 != pRegistry ) { 00107 std::string full = pRegistry->identifier(); 00108 size_t len = m_rootName.length(); 00109 size_t idx = full.find(SEPARATOR,len+1); 00110 std::string path = (idx==std::string::npos) ? full : full.substr(0, idx); 00111 Connections::iterator i = m_connections.find(path); 00112 if ( i != m_connections.end() ) { 00113 return (*i).second.service; 00114 } 00115 } 00116 return 0; 00117 }
| NTuple::Directory * NTupleSvc::createDirectory | ( | DataObject * | pParent, | |
| const std::string & | title | |||
| ) | [virtual] |
Create Ntuple directory and register it with the data store.
Implements INTupleSvc.
Definition at line 468 of file NTupleSvc.cpp.
References IRegistry::identifier(), and DataObject::registry().
Referenced by book(), and createDirectory().
00469 { 00470 if ( 0 != pParent ) { 00471 IRegistry* pDir = pParent->registry(); 00472 if ( 0 != pDir ) { 00473 std::string full = pDir->identifier(); 00474 full += (relPath[0]=='/') ? "" : "/"; 00475 full += relPath; 00476 return createDirectory(full); 00477 } 00478 } 00479 return 0; 00480 }
| NTuple::Directory * NTupleSvc::createDirectory | ( | DataObject * | pParent, | |
| long | id | |||
| ) | [virtual] |
Create Ntuple directory and register it with the data store.
Implements INTupleSvc.
Definition at line 483 of file NTupleSvc.cpp.
References _itoa(), and createDirectory().
00483 { 00484 char txt[32]; 00485 return createDirectory( pParent, ::_itoa(id, txt,10) ); 00486 }
| NTuple::Directory * NTupleSvc::createDirectory | ( | const std::string & | dirPath, | |
| long | id | |||
| ) | [virtual] |
Create Ntuple directory and register it with the data store.
Implements INTupleSvc.
Definition at line 489 of file NTupleSvc.cpp.
References _itoa(), and createDirectory().
00489 { 00490 char txt[32]; 00491 return createDirectory( dirPath, ::_itoa(id, txt,10) ); 00492 }
| NTuple::Directory * NTupleSvc::createDirectory | ( | const std::string & | dirPath, | |
| const std::string & | title | |||
| ) | [virtual] |
Create Ntuple directory and register it with the data store.
Implements INTupleSvc.
Definition at line 495 of file NTupleSvc.cpp.
References createDirectory().
00495 { 00496 std::string full = dirPath; 00497 full += (relPath[0]=='/') ? "" : "/"; 00498 full += relPath; 00499 return createDirectory(full); 00500 }
| NTuple::Directory * NTupleSvc::createDirectory | ( | const std::string & | fullPath | ) | [virtual] |
Create Ntuple directory and register it with the data store.
Implements INTupleSvc.
Definition at line 526 of file NTupleSvc.cpp.
References createDirectory(), DataSvc::findObject(), getDataLoader(), StatusCode::isSuccess(), DataSvc::registerObject(), std::basic_string< _CharT, _Traits, _Alloc >::rfind(), IDataProviderSvc::SEPARATOR, std::basic_string< _CharT, _Traits, _Alloc >::substr(), and DataSvc::unregisterObject().
00526 { 00527 NTuple::Directory* p = 0; 00528 StatusCode status = findObject(fullPath, *pp_cast<DataObject>(&p)); 00529 if ( !status.isSuccess() ) { 00530 int sep2 = fullPath.rfind(SEPARATOR); 00531 if ( sep2 > 0 ) { 00532 std::string relPath = fullPath.substr(0, sep2); 00533 p = createDirectory(relPath); 00534 if ( 0 != p ) { 00535 p = new NTuple::Directory(); 00536 // Finally register the created N tuple with the store 00537 status = registerObject(fullPath, p); 00538 if ( status.isSuccess() ) { 00539 // ...starting from the file entries 00540 IConversionSvc* svc = getDataLoader(p->registry()); 00541 if ( 0 != svc ) { 00542 IOpaqueAddress* pAddr = 0; 00543 status = svc->createRep (p, pAddr); 00544 if ( status.isSuccess() ) { 00545 p->registry()->setAddress(pAddr); 00546 status = svc->fillRepRefs (pAddr, p); 00547 if ( status.isSuccess() ) { 00548 return p; 00549 } 00550 } 00551 } 00552 unregisterObject(p); 00553 } 00554 p->release(); 00555 p = 0; 00556 } 00557 } 00558 } 00559 try { 00560 p = dynamic_cast<NTuple::Directory*>(p); 00561 return p; 00562 } 00563 catch (...) { 00564 } 00565 return 0; 00566 }
| StatusCode NTupleSvc::create | ( | const CLID & | typ, | |
| const std::string & | title, | |||
| NTuple::Tuple *& | refpTuple | |||
| ) | [virtual] |
Create requested N tuple (Hide constructor).
Eventually allow loading through factory?
Implements INTupleSvc.
Definition at line 370 of file NTupleSvc.cpp.
References CLID_ColumnWiseTuple, CLID_RowWiseTuple, StatusCode::FAILURE, NTuple::TupleImp::setTupleService(), and StatusCode::SUCCESS.
Referenced by book().
00370 { 00371 NTuple::TupleImp* pTuple = 0; 00372 StatusCode status = StatusCode::FAILURE; 00373 if ( typ == CLID_ColumnWiseTuple ) { 00374 pTuple = new NTuple::ColumnWiseTuple( title ); 00375 } 00376 else if ( typ == CLID_RowWiseTuple ) { 00377 pTuple = new NTuple::RowWiseTuple( title ); 00378 } 00379 else { 00381 } 00382 if ( 0 != pTuple ) { 00383 pTuple->setTupleService(this); 00384 status = StatusCode::SUCCESS; 00385 } 00386 refpTuple = pTuple; 00387 return status; 00388 }
| NTuple::Tuple * NTupleSvc::book | ( | const std::string & | fullPath, | |
| const CLID & | type, | |||
| const std::string & | title | |||
| ) | [virtual] |
Book Ntuple and register it with the data store.
Implements INTupleSvc.
Definition at line 391 of file NTupleSvc.cpp.
References createDirectory(), endmsg(), MSG::ERROR, StatusCode::isSuccess(), std::basic_string< _CharT, _Traits, _Alloc >::length(), DataSvc::m_rootName, Service::msgSvc(), Service::name(), Gaudi::Utils::Histos::path(), DataSvc::retrieveObject(), std::basic_string< _CharT, _Traits, _Alloc >::rfind(), and IDataProviderSvc::SEPARATOR.
Referenced by book().
00391 { 00392 DataObject* pObj = 0; 00393 std::string path = fullPath; 00394 MsgStream log(msgSvc(), name()); 00395 if ( path[0] != SEPARATOR ) { 00396 path = m_rootName; 00397 path += SEPARATOR; 00398 path += fullPath; 00399 } 00400 StatusCode status = retrieveObject(path, pObj); 00401 if ( !status.isSuccess() ) { 00402 int sep = path.rfind(SEPARATOR); 00403 if ( sep > 0 ) { 00404 std::string p_path (path, 0, sep); 00405 std::string o_path (path, sep, path.length()); 00406 DataObject* dir = createDirectory(p_path); 00407 if ( 0 != dir ) { 00408 NTuple::Tuple* tup = book( dir, o_path, type, title); 00409 if ( 0 == tup ) { 00410 log << MSG::ERROR << "Cannot book N-tuple " << path << " (Unknown reason)" << endmsg; 00411 } 00412 return tup; 00413 } 00414 log << MSG::ERROR << "Cannot book N-tuple " << path << " (Invalid parent directory)" << endmsg; 00415 return 0; 00416 } 00417 log << MSG::ERROR << "Cannot book N-tuple " << path << " (Invalid path)" << endmsg; 00418 return 0; 00419 } 00420 log << MSG::ERROR << "Cannot book N-tuple " << path << " (Exists already)" << endmsg; 00421 return 0; 00422 }
| NTuple::Tuple * NTupleSvc::book | ( | const std::string & | dirPath, | |
| const std::string & | relPath, | |||
| const CLID & | type, | |||
| const std::string & | title | |||
| ) | [virtual] |
Book Ntuple and register it with the data store.
Implements INTupleSvc.
Definition at line 425 of file NTupleSvc.cpp.
References book(), and IDataProviderSvc::SEPARATOR.
00425 { 00426 std::string full = dirPath; 00427 if (relPath[0] != SEPARATOR) full += SEPARATOR; 00428 full += relPath; 00429 return book(full, type, title); 00430 }
| NTuple::Tuple * NTupleSvc::book | ( | const std::string & | dirPath, | |
| long | id, | |||
| const CLID & | type, | |||
| const std::string & | title | |||
| ) | [virtual] |
Book Ntuple and register it with the data store.
Implements INTupleSvc.
Definition at line 433 of file NTupleSvc.cpp.
References _itoa(), and book().
| NTuple::Tuple * NTupleSvc::book | ( | DataObject * | pParent, | |
| const std::string & | relPath, | |||
| const CLID & | type, | |||
| const std::string & | title | |||
| ) | [virtual] |
Book Ntuple and register it with the data store.
Implements INTupleSvc.
Definition at line 439 of file NTupleSvc.cpp.
References create(), DataSvc::findObject(), StatusCode::isSuccess(), and DataSvc::registerObject().
00439 { 00440 NTuple::Tuple* pObj = 0; 00441 // Check if object is already present 00442 StatusCode status = findObject(pParent, relPath, *pp_cast<DataObject>(&pObj)); 00443 // No ? Then create it! 00444 if ( !status.isSuccess() ) { 00445 status = create( type, title, pObj); 00446 if ( status.isSuccess() ) { 00447 // Finally register the created N tuple with the store 00448 status = registerObject(pParent, relPath, pObj); 00449 if ( status.isSuccess() ) { 00450 return pObj; 00451 } 00452 pObj->release(); 00453 } 00454 } 00455 return 0; 00456 }
| NTuple::Tuple * NTupleSvc::book | ( | DataObject * | pParent, | |
| long | id, | |||
| const CLID & | type, | |||
| const std::string & | title | |||
| ) | [virtual] |
Book Ntuple and register it with the data store.
Implements INTupleSvc.
Definition at line 459 of file NTupleSvc.cpp.
References _itoa(), and book().
| NTuple::Tuple * NTupleSvc::access | ( | const std::string & | fullPath, | |
| const std::string & | filename | |||
| ) | [virtual] |
Access N tuple on disk.
Implements INTupleSvc.
Definition at line 569 of file NTupleSvc.cpp.
References Service::msgSvc(), and Service::name().
| StatusCode NTupleSvc::save | ( | const std::string & | fullPath | ) | [virtual] |
Save N tuple to disk. Must be called in order to close the ntuple file properly.
Implements INTupleSvc.
Definition at line 575 of file NTupleSvc.cpp.
References DataSvc::findObject(), IDataProviderSvc::INVALID_OBJ_PATH, StatusCode::isSuccess(), Service::msgSvc(), and Service::name().
Referenced by save().
00575 { 00576 MsgStream log ( msgSvc(), name() ); 00577 NTuple::Tuple* pObj = 0; 00578 StatusCode status = findObject(fullPath, *pp_cast<DataObject>(&pObj)); // Check if object is present 00579 if ( status.isSuccess() ) { 00580 return save ( pObj ); 00581 } 00582 return INVALID_OBJ_PATH; 00583 }
| StatusCode NTupleSvc::save | ( | NTuple::Tuple * | tuple | ) | [virtual] |
Save N tuple to disk. Must be called in order to close the ntuple file properly.
Implements INTupleSvc.
Definition at line 586 of file NTupleSvc.cpp.
References IRegistry::address(), NTuple::TupleImp::conversionService(), IDataProviderSvc::INVALID_OBJECT, StatusCode::isSuccess(), IDataProviderSvc::NO_DATA_LOADER, DataObject::registry(), IConverter::updateRep(), and IConverter::updateRepRefs().
00586 { 00587 NTuple::TupleImp* tuple = (NTuple::TupleImp*)n_tuple; 00588 if ( 0 != tuple ) { 00589 try { 00590 IConversionSvc* pSvc = tuple->conversionService(); 00591 IRegistry* pReg = tuple->registry(); 00592 if ( 0 != pSvc && 0 != pReg ) { 00593 IOpaqueAddress* pAddr = pReg->address(); 00594 StatusCode status = pSvc->updateRep(pAddr, n_tuple); 00595 if ( status.isSuccess() ) { 00596 status = pSvc->updateRepRefs(pAddr, n_tuple); 00597 } 00598 return status; 00599 } 00600 return IDataProviderSvc::NO_DATA_LOADER; 00601 } 00602 catch(...) { 00603 } 00604 } 00605 return INVALID_OBJECT; 00606 }
| StatusCode NTupleSvc::save | ( | DataObject * | pParent, | |
| const std::string & | relPath | |||
| ) | [virtual] |
Save N tuple to disk. Must be called in order to close the ntuple file properly.
Implements INTupleSvc.
Definition at line 609 of file NTupleSvc.cpp.
References DataSvc::findObject(), IDataProviderSvc::INVALID_OBJ_PATH, StatusCode::isSuccess(), and save().
00609 { 00610 NTuple::Tuple* pObj = 0; 00611 StatusCode status = findObject(pParent, relPath, *pp_cast<DataObject>(&pObj)); // Check if object is present 00612 if ( status.isSuccess() ) { 00613 return save ( pObj ); 00614 } 00615 return INVALID_OBJ_PATH; 00616 }
| StatusCode NTupleSvc::writeRecord | ( | NTuple::Tuple * | tuple | ) | [virtual] |
Write single record to N tuple.
Implements INTupleSvc.
Definition at line 619 of file NTupleSvc.cpp.
References IRegistry::address(), NTuple::TupleImp::conversionService(), IConverter::createRep(), IConverter::fillRepRefs(), getDataLoader(), IDataProviderSvc::INVALID_OBJECT, StatusCode::isSuccess(), IDataProviderSvc::NO_DATA_LOADER, DataObject::registry(), IRegistry::setAddress(), and NTuple::TupleImp::setConversionService().
Referenced by writeRecord().
00619 { 00620 NTuple::TupleImp* tuple = (NTuple::TupleImp*)n_tuple; 00621 if ( 0 != tuple ) { 00622 try { 00623 IConversionSvc* pSvc = tuple->conversionService(); 00624 if ( 0 == pSvc ) { 00625 pSvc = getDataLoader(n_tuple->registry()); 00626 tuple->setConversionService(pSvc); 00627 } 00628 if ( 0 != pSvc ) { 00629 IRegistry* pReg = n_tuple->registry(); 00630 IOpaqueAddress* pAddr = pReg->address(); 00631 StatusCode status = pSvc->createRep(n_tuple, pAddr); 00632 if ( status.isSuccess() ) { 00633 pReg->setAddress(pAddr); 00634 status = pSvc->fillRepRefs(pAddr, n_tuple); 00635 } 00636 return status; 00637 } 00638 return IDataProviderSvc::NO_DATA_LOADER; 00639 } 00640 catch(...) { 00641 } 00642 } 00643 return INVALID_OBJECT; 00644 }
| StatusCode NTupleSvc::writeRecord | ( | const std::string & | fullPath | ) | [virtual] |
Write single record to N tuple.
Implements INTupleSvc.
Definition at line 647 of file NTupleSvc.cpp.
References DataSvc::findObject(), IDataProviderSvc::INVALID_OBJ_PATH, StatusCode::isSuccess(), and writeRecord().
00647 { 00648 NTuple::Tuple* pObj = 0; 00649 StatusCode status = findObject(fullPath, *pp_cast<DataObject>(&pObj)); // Check if object is present 00650 if ( status.isSuccess() ) { 00651 return writeRecord ( pObj ); 00652 } 00653 return INVALID_OBJ_PATH; 00654 }
| StatusCode NTupleSvc::writeRecord | ( | DataObject * | pParent, | |
| const std::string & | relPath | |||
| ) | [virtual] |
Write single record to N tuple.
Implements INTupleSvc.
Definition at line 657 of file NTupleSvc.cpp.
References DataSvc::findObject(), IDataProviderSvc::INVALID_OBJ_PATH, StatusCode::isSuccess(), and writeRecord().
00657 { 00658 NTuple::Tuple* pObj = 0; 00659 StatusCode status = findObject(pParent, relPath, *pp_cast<DataObject>(&pObj)); // Check if object is present 00660 if ( status.isSuccess() ) { 00661 return writeRecord ( pObj ); 00662 } 00663 return INVALID_OBJ_PATH; 00664 }
| StatusCode NTupleSvc::readRecord | ( | NTuple::Tuple * | tuple | ) | [virtual] |
Read single record from N tuple.
Implements INTupleSvc.
Definition at line 667 of file NTupleSvc.cpp.
References IRegistry::address(), NTuple::TupleImp::conversionService(), getDataLoader(), IDataProviderSvc::INVALID_OBJECT, StatusCode::isSuccess(), IDataProviderSvc::NO_DATA_LOADER, DataObject::registry(), NTuple::TupleImp::setConversionService(), IConverter::updateObj(), and IConverter::updateObjRefs().
Referenced by readRecord().
00667 { 00668 StatusCode status = INVALID_OBJECT; 00669 NTuple::TupleImp* tuple = (NTuple::TupleImp*)n_tuple; 00670 if ( 0 != tuple ) { 00671 try { 00672 IConversionSvc* pSvc = tuple->conversionService(); 00673 if ( 0 == pSvc ) { 00674 pSvc = getDataLoader(n_tuple->registry()); 00675 tuple->setConversionService(pSvc); 00676 } 00677 if ( 0 != pSvc ) { 00678 IRegistry* pReg = n_tuple->registry(); 00679 IOpaqueAddress* pAddr = pReg->address(); 00680 status = pSvc->updateObj(pAddr, n_tuple); 00681 if ( status.isSuccess() ) { 00682 status = pSvc->updateObjRefs(pAddr, n_tuple); 00683 } 00684 return status; 00685 } 00686 status = IDataProviderSvc::NO_DATA_LOADER; 00687 } 00688 catch(...) { 00689 status = INVALID_OBJECT; 00690 } 00691 } 00692 return status; 00693 }
| StatusCode NTupleSvc::readRecord | ( | const std::string & | fullPath | ) | [virtual] |
Read single record from N tuple.
Implements INTupleSvc.
Definition at line 696 of file NTupleSvc.cpp.
References DataSvc::findObject(), IDataProviderSvc::INVALID_OBJ_PATH, StatusCode::isSuccess(), and readRecord().
00696 { 00697 NTuple::Tuple* pObj = 0; 00698 StatusCode status = findObject(fullPath, *pp_cast<DataObject>(&pObj)); // Check if object is present 00699 if ( status.isSuccess() ) { 00700 return readRecord ( pObj ); 00701 } 00702 return INVALID_OBJ_PATH; 00703 }
| StatusCode NTupleSvc::readRecord | ( | DataObject * | pParent, | |
| const std::string & | relPath | |||
| ) | [virtual] |
Read single record from N tuple.
Implements INTupleSvc.
Definition at line 706 of file NTupleSvc.cpp.
References DataSvc::findObject(), IDataProviderSvc::INVALID_OBJ_PATH, StatusCode::isSuccess(), and readRecord().
00706 { 00707 NTuple::Tuple* pObj = 0; 00708 StatusCode status = findObject(pParent, relPath, *pp_cast<DataObject>(&pObj)); // Check if object is present 00709 if ( status.isSuccess() ) { 00710 return readRecord ( pObj ); 00711 } 00712 return INVALID_OBJ_PATH; 00713 }
| bool NTupleSvc::isConnected | ( | const std::string & | identifier | ) | const [virtual] |
Check if a datasource is connected.
Implements IDataSourceMgr.
Definition at line 99 of file NTupleSvc.cpp.
References m_connections.
00099 { 00100 Connections::const_iterator i = m_connections.find(identifier); 00101 return !(i==m_connections.end()); 00102 }
| StatusCode NTupleSvc::connect | ( | const std::string & | ident | ) | [virtual] |
Add file to list I/O list.
Implements IDataSourceMgr.
Definition at line 229 of file NTupleSvc.cpp.
Referenced by initialize().
00229 { 00230 std::string logName; 00231 return connect(ident, logName); 00232 }
| StatusCode NTupleSvc::connect | ( | const std::string & | ident, | |
| std::string & | logname | |||
| ) | [virtual] |
Add file to list I/O list.
Implements IDataSourceMgr.
Reimplemented in TagCollectionSvc.
Definition at line 234 of file NTupleSvc.cpp.
References Tokenizer::analyse(), attachTuple(), createService(), endmsg(), MSG::ERROR, StatusCode::FAILURE, std::basic_string< _CharT, _Traits, _Alloc >::find(), DataSvc::findObject(), StatusCode::isSuccess(), Tokenizer::items(), std::basic_string< _CharT, _Traits, _Alloc >::length(), m_connections, DataSvc::m_rootName, Service::msgSvc(), Service::name(), std::vector< _Tp, _Alloc >::push_back(), IConverter::repSvcType(), std::basic_string< _CharT, _Traits, _Alloc >::substr(), StatusCode::SUCCESS, and toupper().
00234 { 00235 MsgStream log ( msgSvc(), name() ); 00236 DataObject* pO = 0; 00237 StatusCode status = findObject(m_rootName, pO); 00238 if ( status.isSuccess() ) { 00239 char typ=0; 00240 Tokenizer tok(true); 00241 std::vector<Prop> props; 00242 long loc = ident.find(" "); 00243 std::string filename, auth, svc = "", db_typ = ""; 00244 logname = ident.substr(0,loc); 00245 tok.analyse(ident.substr(loc+1,ident.length()), " ", "", "", "=", "'", "'"); 00246 for ( Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); ++i) { 00247 const std::string& tag = (*i).tag(); 00248 switch( ::toupper(tag[0]) ) { 00249 case 'A': 00250 break; 00251 case 'F': // FILE='<file name>' 00252 case 'D': // DATAFILE='<file name>' 00253 filename = (*i).value(); 00254 break; 00255 case 'O': // OPT='<NEW<CREATE,WRITE>, UPDATE, READ>' 00256 switch( ::toupper((*i).value()[0]) ) { 00257 case 'C': 00258 case 'N': 00259 case 'W': 00260 typ = 'N'; 00261 break; 00262 case 'U': 00263 typ = 'U'; 00264 break; 00265 case 'O': 00266 case 'R': 00267 typ = 'O'; 00268 break; 00269 default: 00270 typ = 0; 00271 break; 00272 } 00273 break; 00274 case 'T': // TYP='<HBOOK,ROOT,OBJY,...>' 00275 db_typ = (*i).value(); 00276 break; 00277 default: 00278 props.push_back( Prop((*i).tag(), (*i).value())); 00279 break; 00280 } 00281 } 00282 if ( 0 != typ ) { 00283 IConversionSvc* pSvc = 0; 00284 status = createService(name()+'.'+logname, db_typ, props, pSvc); 00285 if ( status.isSuccess() ) { 00286 status = attachTuple(filename, logname, typ, pSvc->repSvcType()); 00287 if ( status.isSuccess() ) { 00288 m_connections.insert(Connections::value_type(m_rootName+'/'+logname,Connection(pSvc))); 00289 return StatusCode::SUCCESS; 00290 } 00291 } 00292 } 00293 } 00294 log << MSG::ERROR << "Cannot add " << ident << " invalid filename!" << endmsg; 00295 return StatusCode::FAILURE; 00296 }
| StatusCode NTupleSvc::disconnect | ( | const std::string & | nam | ) | [virtual] |
Close open connection.
Implements IDataSourceMgr.
Definition at line 189 of file NTupleSvc.cpp.
References StatusCode::FAILURE, m_connections, releaseConnection(), and StatusCode::SUCCESS.
00189 { 00190 Connections::iterator i = m_connections.find(nam); 00191 if ( i != m_connections.end() ) { 00192 releaseConnection((*i).second); 00193 m_connections.erase(i); 00194 return StatusCode::SUCCESS; 00195 } 00196 return StatusCode::FAILURE; 00197 }
| StatusCode NTupleSvc::disconnectAll | ( | ) | [virtual] |
Close all open connections.
Implements IDataSourceMgr.
Definition at line 200 of file NTupleSvc.cpp.
References m_connections, releaseConnection(), and StatusCode::SUCCESS.
Referenced by finalize().
00200 { 00201 for(Connections::iterator i = m_connections.begin(); i != m_connections.end(); ++i) { 00202 releaseConnection((*i).second); 00203 } 00204 m_connections.erase(m_connections.begin(), m_connections.end()); 00205 return StatusCode::SUCCESS; 00206 }
| StatusCode NTupleSvc::createService | ( | const std::string & | nam, | |
| const std::string & | typ, | |||
| const std::vector< Prop > & | props, | |||
| IConversionSvc *& | pSvc | |||
| ) | [protected] |
Create conversion service.
CGL: set the storage type
Reimplemented in TagCollectionSvc.
Definition at line 298 of file NTupleSvc.cpp.
References endmsg(), MSG::ERROR, StatusCode::FAILURE, HBOOK_StorageType, IID_IConversionSvc, IID_IProperty, IID_IService, StatusCode::isSuccess(), std::basic_string< _CharT, _Traits, _Alloc >::length(), Service::msgSvc(), Service::name(), IInterface::queryInterface(), ROOT_StorageType, Service::serviceLocator(), IConverter::setDataProvider(), TEST_StorageType, PropertyWithValue< TYPE >::value(), and MSG::WARNING.
Referenced by connect().
00302 { 00303 MsgStream log ( msgSvc(), name() ); 00305 // Get the value of the Stat persistancy mechanism from the AppMgr 00306 IProperty* appPropMgr = 0; 00307 StatusCode sts = serviceLocator()->queryInterface(IID_IProperty, pp_cast<void>(&appPropMgr) ); 00308 if( !sts.isSuccess() ) { 00309 // Report an error and return the FAILURE status code 00310 log << MSG::ERROR << "Could not get PropMgr" << endmsg; 00311 return sts; 00312 } 00313 00314 StringProperty sp("HistogramPersistency",""); 00315 sts = appPropMgr->getProperty( &sp ); 00316 if ( !sts.isSuccess() ) { 00317 log << MSG::ERROR << "Could not get NTuple Persistency format" 00318 << " from ApplicationMgr properties" << endmsg; 00319 return sts; 00320 } 00321 00322 long storage_typ = TEST_StorageType; 00323 if ( sp.value() == "HBOOK" ) { 00324 storage_typ = HBOOK_StorageType; 00325 } 00326 else if ( sp.value() == "ROOT" ) { 00327 storage_typ = ROOT_StorageType; 00328 } 00329 else { 00330 appPropMgr->release(); 00331 log << MSG::ERROR << "Unknown NTuple Persistency format: " << sp.value() << endmsg; 00332 return StatusCode::FAILURE; 00333 } 00334 // Clean up 00335 appPropMgr->release(); 00336 00337 if ( typ.length() > 0 && typ != sp.value() ) { 00338 log << MSG::WARNING << "NTuple persistency type is " 00339 << sp.value() << "." << endmsg 00340 << "Type given by job option " 00341 << "NTupleSvc.Input/Output ignored!" << endmsg; 00342 } 00343 00344 // log << MSG::DEBUG << "storage type: " << m_storageType << endmsg; 00345 00346 // FIXME: (MCl) why NTupleSvc has to directly create a ConversionSvc? 00347 IService* pService = 0; 00348 IInterface* iface = new ConversionSvc(name()+"Conversions", serviceLocator(), storage_typ); 00349 StatusCode status = iface->queryInterface(IID_IService, pp_cast<void>(&pService)); 00350 if ( status.isSuccess() ) { 00351 status = iface->queryInterface(IID_IConversionSvc, pp_cast<void>(&pSvc)); 00352 if ( !status.isSuccess() ) { 00353 pService->release(); 00354 return status; 00355 } 00356 } 00357 status = pService->sysInitialize(); 00358 if ( !status.isSuccess() ) { 00359 return status; 00360 } 00361 pService->release(); 00362 status = pSvc->setDataProvider(this); 00363 if ( !status.isSuccess() ) { 00364 return status; 00365 } 00366 return status; 00367 }
| void NTupleSvc::releaseConnection | ( | Connection & | c | ) | [protected] |
Finalize single service.
Definition at line 179 of file NTupleSvc.cpp.
References c, IID_IService, and SmartIFBase< TYPE >::isValid().
Referenced by disconnect(), and disconnectAll().
00179 { 00180 SmartIF<IService> isvc(IID_IService, c.service ); 00181 if ( isvc.isValid( ) ) { 00182 isvc->finalize().ignore(); 00183 } 00184 c.service->release(); 00185 c.service = 0; 00186 }
| StatusCode NTupleSvc::attachTuple | ( | const std::string & | filename, | |
| const std::string & | logname, | |||
| const char | typ, | |||
| const long | t | |||
| ) | [protected] |
Attach output/input file.
Definition at line 502 of file NTupleSvc.cpp.
References CLID_NTupleFile, endmsg(), MSG::ERROR, MSG::INFO, StatusCode::isSuccess(), DataSvc::m_rootName, Service::msgSvc(), Service::name(), DataSvc::registerAddress(), GenericAddress::release(), and DataSvc::retrieveObject().
Referenced by TagCollectionSvc::connect(), and connect().
00502 { 00503 MsgStream log(msgSvc(), name()); 00504 DataObject* p; 00505 // First get the root object 00506 StatusCode status = retrieveObject(m_rootName, p); 00507 if ( status.isSuccess() ) { 00508 // Now add the registry entry to the store 00509 std::string entryname = m_rootName; 00510 entryname += '/'; 00511 entryname += logname; 00512 GenericAddress* pA = 00513 new GenericAddress(t, CLID_NTupleFile, filename, entryname, 0, typ); 00514 status = registerAddress(p, logname, pA); 00515 if ( status.isSuccess() ) { 00516 log << MSG::INFO << "Added stream file:" << filename << " as " << logname << endmsg; 00517 return status; 00518 } 00519 pA->release(); 00520 } 00521 log << MSG::ERROR << "Cannot add file:" << filename << " as " << logname << endmsg; 00522 return status; 00523 }
| StatusCode NTupleSvc::updateDirectories | ( | ) | [protected] |
Update directory data.
Definition at line 119 of file NTupleSvc.cpp.
References IRegistry::address(), endmsg(), MSG::ERROR, DataSvc::findObject(), getDataLoader(), MSG::INFO, StatusCode::isSuccess(), DataSvc::m_rootName, Service::msgSvc(), Service::name(), DataSvc::objectLeaves(), DataSelectionAgent::selectedObjects(), DataSvc::traverseSubTree(), IConverter::updateRep(), and IConverter::updateRepRefs().
Referenced by finalize().
00119 { 00120 typedef std::vector<IRegistry*> Leaves; 00121 long need_update = 0; 00122 DataObject* pO = 0; 00123 StatusCode iret = findObject(m_rootName, pO); 00124 MsgStream log ( msgSvc(), name() ); 00125 // log << MSG::DEBUG << "in finalize()" << endmsg; 00126 if ( iret.isSuccess() ) { 00127 Leaves leaves; 00128 iret = objectLeaves(pO, leaves); 00129 if ( iret.isSuccess() ) { 00130 // Only traverse the tree below the files 00131 for ( Leaves::iterator d = leaves.begin(); d != leaves.end(); d++ ) { 00132 if ( (*d)->object() ) { 00133 IOpaqueAddress* pA = (*d)->address(); 00134 if ( pA ) { 00135 unsigned long typ = pA->ipar()[1]; 00136 if ( typ == 'R' || typ == 'N' || typ == 'U' ) { 00137 // ...starting from the file entries: first save the directories/ntuples 00138 IConversionSvc* svc = getDataLoader(*d); 00139 if ( 0 != svc ) { 00140 StatusCode status; 00141 DataSelectionAgent agent; 00142 IDataSelector* sel = agent.selectedObjects(); 00143 traverseSubTree ( (*d)->object(), &agent ).ignore(); 00144 for(int i = sel->size()-1; i >= 0; i-- ) { 00145 DataObject* o = (*sel)[i]; 00146 IRegistry* r = o->registry(); 00147 status = svc->updateRep(r->address(), o); 00148 if ( !status.isSuccess() ) { 00149 iret = status; 00150 } 00151 } 00152 for(int j = sel->size()-1; j >= 0; j-- ) { 00153 DataObject* o = (*sel)[j]; 00154 IRegistry* r = o->registry(); 00155 status = svc->updateRepRefs(r->address(), o); 00156 if ( !status.isSuccess() ) { 00157 iret = status; 00158 } 00159 } 00160 if ( iret.isSuccess() ) need_update += sel->size(); 00161 } 00162 } 00163 } 00164 } 00165 } 00166 } 00167 } 00168 if ( !iret.isSuccess() ) { 00169 log << MSG::ERROR << "ERROR while saving NTuples" << endmsg; 00170 return iret; 00171 } 00172 else if ( need_update > 0 ) { 00173 log << MSG::INFO << "NTuples saved successfully" << endmsg; 00174 } 00175 return iret; 00176 }
friend class SvcFactory< NTupleSvc > [friend] |
Definition at line 38 of file NTupleSvc.h.
DBaseEntries NTupleSvc::m_output [protected] |
DBaseEntries NTupleSvc::m_input [protected] |
Connections NTupleSvc::m_connections [protected] |
Container of connection points.
Definition at line 134 of file NTupleSvc.h.
Referenced by TagCollectionSvc::connect(), connect(), disconnect(), disconnectAll(), getDataLoader(), and isConnected().