diff --git a/Database/APR/RootStorageSvc/src/RootDatabase.cpp b/Database/APR/RootStorageSvc/src/RootDatabase.cpp index a124cbee75f169a902d030ba6a867a2fce581951..3cfe6725b0428e84826f7a149d6750c5d6e88052 100644 --- a/Database/APR/RootStorageSvc/src/RootDatabase.cpp +++ b/Database/APR/RootStorageSvc/src/RootDatabase.cpp @@ -42,7 +42,7 @@ using namespace std; /// Standard Constuctor RootDatabase::RootDatabase(IOODatabase* idb) -: DbDatabaseImp(idb), m_file(0), +: DbDatabaseImp(idb), m_file(nullptr), m_defCompression(1), m_defCompressionAlg(1), m_defSplitLevel(99), @@ -51,7 +51,7 @@ RootDatabase::RootDatabase(IOODatabase* idb) m_defWritePolicy(TObject::kOverwrite), // On write create new versions m_branchOffsetTabLen(0), m_defTreeCacheLearnEvents(100), - m_fileMgr(0) + m_fileMgr(nullptr) { m_version = "1.1"; DbInstanceCount::increment(this); @@ -129,8 +129,8 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess TDirectory::TContext dirCtxt(0); - if (m_fileMgr == 0) { - IService *is(0); + if (m_fileMgr == nullptr) { + IService *is(nullptr); if (Gaudi::svcLocator()->getService("FileMgr",is,true).isFailure()) { log << DbPrintLvl::Error @@ -144,19 +144,19 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess // FIXME: hack to avoid issue with setting up RecExCommon links - if (m_fileMgr != 0 && m_fileMgr->hasHandler(Io::ROOT).isFailure()) { + if (m_fileMgr != nullptr && m_fileMgr->hasHandler(Io::ROOT).isFailure()) { log << DbPrintLvl::Info << "Unable to locate ROOT file handler via FileMgr. " << "Will use default TFile::Open" << DbPrint::endmsg; - m_fileMgr = 0; + m_fileMgr = nullptr; } if ( mode == pool::READ ) { - if (m_fileMgr == 0) { + if (m_fileMgr == nullptr) { m_file = TFile::Open(fname); } else { - void *vf(0); + void *vf(nullptr); int r = m_fileMgr->open(Io::ROOT,"RootDatabase",fname,Io::READ,vf,"POOL",false); if (r < 0) { log << DbPrintLvl::Error << "unable to open \"" << fname @@ -168,10 +168,10 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess } } else if ( mode&pool::UPDATE && result == kFALSE ) { - if (m_fileMgr == 0) { + if (m_fileMgr == nullptr) { m_file = TFile::Open(fname, "UPDATE", fname); } else { - void *vf(0); + void *vf(nullptr); int r = m_fileMgr->open(Io::ROOT,"RootDatabase",fname,Io::APPEND,vf,"POOL",true); if (r < 0) { log << DbPrintLvl::Error << "unable to open \"" << fname @@ -181,16 +181,16 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess m_file = (TFile*)vf; } } - if (m_file != 0) { + if (m_file != nullptr) { m_file->SetCompressionLevel(m_defCompression); m_file->SetCompressionAlgorithm(m_defCompressionAlg); } } else if ( pool::RECREATE == (mode&pool::RECREATE) ) { - if (m_fileMgr == 0) { + if (m_fileMgr == nullptr) { m_file = TFile::Open(fname, "RECREATE", fname); } else { - void *vf(0); + void *vf(nullptr); int r = m_fileMgr->open(Io::ROOT,"RootDatabase",fname,Io::WRITE|Io::CREATE,vf,"POOL",true); if (r < 0) { log << DbPrintLvl::Error << "unable to open \"" << fname @@ -200,16 +200,16 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess m_file = (TFile*)vf; } } - if (m_file != 0) { + if (m_file != nullptr) { m_file->SetCompressionLevel(m_defCompression); m_file->SetCompressionAlgorithm(m_defCompressionAlg); } } else if ( mode&pool::CREATE && result == kTRUE ) { - if (m_fileMgr == 0) { + if (m_fileMgr == nullptr) { m_file = TFile::Open(fname, "RECREATE", fname); } else { - void *vf(0); + void *vf(nullptr); int r = m_fileMgr->open(Io::ROOT,"RootDatabase",fname,Io::WRITE|Io::CREATE,vf,"POOL",true); if (r < 0) { log << DbPrintLvl::Error << "unable to open \"" << fname @@ -219,7 +219,7 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess m_file = (TFile*)vf; } } - if (m_file != 0) { + if (m_file != nullptr) { m_file->SetCompressionLevel(m_defCompression); m_file->SetCompressionAlgorithm(m_defCompressionAlg); } @@ -250,7 +250,7 @@ DbStatus RootDatabase::open(const DbDomain& domH,const std::string& nam,DbAccess << " if it does not exists. " << DbPrint::endmsg; } - return (0 == m_file) ? Error : Success; + return (nullptr == m_file) ? Error : Success; } /// Re-open database with changing access permissions @@ -309,7 +309,7 @@ DbStatus RootDatabase::close(DbAccessMode /* mode */ ) { //m_file->ls(); m_file->ResetErrno(); - if (m_fileMgr == 0) { + if (m_fileMgr == nullptr) { m_file->Close(); } else { n = m_fileMgr->close(m_file,"RootDatabase"); @@ -326,7 +326,7 @@ DbStatus RootDatabase::close(DbAccessMode /* mode */ ) { << "I/O WRITE Bytes: " << byteCount(WRITE_COUNTER) << DbPrint::endmsg << "I/O OTHER Bytes: " << byteCount(OTHER_COUNTER) << DbPrint::endmsg; - if (!closed && m_fileMgr != 0) { + if (!closed && m_fileMgr != nullptr) { n = m_fileMgr->close(m_file,"RootDatabase"); } } @@ -621,7 +621,7 @@ DbStatus RootDatabase::setOption(const DbOption& opt) { DbPrint log("RootDatabase.setOption"); if ( m_file->GetListOfKeys()->Contains("CollectionTree") ) { TTree *tree = (TTree*)m_file->Get("CollectionTree"); - if (tree != 0 && tree->GetAutoFlush() > 0) { + if (tree != nullptr && tree->GetAutoFlush() > 0) { if (m_defTreeCacheLearnEvents < tree->GetAutoFlush()) { log << DbPrintLvl::Info << n << ": Overwriting LearnEvents with CollectionTree AutoFlush" << DbPrint::endmsg; m_defTreeCacheLearnEvents = tree->GetAutoFlush(); diff --git a/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp b/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp index 2776a67ff9bae6244e34f2b9a270716ab2a1fa76..2d0057c41050cc6e125ee6492856c11c0453da1c 100755 --- a/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp +++ b/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp @@ -131,8 +131,8 @@ static IntDbArray s_int_Blob; RootTreeContainer::RootTreeContainer(IOODatabase* idb) -: DbContainerImp(idb), m_tree(0), m_type(0), m_dbH(POOL_StorageType), - m_rootDb(0), m_branchName(), m_ioBytes(0), m_treeFillMode(false), +: DbContainerImp(idb), m_tree(nullptr), m_type(0), m_dbH(POOL_StorageType), + m_rootDb(nullptr), m_branchName(), m_ioBytes(0), m_treeFillMode(false), m_isDirty(false) { DbInstanceCount::increment(this); @@ -150,11 +150,11 @@ DbStatus RootTreeContainer::isShapeSupported(const DbTypeInfo* typ) const { } long long int RootTreeContainer::size() { - if (m_tree == 0) return 0; + if (m_tree == nullptr) return 0; long long int s = DbContainerImp::size(); if( isBranchContainer() ) { TBranch * pBranch = m_tree->GetBranch(m_branchName.c_str()); - if (pBranch == 0) return 0; + if (pBranch == nullptr) return 0; s += pBranch->GetEntries(); } else { s += m_tree->GetEntries(); @@ -170,12 +170,12 @@ TBranch* RootTreeContainer::branch(const std::string& nam) const { return (*k).branch; } } - return 0; + return nullptr; } DbStatus RootTreeContainer::writeObject(TransactionStack::value_type& ent) { - RootDataPtr p(0); + RootDataPtr p(nullptr); RootDataPtr user(&ent.objH); const void* ptr = ent.objH ? ent.objH : ent.call->object(); RootDataPtr context(ptr); @@ -220,13 +220,13 @@ DbStatus RootTreeContainer::writeObject(TransactionStack::value_type& ent) { << store->getIOType(id)->name() << ", " << reg.getName(id) << DbPrint::endmsg; sc = addAuxBranch(reg.getName(id), store->getIOType(id), newBrDsc); if( !sc.isSuccess() ) { - p.ptr = 0; // trigger an Error + p.ptr = nullptr; // trigger an Error break; } if( dsc.rows_written ) { // catch up with the rows written by other branches - newBrDsc.object = 0; - newBrDsc.branch->SetAddress( 0 ); + newBrDsc.object = nullptr; + newBrDsc.branch->SetAddress( nullptr ); for( size_t r=0; r<dsc.rows_written; ++r ) { num_bytes += newBrDsc.branch->Fill(); } @@ -262,7 +262,7 @@ DbStatus RootTreeContainer::writeObject(TransactionStack::value_type& ent) { default: break; } - if ( 0 == p.ptr ) { + if ( nullptr == p.ptr ) { DbPrint err( m_name); err << DbPrintLvl::Error << "[RootTreeContainer] Could not write an object" @@ -282,8 +282,8 @@ DbStatus RootTreeContainer::writeObject(TransactionStack::value_type& ent) { for( auto &descMapElem: m_auxBranchMap ) { BranchDesc& dsc = descMapElem.second; if( !dsc.written ) { - dsc.object = 0; - dsc.branch->SetAddress( 0 ); + dsc.object = nullptr; + dsc.branch->SetAddress( nullptr ); // cout << " Branch " << SG::AuxTypeRegistry::instance().getName(descMapElem.first) << " filled out with NULL" << endl; if( isBranchContainer() && !m_treeFillMode ) { size_t bytes_out = dsc.branch->Fill(); @@ -393,8 +393,8 @@ DbStatus RootTreeContainer::fetch(DbSelect& sel) { DbStatus RootTreeContainer::loadObject(DataCallBack* call, Token::OID_t& oid, DbAccessMode /* mode */) { - RootDataPtr user(0); - RootDataPtr context(0); + RootDataPtr user(nullptr); + RootDataPtr context(nullptr); DbStatus status = Error; long long evt_id = oid.second; // Read data; disable branch after reading the information @@ -408,7 +408,7 @@ RootTreeContainer::loadObject(DataCallBack* call, Token::OID_t& oid, DbAccessMod Branches::iterator k; for(k=m_branches.begin(); k != m_branches.end(); ++k,++icol) { BranchDesc& dsc = (*k); - RootDataPtr p(0), q(0); + RootDataPtr p(nullptr), q(nullptr); DbStatus sc = call->bind(DataCallBack::GET,dsc.column,icol,user.ptr,&p.ptr); q.ptr = p.ptr; if ( sc.isSuccess() && sc != DataCallBack::SKIP ) { @@ -527,8 +527,8 @@ DbStatus RootTreeContainer::close() { } m_branches.clear(); m_auxBranchMap.clear(); - m_rootDb = 0; - m_tree = 0; + m_rootDb = nullptr; + m_tree = nullptr; return DbContainerImp::close(); } @@ -572,8 +572,8 @@ DbStatus RootTreeContainer::open( const DbDatabase& dbH, m_tree = (TTree*)m_rootDb->file()->Get(treeName.c_str()); bool hasBeenCreated = (m_branchName.empty() - ? m_tree != 0 - : (m_tree && m_tree->GetBranch(m_branchName.c_str()) != 0)); + ? m_tree != nullptr + : (m_tree && m_tree->GetBranch(m_branchName.c_str()) != nullptr)); if ( hasBeenCreated && (mode&pool::READ || mode&pool::UPDATE) ) { int count; if ( !m_tree->InheritsFrom(TTree::Class()) ) { @@ -598,14 +598,14 @@ DbStatus RootTreeContainer::open( const DbDatabase& dbH, const DbColumn* c = *i; BranchDesc& dsc = m_branches[count]; - TClass* cl = 0; + TClass* cl = nullptr; TLeaf* leaf = pBranch->GetLeaf(colnam.c_str()); switch ( (*i)->typeID() ) { case DbColumn::ANY: case DbColumn::BLOB: case DbColumn::POINTER: cl = TClass::GetClass(pBranch->GetClassName()); - if ( 0 == cl ) { + if ( nullptr == cl ) { log << DbPrintLvl::Debug << "Cannot open the container " << m_name << " of type " << ROOTTREE_StorageType.storageName() << " Class " << pBranch->GetClassName() << " is unknown." @@ -633,11 +633,11 @@ DbStatus RootTreeContainer::open( const DbDatabase& dbH, case DbColumn::NTCHAR: case DbColumn::LONG_NTCHAR: case DbColumn::TOKEN: - dsc.clazz = 0; + dsc.clazz = nullptr; dsc.leaf = leaf; dsc.branch = pBranch; - dsc.buffer = 0; - dsc.object = 0; + dsc.buffer = nullptr; + dsc.object = nullptr; dsc.column = *i; break; default: @@ -662,7 +662,7 @@ DbStatus RootTreeContainer::open( const DbDatabase& dbH, return Success; } else if ( !hasBeenCreated && mode&pool::CREATE ) { - int count, defCompression=1, defSplitLevel=99, + int count, defSplitLevel=99, defAutoSave=16*1024*1024, defBufferSize=16*1024, branchOffsetTabLen=0, containerSplitLevel=defSplitLevel, auxSplitLevel=defSplitLevel; DbStatus res = Success; @@ -777,7 +777,7 @@ DbStatus RootTreeContainer::open( const DbDatabase& dbH, // Define selection criteria DbStatus RootTreeContainer::select(DbSelect& sel) { - if ( 0 != m_tree ) { + if ( nullptr != m_tree ) { if( sel.criteria().length() == 0 || sel.criteria() == "*" ) { sel.link().second = -1; return Success; @@ -803,11 +803,11 @@ DbStatus RootTreeContainer::addObject(const DbColumn* col, int branchOffsetTabLen) { try { - dsc.buffer = 0; - dsc.object = 0; + dsc.buffer = nullptr; + dsc.object = nullptr; dsc.column = col; dsc.clazz = TClass::GetClass(typ.c_str()); - if ( 0 != dsc.clazz ) { + if ( nullptr != dsc.clazz ) { if ( dsc.clazz->GetStreamerInfo() ) { std::string nam = (m_branchName.empty() ? col->name() : m_branchName); if (m_branchName.empty()) { @@ -879,7 +879,7 @@ DbStatus RootTreeContainer::addAuxBranch(const std::string& attribute, { string typenam = SG::normalizedTypeinfoName(*typeinfo); string branch_name = RootAuxDynIO::auxBranchName(attribute, m_branchName); - dsc.branch = 0; + dsc.branch = nullptr; try { if( *typeinfo == typeid(UInt_t) ) createBasicAuxBranch(branch_name, attribute + "/i", dsc); @@ -960,10 +960,10 @@ RootTreeContainer::addBranch(const DbColumn* col,BranchDesc& dsc,const std::stri dsc.branch = m_tree->Branch(nam, buff, coldesc.c_str(), 4096); if ( dsc.branch ) { dsc.leaf = dsc.branch->GetLeaf(nam); - dsc.clazz = 0; + dsc.clazz = nullptr; dsc.column = col; - dsc.buffer = 0; - dsc.object = 0; + dsc.buffer = nullptr; + dsc.object = nullptr; return Success; } return Error; @@ -977,7 +977,7 @@ void RootTreeContainer::setBranchOffsetTabLen(TBranch* b, int offsettab_len) if( b->GetEntryOffsetLen() > 0 ) b->SetEntryOffsetLen( offsettab_len ); TIter biter( b->GetListOfBranches() ); - TBranch* subbranch(0); + TBranch* subbranch(nullptr); while( (subbranch = (TBranch*)biter.Next()) ) { setBranchOffsetTabLen( subbranch, offsettab_len ); } @@ -1065,12 +1065,12 @@ DbStatus RootTreeContainer::getOption(DbOption& opt) const { return opt._setValue((void*)arr->At(idx)); } if ( !strcasecmp(n+5,"BRANCH_NAME") ) { - const char* br_nam = 0; + const char* br_nam = nullptr; opt._getValue(br_nam); if ( br_nam ) { return opt._setValue((void*)m_tree->GetBranch(br_nam)); } - opt._setValue((void*)0); + opt._setValue((void*)nullptr); } if ( !strcasecmp(n+5,"BRANCH_IDX_NAME") ) { int idx = 0; @@ -1080,7 +1080,7 @@ DbStatus RootTreeContainer::getOption(DbOption& opt) const { if ( br ) { return opt._setValue((char*)br->GetName()); } - opt._setValue((char*)0); + opt._setValue((char*)nullptr); } break; case 'E': @@ -1243,7 +1243,7 @@ DbStatus RootTreeContainer::finishTransAct() { // cout << " +++ End Transaction. Tree rows=" << treeEntries << " , Branch " << k->branch->GetName() << " " << branchEntries << endl; if (branchEntries > treeEntries) { TIter next(m_tree->GetListOfBranches()); - TBranch * b = 0; + TBranch * b = nullptr; while((b = (TBranch*)next())){ if (b->GetEntries() != branchEntries) { DbPrint log(m_name); diff --git a/Database/APR/RootStorageSvc/src/RootTreeContainer.h b/Database/APR/RootStorageSvc/src/RootTreeContainer.h index 2a976de2606641291719125fdb12d74cd2a54020..dc761b8a982e07ef00acfd22c8b5c7a362371c10 100755 --- a/Database/APR/RootStorageSvc/src/RootTreeContainer.h +++ b/Database/APR/RootStorageSvc/src/RootTreeContainer.h @@ -72,18 +72,18 @@ namespace pool { // extra variables used by Aux dynamic size_t rows_written = 0; // AuxDyn reader if used by this branch - IRootAuxDynReader*aux_reader = 0; + IRootAuxDynReader*aux_reader = nullptr; int aux_iostore_IFoffset = -1; bool is_basic_type = false; bool written = false; BranchDesc() - : clazz(0), - branch(0), - leaf(0), - object(0), - buffer(0), - column(0) + : clazz(nullptr), + branch(nullptr), + leaf(nullptr), + object(nullptr), + buffer(nullptr), + column(nullptr) {} BranchDesc( TClass* cl, @@ -94,7 +94,7 @@ namespace pool { : clazz(cl), branch(b), leaf(l), - object(0), + object(nullptr), buffer(o), column(c) {}