From 7cbb39fe7da114d3f9df940f1230f710e45d1ed5 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Fri, 22 Nov 2019 21:58:15 -0500 Subject: [PATCH 1/3] StorageSvc: Enable thread-safety checking. Enable the thread-safety checker for this package. Rework to fix all warnings. --- .../StorageSvc/ATLAS_CHECK_THREAD_SAFETY | 1 + .../StorageSvc/DatabaseConnection.h | 5 +- .../APR/StorageSvc/StorageSvc/DbAccessObj.h | 3 +- .../APR/StorageSvc/StorageSvc/DbConnection.h | 5 +- .../APR/StorageSvc/StorageSvc/DbContainer.h | 20 +++--- .../StorageSvc/StorageSvc/DbContainerImp.h | 4 +- .../APR/StorageSvc/StorageSvc/DbDatabase.h | 61 ++++++++-------- Database/APR/StorageSvc/StorageSvc/DbDomain.h | 27 +++---- .../APR/StorageSvc/StorageSvc/DbHandleBase.h | 17 ++--- Database/APR/StorageSvc/StorageSvc/DbHeap.h | 8 ++- Database/APR/StorageSvc/StorageSvc/DbIter.h | 3 +- Database/APR/StorageSvc/StorageSvc/DbObject.h | 37 ++++++---- .../StorageSvc/StorageSvc/DbObjectAccessor.h | 14 ++-- .../APR/StorageSvc/StorageSvc/DbObjectGuard.h | 5 +- .../APR/StorageSvc/StorageSvc/DbSession.h | 10 +-- Database/APR/StorageSvc/StorageSvc/DbToken.h | 4 +- .../APR/StorageSvc/StorageSvc/DbTypeInfo.h | 8 ++- .../StorageSvc/StorageSvc/FileDescriptor.h | 7 +- .../APR/StorageSvc/StorageSvc/IDbContainer.h | 6 +- .../APR/StorageSvc/StorageSvc/IDbDatabase.h | 4 +- .../StorageSvc/StorageSvc/IStorageExplorer.h | 26 +++---- .../APR/StorageSvc/StorageSvc/IStorageSvc.h | 18 ++--- Database/APR/StorageSvc/src/DbContainer.cpp | 27 ++++--- .../APR/StorageSvc/src/DbContainerImp.cpp | 4 +- .../APR/StorageSvc/src/DbContainerObj.cpp | 11 +-- Database/APR/StorageSvc/src/DbContainerObj.h | 11 +-- Database/APR/StorageSvc/src/DbDatabase.cpp | 72 +++++++++++-------- Database/APR/StorageSvc/src/DbDatabaseObj.cpp | 16 +++-- Database/APR/StorageSvc/src/DbDatabaseObj.h | 16 +++-- Database/APR/StorageSvc/src/DbDomain.cpp | 36 ++++++---- Database/APR/StorageSvc/src/DbDomainObj.cpp | 2 +- Database/APR/StorageSvc/src/DbDomainObj.h | 9 +-- Database/APR/StorageSvc/src/DbHeap.cpp | 24 +++++-- Database/APR/StorageSvc/src/DbObject.cpp | 19 +++-- Database/APR/StorageSvc/src/DbReflex.cpp | 4 +- Database/APR/StorageSvc/src/DbSession.cpp | 13 ++-- .../APR/StorageSvc/src/DbStorageExplorer.cpp | 35 ++++----- .../APR/StorageSvc/src/DbStorageExplorer.h | 24 +++---- Database/APR/StorageSvc/src/DbStorageSvc.cpp | 35 ++++----- Database/APR/StorageSvc/src/DbStorageSvc.h | 18 ++--- Database/APR/StorageSvc/src/DbToken.cpp | 8 +-- Database/APR/StorageSvc/src/DbTransform.cpp | 3 +- Database/APR/StorageSvc/src/DbTypeInfo.cpp | 68 ++++++++++-------- .../test/StorageSvc_getGuid_test.cxx | 9 ++- 44 files changed, 435 insertions(+), 322 deletions(-) create mode 100644 Database/APR/StorageSvc/StorageSvc/ATLAS_CHECK_THREAD_SAFETY diff --git a/Database/APR/StorageSvc/StorageSvc/ATLAS_CHECK_THREAD_SAFETY b/Database/APR/StorageSvc/StorageSvc/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 000000000000..3ad42c299310 --- /dev/null +++ b/Database/APR/StorageSvc/StorageSvc/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +Database/APR/StorageSvc diff --git a/Database/APR/StorageSvc/StorageSvc/DatabaseConnection.h b/Database/APR/StorageSvc/StorageSvc/DatabaseConnection.h index 560a6a22b34f..21e53a6141ad 100644 --- a/Database/APR/StorageSvc/StorageSvc/DatabaseConnection.h +++ b/Database/APR/StorageSvc/StorageSvc/DatabaseConnection.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef STORAGESVC_DATABASECONNECTION_H @@ -30,7 +30,8 @@ namespace pool { /// Access technoliogy type virtual int type() const = 0; /// Access object identifier - virtual void* handle() const = 0; + virtual void* handle() = 0; + virtual const void* handle() const = 0; }; } // End namespace pool diff --git a/Database/APR/StorageSvc/StorageSvc/DbAccessObj.h b/Database/APR/StorageSvc/StorageSvc/DbAccessObj.h index 994d078eef7b..cace64ad0021 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbAccessObj.h +++ b/Database/APR/StorageSvc/StorageSvc/DbAccessObj.h @@ -83,7 +83,8 @@ namespace pool { // Inline functions const DbType& type() const { return m_type; } /// Allow access to the Database implementation - IOODatabase* db() const { return m_pool; } + const IOODatabase* db() const { return m_pool; } + IOODatabase* db() { return m_pool; } /// Access reference counter int refCount() const { return m_refCount; } /// Add reference count diff --git a/Database/APR/StorageSvc/StorageSvc/DbConnection.h b/Database/APR/StorageSvc/StorageSvc/DbConnection.h index 925ed625f3f5..58ca16edfb02 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbConnection.h +++ b/Database/APR/StorageSvc/StorageSvc/DbConnection.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef STORAGESVC_DBCONNECTION_H @@ -62,7 +62,8 @@ namespace pool { /// Increase reference count int addRef() { return ++m_refCount; } /// Access object identifier - virtual void* handle() const { return m_handle; } + virtual void* handle() { return m_handle; } + virtual const void* handle() const { return m_handle; } /// Access Database identifier virtual const std::string& name() const { return m_name; } /// Access technoliogy type diff --git a/Database/APR/StorageSvc/StorageSvc/DbContainer.h b/Database/APR/StorageSvc/StorageSvc/DbContainer.h index 170a906c1f30..22db7b266333 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbContainer.h +++ b/Database/APR/StorageSvc/StorageSvc/DbContainer.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -49,7 +49,7 @@ namespace pool { class DbContainer : public DbHandleBase<DbContainerObj> { private: /// Assign transient object properly (including reference counting) - void switchPtr( const DbContainerObj* obj) const; + void switchPtr( DbContainerObj* obj); /// Load object in the container identified by its link handle DbStatus _load( DbObjectHandle<DbObject>& objH, const Token::OID_t& linkH, @@ -60,7 +60,7 @@ namespace pool { Token::OID_t& linkH, const DbTypeInfo* typ); /// Internal add of an object entry identified by its handle - DbStatus _save( const DbObjectHandle<DbObject>& objH, + DbStatus _save( DbObjectHandle<DbObject>& objH, const DbTypeInfo* typ); /// Add object to the container DbStatus _update( const DbObjectHandle<DbObject>& handle, @@ -76,7 +76,7 @@ namespace pool { /// Copy constructor DbContainer(const DbContainer& c) : Base() { switchPtr(c.m_ptr); } /// Constructor taking transient object - DbContainer (const DbContainerObj* ptr) { switchPtr(ptr); } + DbContainer (DbContainerObj* ptr) { switchPtr(ptr); } /// Standard Destructor virtual ~DbContainer() { switchPtr(0); } /// Assignment operator @@ -102,16 +102,18 @@ namespace pool { long long int size() const; /// Access to the Database the container resides in const DbDatabase& containedIn() const; + DbDatabase& containedIn(); /// Allow access to the Database implementation IOODatabase* db() const; /// Let the implementation access the internals - IDbContainer* info() const; + const IDbContainer* info() const; + IDbContainer* info(); /// Retrieve persistent type information by name const DbTypeInfo* objectShape(const Guid& nam) const; /// Access the token of the container object const Token* token() const; /// Close the container the handle poits to - DbStatus close() const; + DbStatus close(); /// Open the container residing in \<file\> with given name and access mode /** @param dbH [IN] Valid handle to database object @@ -123,11 +125,11 @@ namespace pool { * * @return Status code indicating success or failure. */ - DbStatus open(const DbDatabase& dbH, + DbStatus open(DbDatabase& dbH, const std::string& nam, const DbTypeInfo* typ, const DbType& dbtyp, - DbAccessMode mod) const; + DbAccessMode mod); /// Check if the container was opened bool isOpen() const; @@ -184,7 +186,7 @@ namespace pool { template <class T> DbStatus destroy(const DbObjectHandle<T>& objH) { DbObjectHandle<DbObject> oH(objH.ptr()); return _destroy(oH); } /// Add an object to the container identified by its handle - template <class T> DbStatus save( const DbObjectHandle<T>& objH, + template <class T> DbStatus save( DbObjectHandle<T>& objH, const DbTypeInfo* typ) { DbObjectHandle<DbObject> oH(objH.ptr()); return _save(oH, typ); } /// Update an object to the container identified by its handle diff --git a/Database/APR/StorageSvc/StorageSvc/DbContainerImp.h b/Database/APR/StorageSvc/StorageSvc/DbContainerImp.h index 3eb2bfb6ace0..d4f764041829 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbContainerImp.h +++ b/Database/APR/StorageSvc/StorageSvc/DbContainerImp.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -182,7 +182,7 @@ namespace pool { ShapeH shape, const DbObjectHandle<DbObject>& objH); /// Add single entry to container - virtual DbStatus save( const DbObjectHandle<DbObject>& objH); + virtual DbStatus save( DbObjectHandle<DbObject>& objH); /// Save new object in the container and return its handle /** @param cntH [IN] Handle to container object. diff --git a/Database/APR/StorageSvc/StorageSvc/DbDatabase.h b/Database/APR/StorageSvc/StorageSvc/DbDatabase.h index 03198de58ca7..a12c4bc37e81 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbDatabase.h +++ b/Database/APR/StorageSvc/StorageSvc/DbDatabase.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -66,14 +66,14 @@ namespace pool { typedef std::vector< Parameter > Parameters; /// Assign transient object properly (including reference counting) - void switchPtr(const DbDatabaseObj* obj) const; + void switchPtr(DbDatabaseObj* obj); public: /// Constructor with initializing arguments DbDatabase(const DbType& typ=POOL_StorageType) { m_type = typ; } /// Copy constructor DbDatabase(const DbDatabase& cp) : Base() { switchPtr(cp.m_ptr); } /// Constructor - DbDatabase(const DbDatabaseObj* obj) { switchPtr(obj); } + DbDatabase(DbDatabaseObj* obj) { switchPtr(obj); } /// Standard destructor virtual ~DbDatabase() { switchPtr(0); } /// Assignment (copy) operator @@ -100,19 +100,23 @@ namespace pool { /// Access to db logon string const std::string& logon() const; /// Access the size of the database: May be undefined for some technologies - long long int size() const; + long long int size(); /// Allow access to the Database implementation - IOODatabase* db() const; + IOODatabase* db(); + const IOODatabase* db() const; /// Add domain to session - DbStatus add(const std::string& name, DbContainerObj* cnt) const; + DbStatus add(const std::string& name, DbContainerObj* cnt); /// Find domain in session DbStatus remove(const DbContainerObj* cnt); /// Select container object in Database const DbContainerObj* find(const std::string& nam) const; + /// Select container object in Database + DbContainerObj* find(const std::string& nam); /// Access the token of the database object const Token* token() const; /// Access to domain object const DbDomain& containedIn() const; + DbDomain& containedIn(); /// Check for existence of Database within domain bool exist(const DbDomain& domH, const std::string& nam) const; /// Open Database using given domain @@ -122,19 +126,19 @@ namespace pool { * @param mode [IN] Open mode (Default=READ). * @return Status code indicating success or failure. */ - DbStatus open(const DbDomain& domH, + DbStatus open(DbDomain& domH, const std::string& pfn, const std::string& fid, - DbAccessMode mode = pool::READ) const; + DbAccessMode mode = pool::READ); /// Re-open database with changing access permissions /** @param mode [IN] Open mode (Valid modes are READ, UPDATE). * @return Status code indicating success or failure. */ - DbStatus reopen(DbAccessMode mode = pool::READ) const; + DbStatus reopen(DbAccessMode mode = pool::READ); /// Close Database - DbStatus close() const; + DbStatus close(); /// End database access, but still leave database accessible - DbStatus retire() const; + DbStatus retire(); /// Check if the database was opened bool isOpen() const; /// Commit/Rollback Database Transaction @@ -151,15 +155,15 @@ namespace pool { /** @param refOpt [IN] Reference to option object. * @return Status code indicating success or failure. */ - DbStatus getOption(DbOption& refOpt) const; + DbStatus getOption(DbOption& refOpt); /// Add a persistent parameter to the file - DbStatus addParam(const std::string& nam, const std::string& val) const; + DbStatus addParam(const std::string& nam, const std::string& val); /// Retrieve the number of user parameters - int nParam() const; + int nParam(); /// Retrieve existing parameter by name - DbStatus param(const std::string& nam, std::string& val) const; + DbStatus param(const std::string& nam, std::string& val); /// Retrieve all parameters - DbStatus params(Parameters& vals) const; + DbStatus params(Parameters& vals); /// Access to all token redirections from merged files const Redirections& redirections() const; @@ -170,32 +174,33 @@ namespace pool { /// Expand OID into a full Token, based on the Links table. For merged files provide links section# DbStatus getLink(const Token::OID_t& oid, int merge_section, Token* pTok); /// Retrieve container name from link container (using token oid, rather than contID) - std::string cntName(const Token& token) const; + std::string cntName(Token& token); /// Add association link to link container - DbStatus makeLink(const Token* pToken, Token::OID_t& linkH) const; + DbStatus makeLink(Token* pToken, Token::OID_t& linkH); /// Access to sections if availible - const ContainerSections& sections(const std::string& cnt) const; + const ContainerSections& sections(const std::string& cnt); /// Add persistent shape to the Database DbStatus addShape (const DbTypeInfo* pShape); /// Retrieve persistent type information by class handle - const DbTypeInfo* objectShape(const RootType& typeH) const; + const DbTypeInfo* objectShape(const RootType& typeH); /// Retrieve persistent type information by name - const DbTypeInfo* objectShape(const Guid& nam) const; + const DbTypeInfo* objectShape(const Guid& nam); /// Retrieve persistent type information by container - const DbTypeInfo* contShape(const std::string& nam) const; + const DbTypeInfo* contShape(const std::string& nam); /// Access local container token (if container exists) - const Token* cntToken(const std::string& cntName) const; + const Token* cntToken(const std::string& cntName); /// Allow access to all known containers DbStatus containers(std::vector<const Token*>& conts, - bool intern=false) const; + bool intern=false); /// Allow access to all known associations between containers - DbStatus associations(std::vector<const Token*>& assocs) const; + DbStatus associations(std::vector<const Token*>& assocs); /// Allow access to all known shapes used by the database - DbStatus shapes(std::vector<const DbTypeInfo*>& shaps) const; + DbStatus shapes(std::vector<const DbTypeInfo*>& shaps); /// Let the implementation access the internals - IDbDatabase* info() const; + IDbDatabase* info(); + const IDbDatabase* info() const; /// Update database age - void setAge(int value) const; + void setAge(int value); /// Access age value int age() const; }; diff --git a/Database/APR/StorageSvc/StorageSvc/DbDomain.h b/Database/APR/StorageSvc/StorageSvc/DbDomain.h index c0f9e85949d5..83ecf5582174 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbDomain.h +++ b/Database/APR/StorageSvc/StorageSvc/DbDomain.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // $Id: DbDomain.h 726071 2016-02-25 09:23:05Z krasznaa $ @@ -50,10 +50,10 @@ namespace pool { friend class DbDomainObj; private: /// Assign transient object properly (including reference counting) - void switchPtr(const DbDomainObj* obj) const; + void switchPtr(DbDomainObj* obj); public: /// Friend's constructor - DbDomain(const DbDomainObj* dom); + DbDomain(DbDomainObj* dom); /// Constructor using Db type DbDomain(const DbType& type) { m_type = type.majorType(); } /// Copy constructor @@ -101,9 +101,9 @@ namespace pool { */ DbStatus open(const DbSession& sesH, const DbType& technology, - DbAccessMode mod=pool::READ) const; + DbAccessMode mod=pool::READ); /// Close domain - DbStatus close() const; + DbStatus close(); /// Access to access mode DbAccessMode openMode() const; /// Access to session handle @@ -111,21 +111,23 @@ namespace pool { /// Check if Database exists within the domain bool existsDbase(const std::string& db_name) const; /// Find Database in domain - DbDatabaseObj* find(const std::string& db_name) const; + const DbDatabaseObj* find(const std::string& db_name) const; + DbDatabaseObj* find(const std::string& db_name); /// Add domain to session - DbStatus add(const std::string& nam, DbDatabaseObj* db) const; + DbStatus add(const std::string& nam, DbDatabaseObj* db); /// Find domain in session - DbStatus remove(DbDatabaseObj* db) const; + DbStatus remove(DbDatabaseObj* db); /// Increase the age of all open databases - DbStatus ageOpenDbs() const; + DbStatus ageOpenDbs(); /// Check if databases are present, which aged a lot and need to be closed - DbStatus closeAgedDbs() const; + DbStatus closeAgedDbs(); /// Set the maximal allowed age limit for files in this domain void setAgeLimit(int value); /// Access the maximal age limit int ageLimit() const; /// Let the implementation access the internals - IDbDomain* info() const; + IDbDomain* info(); + const IDbDomain* info() const; /// Set domain specific options /** @param refOpt [IN] Reference to option object @@ -142,7 +144,8 @@ namespace pool { DbStatus getOption(DbOption& refOpt) const; /// Allow access to the Database implementation - IOODatabase* db() const; + IOODatabase* db(); + const IOODatabase* db() const; }; } // End namespace pool #endif // POOL_DBDOMAIN_H diff --git a/Database/APR/StorageSvc/StorageSvc/DbHandleBase.h b/Database/APR/StorageSvc/StorageSvc/DbHandleBase.h index 9aec0e5df2e6..6622395bcfae 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbHandleBase.h +++ b/Database/APR/StorageSvc/StorageSvc/DbHandleBase.h @@ -1,8 +1,7 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ -// $Id: DbHandleBase.h 726071 2016-02-25 09:23:05Z krasznaa $ //==================================================================== // Pool Handle Base class definitions //-------------------------------------------------------------------- @@ -39,26 +38,28 @@ namespace pool { /// Data type definition typedef DbHandleBase<_DataType> Base; /// Data member: Object pointer. Sub-classes need access on re-assignment - mutable T* m_ptr; + T* m_ptr; /// Data member: Technology type. Sub-classes need access on re-assignment - mutable DbType m_type; + DbType m_type; /// Standard destructor ~DbHandleBase() { m_type.check(); } /// Standard constructor DbHandleBase() : m_ptr(0), m_type(0) { } /// Set handle type - void setType(const DbType& typ) const { m_type=typ; } + void setType(const DbType& typ) { m_type=typ; } /// Set data pointer - void setPtr(T* ptr) const { m_ptr=ptr; } + void setPtr(T* ptr) { m_ptr=ptr; } public: /// Dereference operator - T* operator->() const { return m_ptr; } + T* operator->() { return m_ptr; } + const T* operator->() const { return m_ptr; } /// Validity check through operator NOT bool operator!() const { return !isValid(); } /// Access to underlying object - T* ptr() const { return m_ptr; } + const T* ptr() const { return m_ptr; } + T* ptr() { return m_ptr; } /// Validity check (Objy like) bool isValid() const { return 0 != m_ptr; } /// Inquire storage type of the handle diff --git a/Database/APR/StorageSvc/StorageSvc/DbHeap.h b/Database/APR/StorageSvc/StorageSvc/DbHeap.h index b4c7ea0bbed9..edfcac67e97a 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbHeap.h +++ b/Database/APR/StorageSvc/StorageSvc/DbHeap.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // $Id: DbHeap.h 726071 2016-02-25 09:23:05Z krasznaa $ @@ -44,9 +44,11 @@ namespace pool { /// Access the object guard size static size_t guardSize(); /// Access the offset of an object - static Token::OID_t& oid(const DbObject* pObj); + static Token::OID_t& oid(DbObject* pObj); + static const Token::OID_t& oid(const DbObject* pObj); /// Access the container of an object - static DbContainer& container(const DbObject* pObj); + static DbContainer& container(DbObject* pObj); + static const DbContainer& container(const DbObject* pObj); /// Free an object, which was initially allocated from the heap static DbStatus free(void* ptr, DbContainer* cntH); /// Free an object on the heap diff --git a/Database/APR/StorageSvc/StorageSvc/DbIter.h b/Database/APR/StorageSvc/StorageSvc/DbIter.h index 4504201c9870..b6802f9c33cc 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbIter.h +++ b/Database/APR/StorageSvc/StorageSvc/DbIter.h @@ -84,7 +84,8 @@ namespace pool { /// Access to current object handle (CONST) const DbHandle<T>& handle() const { return m_obj; } /// Dereference operator - T* object() const { return m_obj.ptr(); } + const T* object() const { return m_obj.ptr(); } + T* object() { return m_obj.ptr(); } /// Access to cursor token const Token* token() const { return &m_token; } /// Scan the container diff --git a/Database/APR/StorageSvc/StorageSvc/DbObject.h b/Database/APR/StorageSvc/StorageSvc/DbObject.h index 3af36cd4daa6..32dbade15505 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbObject.h +++ b/Database/APR/StorageSvc/StorageSvc/DbObject.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -20,6 +20,7 @@ #include "StorageSvc/pool.h" #include "StorageSvc/DbType.h" #include "StorageSvc/DbHandleBase.h" +#include "CxxUtils/checker_macros.h" /* * POOL namespace declaration @@ -99,11 +100,11 @@ namespace pool { } public: /// Set handle type - void _setType(const DbType& type) const { Base::setType(type); } + void _setType(const DbType& type) { Base::setType(type); } /// Set object value - template<class T> void _setObject(const T* p) { + template<class T> void _setObject(T* p) { if ( 0 == Base::ptr() && 0 == p ) return; - Base::m_ptr = const_cast<T*>(p); + Base::m_ptr = p; } void _setObject(const int /* null_obj */ ) { if ( 0 == Base::ptr() ) return; @@ -117,12 +118,13 @@ namespace pool { /// Constructor with storage type DbObjectHandle(const DbType& typ) { _setType(typ); } /// Constructor with object pointer - DbObjectHandle(const USER* p) { _setObject(p); } + DbObjectHandle(USER* p) { _setObject(p); } /// Copy constructor DbObjectHandle(const DbObjectHandle<USER>& c) : DbHandleBase<USER>() { _set(c.ptr(),c.type()); } /// Generic assignment operator from base class - operator USER*() const { return Base::ptr(); } + operator const USER*() const { return Base::ptr(); } + operator USER*() { return Base::ptr(); } /// Generic assignment operator DbObjectHandle<USER>& operator=(const int /* nuller */) { _setObject(0); return *this; } @@ -138,9 +140,11 @@ namespace pool { /// Retrieve hosting container const DbContainer& containedIn() const; /// Access object oid - Token::OID_t& oid() const; + const Token::OID_t& oid() const; + /// Access object oid + Token::OID_t& oid(); /// Add persistent association entry - DbStatus makeLink(const Token* pToken, Token::OID_t& linkH) const; + DbStatus makeLink ATLAS_NOT_THREAD_SAFE (const Token* pToken, Token::OID_t& linkH) const; }; @@ -154,7 +158,7 @@ namespace pool { /// Constructor with storage type DbHandle(const DbType& typ) { Handle::_setType(typ); } /// Constructor with object assignment - DbHandle(const USER* obj) { Handle::_setObject(obj);} + DbHandle(USER* obj) { Handle::_setObject(obj);} /// Copy constructor template <typename T> DbHandle(const DbObjectHandle<T>& c) : DbObjectHandle<USER>() @@ -163,18 +167,18 @@ namespace pool { DbHandle(const DbHandle<USER>& c) : DbObjectHandle<USER>() { Handle::_set(c.ptr(),c.type()); } /// Generic assignment operator - DbHandle<USER>& operator=(const DbHandle<USER>& c) { + DbHandle<USER>& operator=(DbHandle<USER>& c) { if ( this != &c ) Handle::_set(c.ptr(),c.type()); return *this; } /// Generic assignment operator - DbHandle<USER>& operator=(const USER* obj) { + DbHandle<USER>& operator=(USER* obj) { if ( Handle::ptr() != obj ) Handle::_setObject(obj); return *this; } /// Generic assignment operator template <typename T> - DbHandle<USER>& operator=(const DbObjectHandle<T>& c) { + DbHandle<USER>& operator=(DbObjectHandle<T>& c) { if ( Handle::ptr() != c.ptr() ) Handle::_set(c.ptr(), c.type()); return *this; } @@ -203,12 +207,17 @@ namespace pool { /// Access object oid template <class T> inline - Token::OID_t& DbObjectHandle<T>::oid() const + Token::OID_t& DbObjectHandle<T>::oid() + { return DbObjectAccessor::objectOid(Base::ptr()); } + + /// Access object oid + template <class T> inline + const Token::OID_t& DbObjectHandle<T>::oid() const { return DbObjectAccessor::objectOid(Base::ptr()); } /// Add persistent association entry template <class T> inline - DbStatus DbObjectHandle<T>::makeLink(const Token* pToken, Token::OID_t& linkH) const + DbStatus DbObjectHandle<T>::makeLink ATLAS_NOT_THREAD_SAFE (const Token* pToken, Token::OID_t& linkH) const { return DbObjectAccessor::makeObjectLink(Base::ptr(), pToken, linkH); } #endif diff --git a/Database/APR/StorageSvc/StorageSvc/DbObjectAccessor.h b/Database/APR/StorageSvc/StorageSvc/DbObjectAccessor.h index f544d3e6421f..2de72010da92 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbObjectAccessor.h +++ b/Database/APR/StorageSvc/StorageSvc/DbObjectAccessor.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -47,12 +47,16 @@ namespace pool { static const DbContainer& containedIn(const DbObject* pObj); /// Access object oid - static Token::OID_t& objectOid(const DbObject* ptr); + static Token::OID_t& objectOid(DbObject* ptr); + + /// Access object oid + static const Token::OID_t& objectOid(const DbObject* ptr); /// Add persistent association entry - static DbStatus makeObjectLink( const DbObject* pObj, - const Token* pToken, - Token::OID_t& tokenH); + static DbStatus makeObjectLink ATLAS_NOT_THREAD_SAFE + ( const DbObject* pObj, + Token* pToken, + Token::OID_t& tokenH ); }; } // End namespace pool diff --git a/Database/APR/StorageSvc/StorageSvc/DbObjectGuard.h b/Database/APR/StorageSvc/StorageSvc/DbObjectGuard.h index 3a2154e815a5..997aceb4ed3e 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbObjectGuard.h +++ b/Database/APR/StorageSvc/StorageSvc/DbObjectGuard.h @@ -1,8 +1,7 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ -// $Id: DbObjectGuard.h 726071 2016-02-25 09:23:05Z krasznaa $ //==================================================================== // DbObjectGuard definition //-------------------------------------------------------------------- @@ -53,10 +52,12 @@ namespace pool { size_t size() const { return m_size; } /// Access oid Token::OID_t& oid() { return m_oid; } + const Token::OID_t& oid() const { return m_oid; } /// Access Storage Type const DbType& type() const { return m_container.type();} /// Accessor: get object container DbContainer& container() { return m_container; } + const DbContainer& container() const { return m_container; } }; } // End namespace pool #endif // POOL_DBOBJECTGUARD_H diff --git a/Database/APR/StorageSvc/StorageSvc/DbSession.h b/Database/APR/StorageSvc/StorageSvc/DbSession.h index 0756b610b680..53ccc0eaaf3c 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbSession.h +++ b/Database/APR/StorageSvc/StorageSvc/DbSession.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // $Id: DbSession.h 726071 2016-02-25 09:23:05Z krasznaa $ @@ -45,14 +45,14 @@ namespace pool { friend class DbSessionObj; private: /// Assign transient object properly (including reference counting) - void switchPtr(const DbSessionObj* obj) const; + void switchPtr(DbSessionObj* obj); public: /// Constructor DbSession(); /// Copy constructor DbSession(const DbSession& copy); /// Object constructor - DbSession(const DbSessionObj* session); + DbSession(DbSessionObj* session); /// Standard destructor virtual ~DbSession(); /// Assignment operator @@ -74,11 +74,11 @@ namespace pool { /// Add domain to session DbStatus add(DbDomainObj* dom) const; /// Find domain in session - DbStatus remove(const DbDomainObj* dom) const; + DbStatus remove(const DbDomainObj* dom); /// Open the session in a given mode DbStatus open(); /// Close the session - DbStatus close() const; + DbStatus close(); /// Allow access to the Database implementation IOODatabase* db(const DbType& typ) const; }; diff --git a/Database/APR/StorageSvc/StorageSvc/DbToken.h b/Database/APR/StorageSvc/StorageSvc/DbToken.h index c4e619a43c14..bfcf53eb0dad 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbToken.h +++ b/Database/APR/StorageSvc/StorageSvc/DbToken.h @@ -54,7 +54,7 @@ namespace pool { /// Optional other user keys std::vector< Guid > m_ukeys; /// Database type information cache - mutable const DbTypeInfo* m_info; + const DbTypeInfo* m_info; /// Flag to indicate if toekn is local or foreign bool m_local; public: @@ -73,7 +73,7 @@ namespace pool { /// Set a user key void setUserKey(int i, const Guid& guid); /// Update type information - void setTypeInfo(const DbTypeInfo* t) const { m_info = t; } + void setTypeInfo(const DbTypeInfo* t) { m_info = t; } /// Access type information const DbTypeInfo* typeInfo() const { return m_info; } /// Set local flag diff --git a/Database/APR/StorageSvc/StorageSvc/DbTypeInfo.h b/Database/APR/StorageSvc/StorageSvc/DbTypeInfo.h index dea43f798400..db66551b654b 100644 --- a/Database/APR/StorageSvc/StorageSvc/DbTypeInfo.h +++ b/Database/APR/StorageSvc/StorageSvc/DbTypeInfo.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // $Id: DbTypeInfo.h 726071 2016-02-25 09:23:05Z krasznaa $ @@ -20,9 +20,11 @@ #include "DataModelRoot/RootType.h" #include "StorageSvc/pool.h" #include "StorageSvc/Shape.h" +#include "CxxUtils/CachedValue.h" // C/C++ include files #include <vector> +#include <atomic> /* * POOL namespace declaration @@ -52,13 +54,13 @@ namespace pool { private: /// Reference counter - mutable int m_refCount; + mutable std::atomic<int> m_refCount; /// Column definitions Columns m_columns; /// Multiplicity int m_mult; /// Reflection class - TypeH m_class; + CxxUtils::CachedValue<TypeH> m_class; protected: /// Constructor with type id diff --git a/Database/APR/StorageSvc/StorageSvc/FileDescriptor.h b/Database/APR/StorageSvc/StorageSvc/FileDescriptor.h index c4d8fa608a06..71df171fd37b 100644 --- a/Database/APR/StorageSvc/StorageSvc/FileDescriptor.h +++ b/Database/APR/StorageSvc/StorageSvc/FileDescriptor.h @@ -1,8 +1,7 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ -// $Id: FileDescriptor.h 726071 2016-02-25 09:23:05Z krasznaa $ //==================================================================== // Storage service file descriptor class definitions //-------------------------------------------------------------------- @@ -27,6 +26,7 @@ namespace pool { // as from IFileCatalog typedef std::string FileID; typedef class DatabaseConnection *ConnectionH; + typedef const DatabaseConnection *ConstConnectionH; /** @class FileDescriptor FileDescriptor.h POOLCore/FileDescriptor.h * @@ -74,7 +74,8 @@ namespace pool { void setFID(const FileID& val) { m_FID = val; } /// Access to file descriptor (READ) - ConnectionH dbc() const { return m_DBC; } + ConnectionH dbc() { return m_DBC; } + ConstConnectionH dbc() const { return m_DBC; } /// Access to file descriptor (WRITE) void setDbc(ConnectionH val) { m_DBC = val; } }; diff --git a/Database/APR/StorageSvc/StorageSvc/IDbContainer.h b/Database/APR/StorageSvc/StorageSvc/IDbContainer.h index 7785e651015c..b1b70fd9b22a 100644 --- a/Database/APR/StorageSvc/StorageSvc/IDbContainer.h +++ b/Database/APR/StorageSvc/StorageSvc/IDbContainer.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // $Id: IDbContainer.h 726071 2016-02-25 09:23:05Z krasznaa $ @@ -83,7 +83,7 @@ namespace pool { /// Close the container virtual DbStatus close() = 0; /// Open the container - virtual DbStatus open( const DbDatabase& dbH, + virtual DbStatus open( DbDatabase& dbH, const std::string& nam, const DbTypeInfo* info, DbAccessMode mode) = 0; @@ -124,7 +124,7 @@ namespace pool { Token::OID_t& linkH) = 0; /// Add object to the container - virtual DbStatus save( const DbObjectHandle<DbObject>& objH) = 0; + virtual DbStatus save( DbObjectHandle<DbObject>& objH) = 0; /// Update existing object in the container /** @param cntH [IN] Valid handle to container * @param object [IN] Pointer to feed data. diff --git a/Database/APR/StorageSvc/StorageSvc/IDbDatabase.h b/Database/APR/StorageSvc/StorageSvc/IDbDatabase.h index c8a3e3a8ff39..62e7aa099f39 100644 --- a/Database/APR/StorageSvc/StorageSvc/IDbDatabase.h +++ b/Database/APR/StorageSvc/StorageSvc/IDbDatabase.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -85,7 +85,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus onOpen(const DbDatabase& dbH, + virtual DbStatus onOpen(DbDatabase& dbH, DbAccessMode mode) = 0; /// Re-open database with changing access permissions diff --git a/Database/APR/StorageSvc/StorageSvc/IStorageExplorer.h b/Database/APR/StorageSvc/StorageSvc/IStorageExplorer.h index c50082253505..74050249a00e 100644 --- a/Database/APR/StorageSvc/StorageSvc/IStorageExplorer.h +++ b/Database/APR/StorageSvc/StorageSvc/IStorageExplorer.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -163,7 +163,7 @@ namespace pool { * @param intern [IN] Flag to access also internal containers * @return DbStatus code indicating success or failure. */ - virtual DbStatus containers( const FileDescriptor& refDB, + virtual DbStatus containers( FileDescriptor& refDB, std::vector<const Token*>& conts, bool intern=false) = 0; @@ -173,7 +173,7 @@ namespace pool { * @param assocs [OUT] Vector with tokens to used containers. * @return DbStatus code indicating success or failure. */ - virtual DbStatus associations(const FileDescriptor& refDB, + virtual DbStatus associations(FileDescriptor& refDB, std::vector<const Token*>& assocs) = 0; /// Access Shapes known to the database. @@ -182,7 +182,7 @@ namespace pool { * @param shapes [OUT] Vector with shapes to used within the database. * @return DbStatus code indicating success or failure. */ - virtual DbStatus shapes( const FileDescriptor& refDB, + virtual DbStatus shapes( FileDescriptor& refDB, std::vector<ShapeH>& shapes) = 0; /// Add a persistent parameter to the database @@ -194,7 +194,7 @@ namespace pool { * @param val [IN] Value of the user parameter to be added. * @return DbStatus code indicating success or failure. */ - virtual DbStatus addDbParam( const FileDescriptor& refDB, + virtual DbStatus addDbParam( FileDescriptor& refDB, const std::string& nam, const std::string& val) = 0; @@ -206,7 +206,7 @@ namespace pool { * @param val [OUT] Value of the user parameter to be retrieved. * @return DbStatus code indicating success or failure. */ - virtual DbStatus dbParam( const FileDescriptor& refDB, + virtual DbStatus dbParam( FileDescriptor& refDB, const std::string& nam, std::string& val) = 0; @@ -217,7 +217,7 @@ namespace pool { * @param vals [OUT] Vector containing all parameter nam/value pairs. * @return DbStatus code indicating success or failure. */ - virtual DbStatus dbParams( const FileDescriptor& refDB, + virtual DbStatus dbParams( FileDescriptor& refDB, Parameters& vals) = 0; /// Retrieve association link from token with redirection when file is merged. @@ -227,7 +227,7 @@ namespace pool { * @param redirections [OUT] Vector containing all parameter nam/value pairs. * @return DbStatus code indicating success or failure. */ - virtual DbStatus dbRedirections(const FileDescriptor& refDB, + virtual DbStatus dbRedirections(FileDescriptor& refDB, pool::DbDatabase::Redirections& redirections) = 0; /// Access options for a given database domain. @@ -269,7 +269,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus getDatabaseOption(const FileDescriptor& refDB, + virtual DbStatus getDatabaseOption(FileDescriptor& refDB, DbOption& opt) = 0; /// Set options for a given database. @@ -281,7 +281,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus setDatabaseOption(const FileDescriptor& refDB, + virtual DbStatus setDatabaseOption(FileDescriptor& refDB, const DbOption& opt) = 0; /// Access options for a given database container. @@ -294,7 +294,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus getContainerOption(const FileDescriptor& refDB, + virtual DbStatus getContainerOption(FileDescriptor& refDB, const std::string& cntName, DbOption& opt) = 0; @@ -308,7 +308,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus setContainerOption(const FileDescriptor& refDB, + virtual DbStatus setContainerOption(FileDescriptor& refDB, const std::string& cntName, const DbOption& opt) = 0; @@ -322,7 +322,7 @@ namespace pool { * @param sel [IN/OUT] Selection criteria * @return DbStatus code indicating success or failure. */ - virtual DbStatus select( const FileDescriptor& refDB, + virtual DbStatus select( FileDescriptor& refDB, const std::string& cntName, DbSelect& sel) = 0; diff --git a/Database/APR/StorageSvc/StorageSvc/IStorageSvc.h b/Database/APR/StorageSvc/StorageSvc/IStorageSvc.h index a31c7f57b9e0..3154b12f5e12 100644 --- a/Database/APR/StorageSvc/StorageSvc/IStorageSvc.h +++ b/Database/APR/StorageSvc/StorageSvc/IStorageSvc.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // $Header: /cvs/PF/pool/StorageSvc/StorageSvc/IStorageSvc.h,v 1.33 2008/05/13 14:39:31 witoldp Exp $ @@ -80,8 +80,8 @@ namespace pool { * @param pToken [IN] Token to the persistent object. * @return std::string container name. */ - virtual std::string getContName(const FileDescriptor& refDB, - const Token& pToken) = 0; + virtual std::string getContName(FileDescriptor& refDB, + Token& pToken) = 0; /// Register object for write /** @@ -95,7 +95,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus allocate( const FileDescriptor& refDB, + virtual DbStatus allocate( FileDescriptor& refDB, const std::string& refCont, int technology, const void* object, @@ -127,10 +127,10 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus update( const FileDescriptor& refDB, + virtual DbStatus update( FileDescriptor& refDB, const void* object, ShapeH shapeH, - const Token& refToken) = 0; + Token& refToken) = 0; /// Destroy an existing persistent object. /** @@ -140,8 +140,8 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus destroy( const FileDescriptor& refDB, - const Token& refToken) = 0; + virtual DbStatus destroy( FileDescriptor& refDB, + Token& refToken) = 0; /// Retrieve persistent shape from Storage manager. /** The persistent shape is saved at write time to a Database. @@ -156,7 +156,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus getShape( const FileDescriptor& refDB, + virtual DbStatus getShape( FileDescriptor& refDB, const Guid& objType, ShapeH& shapeH) = 0; diff --git a/Database/APR/StorageSvc/src/DbContainer.cpp b/Database/APR/StorageSvc/src/DbContainer.cpp index 89db8a6413d3..76ac9c9554db 100644 --- a/Database/APR/StorageSvc/src/DbContainer.cpp +++ b/Database/APR/StorageSvc/src/DbContainer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -21,6 +21,7 @@ #include "StorageSvc/DbToken.h" #include "StorageSvc/DbReflex.h" #include "DbContainerObj.h" +#include "CxxUtils/checker_macros.h" #include <memory> @@ -34,15 +35,15 @@ int DbContainer::refCount() const { } // Open container from handle -DbStatus DbContainer::open( const DbDatabase& dbH, +DbStatus DbContainer::open( DbDatabase& dbH, const string& nam, const DbTypeInfo* typ, const DbType& dbtyp, - DbAccessMode mod) const + DbAccessMode mod) { if ( dbH.isValid() ) { if ( !(dbH.openMode() == pool::READ && mod != pool::READ) ) { - const DbContainerObj* q = dbH.find(nam); + DbContainerObj* q = dbH.find(nam); switchPtr(q ? q : new DbContainerObj(dbH, nam, dbtyp, mod)); if ( mod == pool::READ || mod == pool::UPDATE ) { if ( 0 == typ ) { @@ -58,12 +59,12 @@ DbStatus DbContainer::open( const DbDatabase& dbH, return Error; } -void DbContainer::switchPtr(const DbContainerObj* obj) const { +void DbContainer::switchPtr(DbContainerObj* obj) { if ( obj ) obj->addRef(); if ( m_ptr ) { if (m_ptr->release() == 0) m_ptr = 0; } - m_ptr = const_cast<DbContainerObj*>(obj); + m_ptr = obj; if ( m_ptr ) { m_type = obj->type(); } @@ -74,6 +75,11 @@ const DbDatabase& DbContainer::containedIn() const { return isValid() ? m_ptr->database() : null_dbH; } +DbDatabase& DbContainer::containedIn() { + if (!isValid()) std::abort(); + return m_ptr->database(); +} + long long int DbContainer::size() const { return isValid() ? m_ptr->size() : -1; } @@ -89,7 +95,7 @@ const string& DbContainer::name() const { } /// Close container object if handle is valid -DbStatus DbContainer::close() const { +DbStatus DbContainer::close() { if ( isValid() ) { DbStatus res = m_ptr->close(); switchPtr(0); @@ -124,7 +130,10 @@ const Token* DbContainer::token() const { } /// Access implementation internals -IDbContainer* DbContainer::info() const { +const IDbContainer* DbContainer::info() const { + return isValid() ? m_ptr->info() : 0; +} +IDbContainer* DbContainer::info() { return isValid() ? m_ptr->info() : 0; } @@ -210,7 +219,7 @@ DbStatus DbContainer::update(const void* object, ShapeH shape, const Token::OID_ } /// Save object in the container identified by its handle -DbStatus DbContainer::_save(const DbObjectHandle<DbObject>& objH, const DbTypeInfo* typ) { +DbStatus DbContainer::_save(DbObjectHandle<DbObject>& objH, const DbTypeInfo* typ) { if ( isValid() && objH.isValid() ) { const DbContainer& cnt = objH.containedIn(); // Object MUST be allocated on this container! diff --git a/Database/APR/StorageSvc/src/DbContainerImp.cpp b/Database/APR/StorageSvc/src/DbContainerImp.cpp index e2d4f9a9f79d..21b8a5dd6b30 100644 --- a/Database/APR/StorageSvc/src/DbContainerImp.cpp +++ b/Database/APR/StorageSvc/src/DbContainerImp.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -149,7 +149,7 @@ DbStatus DbContainerImp::transAct(Transaction::Action action) } DbStatus -DbContainerImp::save(const DbObjectHandle<DbObject>& objH) { +DbContainerImp::save(DbObjectHandle<DbObject>& objH) { // Can only be done if no Transaction is ongoing... // i.e. exactly one object was allocated if ( m_writeSize == 1 ) { diff --git a/Database/APR/StorageSvc/src/DbContainerObj.cpp b/Database/APR/StorageSvc/src/DbContainerObj.cpp index ca09fa85fc1d..0d3c56234d1d 100644 --- a/Database/APR/StorageSvc/src/DbContainerObj.cpp +++ b/Database/APR/StorageSvc/src/DbContainerObj.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -25,6 +25,7 @@ #include "StorageSvc/DbTypeInfo.h" #include "StorageSvc/DbContainer.h" #include <memory> +#include <atomic> using namespace std; using namespace pool; @@ -32,7 +33,7 @@ int DbObjectHolder::release() { return 1; } // Enable this to force regular retirement void retireDatabase(DbContainerObj* c) { - static int i=0; + static std::atomic<int> i=0; if ( (++i%2)==0 ) { c->database().setAge(20); c->database().containedIn().closeAgedDbs(); @@ -40,7 +41,7 @@ void retireDatabase(DbContainerObj* c) { } /// Constructor -DbContainerObj::DbContainerObj( const DbDatabase& dbH, +DbContainerObj::DbContainerObj( DbDatabase& dbH, const string& nam, const DbType& dbtyp, DbAccessMode mod) @@ -252,12 +253,12 @@ DbStatus DbContainerObj::addShape(const DbTypeInfo* typ) { } /// Retrieve persistent type information -const DbTypeInfo* DbContainerObj::objectShape(const Guid& guid) const { +const DbTypeInfo* DbContainerObj::objectShape(const Guid& guid) { return m_dbH.objectShape(guid); } /// Add entry to container -DbStatus DbContainerObj::save(const DbObjectHandle<DbObject>& objH, const DbTypeInfo* typ) { +DbStatus DbContainerObj::save(DbObjectHandle<DbObject>& objH, const DbTypeInfo* typ) { if ( !isReadOnly() && hasAccess() && m_isOpen && objH.isValid() ) { if ( m_info->save(objH).isSuccess() ) { if ( m_dbH.addShape(typ).isSuccess() ) { diff --git a/Database/APR/StorageSvc/src/DbContainerObj.h b/Database/APR/StorageSvc/src/DbContainerObj.h index fbaa16516b6c..3dac43d323c0 100644 --- a/Database/APR/StorageSvc/src/DbContainerObj.h +++ b/Database/APR/StorageSvc/src/DbContainerObj.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -71,16 +71,17 @@ namespace pool { * * @return Status code indicating success or failure. */ - DbContainerObj( const DbDatabase& dbH, + DbContainerObj( DbDatabase& dbH, const std::string& nam, const DbType& dbtyp, DbAccessMode mod); /// Standard destructor virtual ~DbContainerObj(); /// Access to internals - IDbContainer* info() const { return m_info; } + const IDbContainer* info() const { return m_info; } + IDbContainer* info() { return m_info; } /// Retrieve persistent type information by name - const DbTypeInfo* objectShape(const Guid& nam) const; + const DbTypeInfo* objectShape(const Guid& nam); /// Add persistent type. Returns error if the type is not supported. DbStatus addShape(const DbTypeInfo* typ); /// Handle to Database (CONST) @@ -116,7 +117,7 @@ namespace pool { /// Destroy an existing persistent object identified by its handle DbStatus destroy(const Token::OID_t& linkH); /// Add an object to the container identified by its handle - DbStatus save(const DbObjectHandle<DbObject>& objH, + DbStatus save(DbObjectHandle<DbObject>& objH, const DbTypeInfo* typ); diff --git a/Database/APR/StorageSvc/src/DbDatabase.cpp b/Database/APR/StorageSvc/src/DbDatabase.cpp index 196a3ca6bf22..2a8039a34889 100644 --- a/Database/APR/StorageSvc/src/DbDatabase.cpp +++ b/Database/APR/StorageSvc/src/DbDatabase.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -32,9 +32,13 @@ const DbDomain& DbDatabase::containedIn() const { static const DbDomain null_dom(m_type); return isValid() ? ptr()->domain() : null_dom; } +DbDomain& DbDatabase::containedIn() { + if (!isValid()) std::abort(); + return ptr()->domain(); +} /// Release handle/switch to new pointer -void DbDatabase::switchPtr(const DbDatabaseObj* obj) const { +void DbDatabase::switchPtr(DbDatabaseObj* obj) { if ( obj ) obj->addRef(); if ( isValid() ) { if (ptr()->release() == 0) { @@ -43,7 +47,7 @@ void DbDatabase::switchPtr(const DbDatabaseObj* obj) const { } } if ( obj ) { - setPtr(const_cast<DbDatabaseObj*>(obj)); + setPtr(obj); setType(obj->type()); } else { setPtr(0); @@ -56,10 +60,10 @@ bool DbDatabase::exist(const DbDomain& dH, const string& n) const { return dH.isValid() ? dH.existsDbase(n) : false; } /// Open Database -DbStatus DbDatabase::open(const DbDomain& domH, +DbStatus DbDatabase::open(DbDomain& domH, const string& pfn, const string& fid, - DbAccessMode mode) const + DbAccessMode mode) { if ( domH.isValid() ) { DbDatabaseObj* db = domH.find(fid); @@ -79,26 +83,26 @@ DbStatus DbDatabase::open(const DbDomain& domH, } /// Close Database -DbStatus DbDatabase::close() const { +DbStatus DbDatabase::close() { if ( isValid() ) ptr()->close(); switchPtr(0); return Success; } /// Access the size of the database: May be undefined for some technologies -long long int DbDatabase::size() const +long long int DbDatabase::size() { return isValid() ? ptr()->size() : -1; } /// Re-open database with changing access permissions -DbStatus DbDatabase::reopen(DbAccessMode mod) const +DbStatus DbDatabase::reopen(DbAccessMode mod) { return isValid() ? ptr()->reopen(mod) : Error; } /// End database access, but still leave database accessible -DbStatus DbDatabase::retire() const +DbStatus DbDatabase::retire() { return isValid() ? ptr()->retire() : Error; } /// Add domain to session -DbStatus DbDatabase::add(const string& nam, DbContainerObj* cnt) const +DbStatus DbDatabase::add(const string& nam, DbContainerObj* cnt) { return (isValid() && cnt) ? ptr()->add(nam, cnt) : Error; } /// Remove domain from session @@ -121,16 +125,20 @@ void DbDatabase::setName(const string& nam) const string& DbDatabase::logon() const { return isValid() ? ptr()->logon() : s_empty; } -/// Find domain in session +/// Select container object in Database const DbContainerObj* DbDatabase::find(const string& nam) const { return isValid() ? ptr()->find(nam) : 0; } +/// Select container object in Database +DbContainerObj* DbDatabase::find(const string& nam) +{ return isValid() ? ptr()->find(nam) : 0; } + /// Check if the database was opened bool DbDatabase::isOpen() const { return isValid(); } /// Add association link to link container -DbStatus DbDatabase::makeLink(const Token* pToken, Token::OID_t& refLink) const +DbStatus DbDatabase::makeLink(Token* pToken, Token::OID_t& refLink) { return isValid() ? ptr()->makeLink(pToken, refLink) : Error; } /// Access to all token redirections from merged files @@ -152,7 +160,7 @@ DbStatus DbDatabase::getLink(const Token::OID_t& oid, int merge_section, Token* { return isValid() ? ptr()->getLink(oid, merge_section, pTok) : Error; } /// Access local container token (if container exists) -std::string DbDatabase::cntName(const Token& token) const +std::string DbDatabase::cntName(Token& token) { return isValid() ? ptr()->cntName(token) : ""; } /// Execute Database Transaction action @@ -165,11 +173,11 @@ DbStatus DbDatabase::setOption(const DbOption& refOpt) { return isValid() ? ptr()->setOption(refOpt) : Error; } /// Pass options from the implementation to the user -DbStatus DbDatabase::getOption(DbOption& refOpt) const +DbStatus DbDatabase::getOption(DbOption& refOpt) { return isValid() ? ptr()->getOption(refOpt) : Error; } /// Access to sections if availible -const DbDatabase::ContainerSections& DbDatabase::sections(const string& cnt) const { +const DbDatabase::ContainerSections& DbDatabase::sections(const string& cnt) { static const ContainerSections s_sect; return isValid() ? ptr()->sections(cnt) : s_sect; } @@ -179,47 +187,47 @@ DbStatus DbDatabase::addShape(const DbTypeInfo* refType) { return isValid() ? ptr()->addShape(refType) : Error; } /// Retrieve persistent type information -const DbTypeInfo* DbDatabase::objectShape(const Guid& guid) const +const DbTypeInfo* DbDatabase::objectShape(const Guid& guid) { return isValid() ? ptr()->objectShape(guid) : 0; } /// Retrieve persistent type information by class handle -const DbTypeInfo* DbDatabase::objectShape(const RootType& typeH) const +const DbTypeInfo* DbDatabase::objectShape(const RootType& typeH) { return isValid() ? ptr()->objectShape(typeH) : 0; } /// Retrieve persistent type information -const DbTypeInfo* DbDatabase::contShape(const string& nam) const +const DbTypeInfo* DbDatabase::contShape(const string& nam) { return isValid() ? ptr()->contShape(nam) : 0; } /// Access local container token (if container exists) -const Token* DbDatabase::cntToken(const string& cntName) const +const Token* DbDatabase::cntToken(const string& cntName) { return isValid() ? ptr()->cntToken(cntName) : 0; } /// Allow access to all known containers -DbStatus DbDatabase::containers(vector<const Token*>& conts,bool with_internal) const +DbStatus DbDatabase::containers(vector<const Token*>& conts,bool with_internal) { return isValid() ? ptr()->containers(conts,with_internal) : Error; } /// Allow access to all known associations between containers -DbStatus DbDatabase::associations(vector<const Token*>& assocs) const +DbStatus DbDatabase::associations(vector<const Token*>& assocs) { return isValid() ? ptr()->associations(assocs) : Error; } /// Allow access to all known shapes used by the database -DbStatus DbDatabase::shapes(vector<const DbTypeInfo*>& shaps) const +DbStatus DbDatabase::shapes(vector<const DbTypeInfo*>& shaps) { return isValid() ? ptr()->shapes(shaps) : Error; } /// Retrieve the number of user parameters -int DbDatabase::nParam() const +int DbDatabase::nParam() { return isValid() ? ptr()->nParam() : -1; } /// Add a persistent parameter to the file -DbStatus DbDatabase::addParam(const string& nam, const string& val) const +DbStatus DbDatabase::addParam(const string& nam, const string& val) { return isValid() ? ptr()->addParam(nam, val) : Error; } /// Retrieve existing parameter by name -DbStatus DbDatabase::param(const string& nam, string& val) const +DbStatus DbDatabase::param(const string& nam, string& val) { return isValid() ? ptr()->param(nam, val) : Error; } /// Retrieve all parameters -DbStatus DbDatabase::params(Parameters& vals) const +DbStatus DbDatabase::params(Parameters& vals) { return isValid() ? ptr()->params(vals) : Error; } /// Access the token of the database object @@ -227,15 +235,21 @@ const Token* DbDatabase::token() const { return isValid() ? ptr()->token() : 0; } /// Access implementation internals -IDbDatabase* DbDatabase::info() const +IDbDatabase* DbDatabase::info() +{ return isValid() ? ptr()->info() : 0; } + +const IDbDatabase* DbDatabase::info() const { return isValid() ? ptr()->info() : 0; } /// Allow access to the Database implementation -IOODatabase* DbDatabase::db() const +IOODatabase* DbDatabase::db() +{ return isValid() ? ptr()->db() : 0; } + +const IOODatabase* DbDatabase::db() const { return isValid() ? ptr()->db() : 0; } /// Update database age -void DbDatabase::setAge(int value) const +void DbDatabase::setAge(int value) { if ( isValid() ) ptr()->setAge(value); } /// Access age value diff --git a/Database/APR/StorageSvc/src/DbDatabaseObj.cpp b/Database/APR/StorageSvc/src/DbDatabaseObj.cpp index c7fa30b796d9..f3c76b7859e3 100644 --- a/Database/APR/StorageSvc/src/DbDatabaseObj.cpp +++ b/Database/APR/StorageSvc/src/DbDatabaseObj.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -44,7 +44,7 @@ static const DbPrintLvl::MsgLevel dbg_lvl = DbPrintLvl::Debug; // Standard Constructor -DbDatabaseObj::DbDatabaseObj( const DbDomain& dom, +DbDatabaseObj::DbDatabaseObj( DbDomain& dom, const string& pfn, const string& fid, DbAccessMode mod) @@ -144,12 +144,12 @@ DbStatus DbDatabaseObj::cleanup() { } // Add association entry -DbStatus DbDatabaseObj::makeLink(const Token* pTok, Token::OID_t& refLnk) { +DbStatus DbDatabaseObj::makeLink(Token* pTok, Token::OID_t& refLnk) { if ( pTok ) { int is_dbTok = (typeid(*pTok) == typeid(DbToken)); LinkMap::iterator i; if ( is_dbTok ) { - DbToken* pdbTok = (DbToken*)pTok; + DbToken* pdbTok = static_cast<DbToken*>(pTok); pdbTok->setKey(DbToken::TOKEN_CONT_KEY); i = m_linkMap.find(pdbTok->contKey()); } @@ -609,7 +609,7 @@ DbStatus DbDatabaseObj::retire() { } /// Access to sections if availible -const DbDatabaseObj::ContainerSections& DbDatabaseObj::sections(const string& cnt) const { +const DbDatabaseObj::ContainerSections& DbDatabaseObj::sections(const string& cnt) { Sections::const_iterator i = m_sections.find(cnt); if ( i == m_sections.end() ) { static const ContainerSections s_sect(1,DbSection()); @@ -740,7 +740,7 @@ DbStatus DbDatabaseObj::getLink(const Token::OID_t& oid, int merge_section, Toke } -std::string DbDatabaseObj::cntName(const Token& token) { +std::string DbDatabaseObj::cntName(Token& token) { if ( 0 == m_info ) open(); if ( 0 != m_info ) { int lnk = m_indexMap[token.oid().first]; // Map link to index @@ -758,7 +758,9 @@ std::string DbDatabaseObj::cntName(const Token& token) { if ( lnk < int(m_linkVec.size()) ) { DbToken* link = m_linkVec[lnk]; if ( link != 0 ) { - if ( token.contID().empty() ) const_cast<Token*>(&token)->setCont(link->contID()); + if ( token.contID().empty() ) { + token.setCont(link->contID()); + } return link->contID(); // in ##Links } } diff --git a/Database/APR/StorageSvc/src/DbDatabaseObj.h b/Database/APR/StorageSvc/src/DbDatabaseObj.h index 6c6c7def0ec1..46765b73d85c 100644 --- a/Database/APR/StorageSvc/src/DbDatabaseObj.h +++ b/Database/APR/StorageSvc/src/DbDatabaseObj.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -97,7 +97,7 @@ namespace pool { /// Collection of retired database containers Containers m_retiredConts; /// Internal string representation type - const DbTypeInfo* m_string_t; + DbTypeInfo* m_string_t; /// Physical Database login std::string m_logon; /// File age counter @@ -114,7 +114,7 @@ namespace pool { DbStatus cleanup(); public: /// Standard constructor of a Database obejct - DbDatabaseObj( const DbDomain& dom, + DbDatabaseObj( DbDomain& dom, const std::string& pfn, const std::string& fid, DbAccessMode mode = pool::READ); @@ -125,9 +125,11 @@ namespace pool { /// Access the size of the database: May be undefined for some technologies long long int size(); /// Access to technology dependent implementation - IDbDatabase* info() const { return m_info; } + IDbDatabase* info() { return m_info; } + const IDbDatabase* info() const { return m_info; } /// Access to domain handle (CONST) DbDomain& domain() { return m_dom; } + const DbDomain& domain() const { return m_dom; } /// Access age value int age() const { return m_fileAge; } /// Access the token of the database object @@ -155,9 +157,9 @@ namespace pool { /// Expand OID into a full Token, based on the Links table. For merged files provide links section# DbStatus getLink(const Token::OID_t& oid, int merge_section, Token* pTok); /// Retrieve container name from link container (using token oid, rather than contID) - std::string cntName(const Token& token); + std::string cntName(Token& token); /// Add association link to link container - DbStatus makeLink(const Token* pToken, Token::OID_t& refLink); + DbStatus makeLink(Token* pToken, Token::OID_t& refLink); /// Retrieve persistent type information by class handle const DbTypeInfo* objectShape(const TypeH& classH); /// Retrieve persistent type information by shape identifier @@ -188,7 +190,7 @@ namespace pool { /// Access options DbStatus getOption(DbOption& refOpt); /// Access to sections if availible - const ContainerSections& sections(const std::string& cnt) const; + const ContainerSections& sections(const std::string& cnt); /// Update database age void setAge(int value); diff --git a/Database/APR/StorageSvc/src/DbDomain.cpp b/Database/APR/StorageSvc/src/DbDomain.cpp index 2285b4f101bb..4c89fb0244a2 100644 --- a/Database/APR/StorageSvc/src/DbDomain.cpp +++ b/Database/APR/StorageSvc/src/DbDomain.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -16,6 +16,7 @@ #include "StorageSvc/DbObject.h" #include "DbDatabaseObj.h" #include "DbDomainObj.h" +#include "CxxUtils/checker_macros.h" using namespace std; using namespace pool; @@ -23,12 +24,12 @@ using namespace pool; static const string s_empty = ""; /// Object constructor -DbDomain::DbDomain(const DbDomainObj* dom) { +DbDomain::DbDomain(DbDomainObj* dom) { switchPtr( dom ); if ( dom ) setType(dom->type()); } -DbStatus DbDomain::open(const DbSession& sesH,const DbType& typ,DbAccessMode mod) const { +DbStatus DbDomain::open(const DbSession& sesH,const DbType& typ,DbAccessMode mod) { if ( !isValid() ) { if ( sesH.isValid() ) { DbType db_typ(typ.majorType()); @@ -45,7 +46,7 @@ DbStatus DbDomain::open(const DbSession& sesH,const DbType& typ,DbAccessMode mod return Success; } -DbStatus DbDomain::close() const { +DbStatus DbDomain::close() { if ( isValid() ) { ptr()->close(); switchPtr(0); @@ -54,7 +55,7 @@ DbStatus DbDomain::close() const { } /// Assign transient object properly (including reference counting) -void DbDomain::switchPtr(const DbDomainObj* obj) const { +void DbDomain::switchPtr(DbDomainObj* obj) { if( obj ) obj->addRef(); if( isValid() ) { if (ptr()->release() == 0) { @@ -63,7 +64,7 @@ void DbDomain::switchPtr(const DbDomainObj* obj) const { } } if( obj ) { - setPtr(const_cast<DbDomainObj*>(obj)); + setPtr(obj); setType(obj->type()); } else { setPtr(0); @@ -72,7 +73,7 @@ void DbDomain::switchPtr(const DbDomainObj* obj) const { } /// Add domain to session -DbStatus DbDomain::add(const string& nam, DbDatabaseObj* dbH) const { +DbStatus DbDomain::add(const string& nam, DbDatabaseObj* dbH) { DbStatus sc = Error; if ( isValid() && dbH ) { sc = ptr()->add(nam, dbH); @@ -84,7 +85,7 @@ DbStatus DbDomain::add(const string& nam, DbDatabaseObj* dbH) const { } /// Find domain in session -DbStatus DbDomain::remove(DbDatabaseObj* dbH) const { +DbStatus DbDomain::remove(DbDatabaseObj* dbH) { DbStatus sc = Error; if ( isValid() && dbH ) { sc = ptr()->remove(dbH); @@ -118,7 +119,10 @@ int DbDomain::refCount() const { return isValid() ? ptr()->refCount() : int(INVALID); } /// Find domain in session -DbDatabaseObj* DbDomain::find(const string& db_name) const +const DbDatabaseObj* DbDomain::find(const string& db_name) const +{ return isValid() ? ptr()->find(db_name) : 0; } + +DbDatabaseObj* DbDomain::find(const string& db_name) { return isValid() ? ptr()->find(db_name) : 0; } /// Check if Database exists within the domain @@ -126,19 +130,25 @@ bool DbDomain::existsDbase(const string& nam) const { return isValid() ? ptr()->existsDbase(nam) : false; } /// Access implementation internals -IDbDomain* DbDomain::info() const +IDbDomain* DbDomain::info() +{ return isValid() ? ptr()->info() : 0; } + +const IDbDomain* DbDomain::info() const { return isValid() ? ptr()->info() : 0; } /// Allow access to the Database implementation -IOODatabase* DbDomain::db() const +IOODatabase* DbDomain::db() +{ return isValid() ? ptr()->db() : 0; } + +const IOODatabase* DbDomain::db() const { return isValid() ? ptr()->db() : 0; } /// Increase the age of all open databases -DbStatus DbDomain::ageOpenDbs() const +DbStatus DbDomain::ageOpenDbs() { return isValid() ? ptr()->ageOpenDbs() : Error; } /// Check if databases are present, which aged a lot and need to be closed -DbStatus DbDomain::closeAgedDbs() const +DbStatus DbDomain::closeAgedDbs() { return isValid() ? ptr()->closeAgedDbs() : Error; } /// Set the maximal allowed age limit for files in this domain diff --git a/Database/APR/StorageSvc/src/DbDomainObj.cpp b/Database/APR/StorageSvc/src/DbDomainObj.cpp index ab3766484068..3cfc0ea61e97 100644 --- a/Database/APR/StorageSvc/src/DbDomainObj.cpp +++ b/Database/APR/StorageSvc/src/DbDomainObj.cpp @@ -78,7 +78,7 @@ DbDomainObj::~DbDomainObj() { << DbPrint::endmsg; } -bool DbDomainObj::existsDbase( const string& name) +bool DbDomainObj::existsDbase( const string& name) const { return (m_info) ? m_info->existsDbase( name ) : false; } DbStatus DbDomainObj::open(DbAccessMode mod) { diff --git a/Database/APR/StorageSvc/src/DbDomainObj.h b/Database/APR/StorageSvc/src/DbDomainObj.h index 63690d170b93..d00ebdc6987f 100644 --- a/Database/APR/StorageSvc/src/DbDomainObj.h +++ b/Database/APR/StorageSvc/src/DbDomainObj.h @@ -1,8 +1,7 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ -// $Id: DbDomainObj.h 726071 2016-02-25 09:23:05Z krasznaa $ //==================================================================== // DbDomainObj object definition //-------------------------------------------------------------------- @@ -53,15 +52,17 @@ namespace pool { /// Standard destructor virtual ~DbDomainObj(); /// Access to technology dependent implementation - IDbDomain* info() const { return m_info; } + IDbDomain* info() { return m_info; } + const IDbDomain* info() const { return m_info; } /// Access session handle DbSession& session() { return m_session; } + const DbSession& session() const { return m_session; } /// Set the maximal allowed age limit for files in this domain void setAgeLimit(int value) { m_maxAge = value; } /// Access the maximal age limit int ageLimit() const { return m_maxAge; } /// Check for Database existence within domain - bool existsDbase(const std::string& nam); + bool existsDbase(const std::string& nam) const; /// Open domain with possible change of access mode DbStatus open(DbAccessMode mode); /// Open domain in default access mode diff --git a/Database/APR/StorageSvc/src/DbHeap.cpp b/Database/APR/StorageSvc/src/DbHeap.cpp index 82eeab869d1c..7683f73a0dbd 100644 --- a/Database/APR/StorageSvc/src/DbHeap.cpp +++ b/Database/APR/StorageSvc/src/DbHeap.cpp @@ -14,8 +14,14 @@ using namespace pool; static const size_t GUARDSIZE = 72; -inline static DbObjectGuard* GUARD(const void* ptr) { - return (DbObjectGuard*) (((char*)ptr)-GUARDSIZE); +inline static DbObjectGuard* GUARD(void* ptr) { + char* cptr = static_cast<char*>(ptr); + return reinterpret_cast<DbObjectGuard*> (cptr-GUARDSIZE); +} + +inline static const DbObjectGuard* GUARD(const void* ptr) { + const char* cptr = static_cast<const char*>(ptr); + return reinterpret_cast<const DbObjectGuard*> (cptr-GUARDSIZE); } /// Standard Constructor @@ -32,12 +38,22 @@ size_t DbHeap::guardSize() { } /// Number of chunks currently allocated from the heap -Token::OID_t& DbHeap::oid(const DbObject* pObj) { +Token::OID_t& DbHeap::oid(DbObject* pObj) { + return GUARD(pObj)->oid(); +} + +/// Number of chunks currently allocated from the heap +const Token::OID_t& DbHeap::oid(const DbObject* pObj) { return GUARD(pObj)->oid(); } /// Number of chunks currently allocated from the heap -DbContainer& DbHeap::container(const DbObject* pObj) { +DbContainer& DbHeap::container(DbObject* pObj) { + return GUARD(pObj)->container(); +} + +/// Number of chunks currently allocated from the heap +const DbContainer& DbHeap::container(const DbObject* pObj) { return GUARD(pObj)->container(); } diff --git a/Database/APR/StorageSvc/src/DbObject.cpp b/Database/APR/StorageSvc/src/DbObject.cpp index 1ef3d5042b63..206a1f9c1573 100644 --- a/Database/APR/StorageSvc/src/DbObject.cpp +++ b/Database/APR/StorageSvc/src/DbObject.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -19,6 +19,7 @@ #include "StorageSvc/DbTypeInfo.h" #include "StorageSvc/DbDatabase.h" #include "StorageSvc/DbContainer.h" +#include "CxxUtils/checker_macros.h" #include <stdexcept> using namespace std; @@ -61,19 +62,25 @@ const DbContainer& DbObjectAccessor::containedIn(const DbObject* pObj) { /// Add a link entry to the Database -DbStatus DbObjectAccessor::makeObjectLink(const DbObject* pObj, - const Token* pTok, - Token::OID_t& lnkH) +DbStatus DbObjectAccessor::makeObjectLink ATLAS_NOT_THREAD_SAFE + (const DbObject* pObj, + Token* pTok, + Token::OID_t& lnkH) { if ( 0 != pTok ) { - const DbDatabase& dbH = DbHeap::container(pObj).containedIn(); + DbDatabase& dbH = DbHeap::container(const_cast<DbObject*>(pObj)).containedIn(); return dbH.makeLink(pTok, lnkH); } return Error; } /// Validate an association of an object -Token::OID_t& DbObjectAccessor::objectOid(const DbObject* pObj) { +Token::OID_t& DbObjectAccessor::objectOid(DbObject* pObj) { + return DbHeap::oid(pObj); +} + +/// Validate an association of an object +const Token::OID_t& DbObjectAccessor::objectOid(const DbObject* pObj) { return DbHeap::oid(pObj); } diff --git a/Database/APR/StorageSvc/src/DbReflex.cpp b/Database/APR/StorageSvc/src/DbReflex.cpp index 533d7220b07a..971bb9627aee 100644 --- a/Database/APR/StorageSvc/src/DbReflex.cpp +++ b/Database/APR/StorageSvc/src/DbReflex.cpp @@ -39,13 +39,13 @@ void genMD5(const string& s, void* code); typedef map<Guid,TypeH> GuidMap; static GuidMap& guid_mapping() { - static GuidMap s_map; + static GuidMap s_map ATLAS_THREAD_SAFE; // protected by guidMapMutex return s_map; } typedef map<TypeH,Guid> TypeMap; static TypeMap& type_mapping() { - static TypeMap s_map; + static TypeMap s_map ATLAS_THREAD_SAFE; // protected by guidMapMutex return s_map; } diff --git a/Database/APR/StorageSvc/src/DbSession.cpp b/Database/APR/StorageSvc/src/DbSession.cpp index 4dd4dcd06103..c7767a26867d 100644 --- a/Database/APR/StorageSvc/src/DbSession.cpp +++ b/Database/APR/StorageSvc/src/DbSession.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //==================================================================== @@ -16,11 +16,12 @@ #include "StorageSvc/DbSession.h" #include "DbDomainObj.h" #include "DbSessionObj.h" +#include "CxxUtils/checker_macros.h" using namespace pool; /// Object constructor -DbSession::DbSession(const DbSessionObj* pSession) { +DbSession::DbSession(DbSessionObj* pSession) { setType(POOL_StorageType); switchPtr(pSession); } @@ -44,12 +45,12 @@ DbSession::~DbSession() { } /// Attach session to handle -void DbSession::switchPtr(const DbSessionObj* obj) const { +void DbSession::switchPtr(DbSessionObj* obj) { if ( obj ) obj->addRef(); if ( m_ptr ) { if (m_ptr->release() == 0) m_ptr = 0; } - m_ptr = const_cast<DbSessionObj*>(obj); + m_ptr = obj; if ( m_ptr ) { setType(m_ptr->type()); } @@ -64,7 +65,7 @@ DbStatus DbSession::open() { } /// Close session by handle -DbStatus DbSession::close() const { +DbStatus DbSession::close() { if ( m_ptr ) { m_ptr->clearEntries(); m_ptr->close(); @@ -86,7 +87,7 @@ DbStatus DbSession::add(DbDomainObj* dom) const { } /// Remove domain from current session -DbStatus DbSession::remove(const DbDomainObj* dom) const { +DbStatus DbSession::remove(const DbDomainObj* dom) { DbStatus sc = Error; if ( isValid() && dom ) { sc = m_ptr->remove(dom); diff --git a/Database/APR/StorageSvc/src/DbStorageExplorer.cpp b/Database/APR/StorageSvc/src/DbStorageExplorer.cpp index caa3f8d6288f..884208a98f1a 100644 --- a/Database/APR/StorageSvc/src/DbStorageExplorer.cpp +++ b/Database/APR/StorageSvc/src/DbStorageExplorer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // $Header: /cvs/PF/pool/StorageSvc/src/DbStorageExplorer.cpp,v 1.26 2010/05/11 00:16:07 frankb Exp $ @@ -32,9 +32,10 @@ using namespace std; using namespace pool; typedef const DbDatabaseObj *DbDatabaseH; +typedef DbDatabaseObj *DbDatabaseHNC; -static DbDatabaseH __DB(const FileDescriptor& fDesc) { - DbDatabaseH handle = DbDatabaseH(fDesc.dbc()->handle()); +static DbDatabaseHNC __DB(FileDescriptor& fDesc) { + DbDatabaseHNC handle = DbDatabaseHNC(fDesc.dbc()->handle()); return handle; } @@ -110,7 +111,7 @@ long long int DbStorageExplorer::databaseSize(FileDescriptor& refDB) const { /// Access the containers in a given database. DbStatus -DbStorageExplorer::containers(const FileDescriptor& refDB,TokenVec& conts,bool intern) { +DbStorageExplorer::containers(FileDescriptor& refDB,TokenVec& conts,bool intern) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { DbDatabase dbH(__DB(refDB)); @@ -120,7 +121,7 @@ DbStorageExplorer::containers(const FileDescriptor& refDB,TokenVec& conts,bool i } /// Access the container level associations between objects. -DbStatus DbStorageExplorer::associations(const FileDescriptor& refDB,TokenVec& assocs) { +DbStatus DbStorageExplorer::associations(FileDescriptor& refDB,TokenVec& assocs) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { DbDatabase dbH(__DB(refDB)); @@ -130,7 +131,7 @@ DbStatus DbStorageExplorer::associations(const FileDescriptor& refDB,TokenVec& a } /// Access Shapes known to the database. -DbStatus DbStorageExplorer::shapes(const FileDescriptor& refDB,vector<ShapeH>& shaps) { +DbStatus DbStorageExplorer::shapes(FileDescriptor& refDB,vector<ShapeH>& shaps) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { // Unfortunately STL does not propagate casts of contained types @@ -146,7 +147,7 @@ DbStatus DbStorageExplorer::shapes(const FileDescriptor& refDB,vector<ShapeH>& s /// Add a persistent parameter to the database DbStatus -DbStorageExplorer::addDbParam(const FileDescriptor& refDB,const string& nam,const string& val) { +DbStorageExplorer::addDbParam(FileDescriptor& refDB,const string& nam,const string& val) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { DbDatabase dbH(__DB(refDB)); @@ -157,7 +158,7 @@ DbStorageExplorer::addDbParam(const FileDescriptor& refDB,const string& nam,cons /// Retrieve existing parameter by name DbStatus -DbStorageExplorer::dbParam(const FileDescriptor& refDB,const string& nam,string& val) { +DbStorageExplorer::dbParam(FileDescriptor& refDB,const string& nam,string& val) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { DbDatabase dbH(__DB(refDB)); @@ -167,7 +168,7 @@ DbStorageExplorer::dbParam(const FileDescriptor& refDB,const string& nam,string& } /// Retrieve all parameters -DbStatus DbStorageExplorer::dbParams( const FileDescriptor& refDB,Parameters& vals) { +DbStatus DbStorageExplorer::dbParams( FileDescriptor& refDB,Parameters& vals) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { DbDatabase dbH(__DB(refDB)); @@ -177,7 +178,7 @@ DbStatus DbStorageExplorer::dbParams( const FileDescriptor& refDB,Parameters& va } /// Retrieve association link from token with redirection when file is merged. -DbStatus DbStorageExplorer::dbRedirections(const FileDescriptor& refDB, pool::DbDatabase::Redirections& redirections) { +DbStatus DbStorageExplorer::dbRedirections(FileDescriptor& refDB, pool::DbDatabase::Redirections& redirections) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { DbDatabase dbH(__DB(refDB)); @@ -198,7 +199,7 @@ DbStatus DbStorageExplorer::setDomainOption( const SessionH sessionH, const DbO } /// Access options for a given database. -DbStatus DbStorageExplorer::getDatabaseOption(const FileDescriptor& refDB,DbOption& opt) { +DbStatus DbStorageExplorer::getDatabaseOption(FileDescriptor& refDB,DbOption& opt) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { DbDatabase dbH(__DB(refDB)); @@ -209,7 +210,7 @@ DbStatus DbStorageExplorer::getDatabaseOption(const FileDescriptor& refDB,DbOpti /// Set options for a given database. DbStatus -DbStorageExplorer::setDatabaseOption(const FileDescriptor& refDB,const DbOption& opt) { +DbStorageExplorer::setDatabaseOption(FileDescriptor& refDB,const DbOption& opt) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { DbDatabase dbH(__DB(refDB)); @@ -220,7 +221,7 @@ DbStorageExplorer::setDatabaseOption(const FileDescriptor& refDB,const DbOption& /// Access options for a given database. DbStatus -DbStorageExplorer::getContainerOption(const FileDescriptor& refDB,const string& cntName,DbOption& opt) +DbStorageExplorer::getContainerOption(FileDescriptor& refDB,const string& cntName,DbOption& opt) { const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); if ( dbc ) { @@ -240,7 +241,7 @@ DbStorageExplorer::getContainerOption(const FileDescriptor& refDB,const string& } /// Set options for a given database. -DbStatus DbStorageExplorer::setContainerOption(const FileDescriptor& refDB, +DbStatus DbStorageExplorer::setContainerOption(FileDescriptor& refDB, const string& cntName, const DbOption& opt) { @@ -262,13 +263,13 @@ DbStatus DbStorageExplorer::setContainerOption(const FileDescriptor& refDB, } /// Initiate a selection on a given container. -DbStatus DbStorageExplorer::select(const FileDescriptor& refDB, +DbStatus DbStorageExplorer::select(FileDescriptor& refDB, const string& cntName, DbSelect& sel) { - const DbConnection* dbc = dynamic_cast<const DbConnection*>(refDB.dbc()); + DbConnection* dbc = dynamic_cast<DbConnection*>(refDB.dbc()); if ( dbc ) { - DbDatabase dbH(DbDatabaseH(dbc->handle())); + DbDatabase dbH(DbDatabaseHNC(dbc->handle())); if ( dbH.isValid() ) { return sel.start(dbH, cntName); } diff --git a/Database/APR/StorageSvc/src/DbStorageExplorer.h b/Database/APR/StorageSvc/src/DbStorageExplorer.h index da437a6e9f0a..226bb71ae489 100644 --- a/Database/APR/StorageSvc/src/DbStorageExplorer.h +++ b/Database/APR/StorageSvc/src/DbStorageExplorer.h @@ -162,7 +162,7 @@ namespace pool { * @param intern [IN] Flag to access also internal containers * @return DbStatus code indicating success or failure. */ - virtual DbStatus containers( const FileDescriptor& refDB, + virtual DbStatus containers( FileDescriptor& refDB, TokenVec& conts, bool intern); @@ -172,7 +172,7 @@ namespace pool { * @param assocs [OUT] Vector with tokens to used containers. * @return DbStatus code indicating success or failure. */ - virtual DbStatus associations(const FileDescriptor& refDB, + virtual DbStatus associations(FileDescriptor& refDB, TokenVec& assocs); /// Access Shapes known to the database. @@ -181,7 +181,7 @@ namespace pool { * @param shapes [OUT] Vector with shapes to used within the database. * @return DbStatus code indicating success or failure. */ - virtual DbStatus shapes( const FileDescriptor& refDB, + virtual DbStatus shapes( FileDescriptor& refDB, std::vector<ShapeH>& shapes); /// Add a persistent parameter to the database @@ -193,7 +193,7 @@ namespace pool { * @param val [IN] Value of the user parameter to be added. * @return DbStatus code indicating success or failure. */ - virtual DbStatus addDbParam( const FileDescriptor& refDB, + virtual DbStatus addDbParam( FileDescriptor& refDB, const std::string& nam, const std::string& val); @@ -205,7 +205,7 @@ namespace pool { * @param val [OUT] Value of the user parameter to be retrieved. * @return DbStatus code indicating success or failure. */ - virtual DbStatus dbParam( const FileDescriptor& refDB, + virtual DbStatus dbParam( FileDescriptor& refDB, const std::string& nam, std::string& val); @@ -216,7 +216,7 @@ namespace pool { * @param vals [OUT] Vector containing all parameter nam/value pairs. * @return DbStatus code indicating success or failure. */ - virtual DbStatus dbParams( const FileDescriptor& refDB, + virtual DbStatus dbParams( FileDescriptor& refDB, Parameters& vals); /// Retrieve association link from token with redirection when file is merged. @@ -226,7 +226,7 @@ namespace pool { * @param redirections [OUT] Vector containing all parameter nam/value pairs. * @return DbStatus code indicating success or failure. */ - virtual DbStatus dbRedirections(const FileDescriptor& refDB, + virtual DbStatus dbRedirections(FileDescriptor& refDB, pool::DbDatabase::Redirections& redirections); /// Access options for a given database domain. @@ -268,7 +268,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus getDatabaseOption( const FileDescriptor& refDB, + virtual DbStatus getDatabaseOption( FileDescriptor& refDB, DbOption& opt); /// Set options for a given database. @@ -280,7 +280,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus setDatabaseOption( const FileDescriptor& refDB, + virtual DbStatus setDatabaseOption( FileDescriptor& refDB, const DbOption& opt); /// Access options for a given database container. @@ -293,7 +293,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus getContainerOption(const FileDescriptor& refDB, + virtual DbStatus getContainerOption(FileDescriptor& refDB, const std::string& cntName, DbOption& opt); @@ -307,7 +307,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus setContainerOption(const FileDescriptor& refDB, + virtual DbStatus setContainerOption(FileDescriptor& refDB, const std::string& cntName, const DbOption& opt); @@ -321,7 +321,7 @@ namespace pool { * @param sel [IN/OUT] Selection criteria * @return DbStatus code indicating success or failure. */ - virtual DbStatus select( const FileDescriptor& refDB, + virtual DbStatus select( FileDescriptor& refDB, const std::string& cntName, DbSelect& sel); diff --git a/Database/APR/StorageSvc/src/DbStorageSvc.cpp b/Database/APR/StorageSvc/src/DbStorageSvc.cpp index dd0191ea2406..f3510dbd6ac4 100644 --- a/Database/APR/StorageSvc/src/DbStorageSvc.cpp +++ b/Database/APR/StorageSvc/src/DbStorageSvc.cpp @@ -50,6 +50,7 @@ namespace pool { typedef DbObjectHandle<DbObject> ObjHandle; typedef const DbTypeInfo *DbTypeInfoH; typedef const DbDatabaseObj *DbDatabaseH; + typedef DbDatabaseObj *DbDatabaseHNC; class DbClassMap : public map<TypeH, Guid> {}; @@ -129,9 +130,9 @@ DbStatus DbStorageSvc::finalize() { return Success; } -std::string DbStorageSvc::getContName(const FileDescriptor& refDB, const Token& persToken) { +std::string DbStorageSvc::getContName(FileDescriptor& refDB, Token& persToken) { if ( m_domH.isValid() ) { - DbDatabase dbH(DbDatabaseH(refDB.dbc()->handle())); + DbDatabase dbH(DbDatabaseHNC(refDB.dbc()->handle())); if ( dbH.isValid() ) { return dbH.cntName(persToken); } @@ -140,13 +141,13 @@ std::string DbStorageSvc::getContName(const FileDescriptor& refDB, const Token& } /// Retrieve persistent shape from Storage manager. -DbStatus DbStorageSvc::getShape( const FileDescriptor& fDesc, +DbStatus DbStorageSvc::getShape( FileDescriptor& fDesc, const Guid& objType, ShapeH& shape) { shape = 0; if ( /*0 != &fDesc &&*/ m_domH.isValid() ) { - DbDatabase dbH(DbDatabaseH(fDesc.dbc()->handle())); + DbDatabase dbH(DbDatabaseHNC(fDesc.dbc()->handle())); if ( !dbH.isValid() ) { DbStatus sc = dbH.open(m_domH, fDesc.PFN(), fDesc.FID(), pool::READ); if ( !sc.isSuccess() ) { @@ -196,7 +197,7 @@ DbStatus DbStorageSvc::createShape( const FileDescriptor& /*fDesc */, } /// Register object for write -DbStatus DbStorageSvc::allocate( const FileDescriptor& fDesc, +DbStatus DbStorageSvc::allocate( FileDescriptor& fDesc, const string& refCont, int technology, const void* object, @@ -207,8 +208,8 @@ DbStatus DbStorageSvc::allocate( const FileDescriptor& fDesc, refpToken = 0; if( shape && object ) { - const void* handle = fDesc.dbc()->handle(); - DbDatabase dbH((DbDatabaseH)handle); + void* handle = fDesc.dbc()->handle(); + DbDatabase dbH((DbDatabaseHNC)handle); DbContainer cntH(dbH.type()); sc = cntH.open( dbH, refCont, @@ -241,15 +242,15 @@ DbStatus DbStorageSvc::allocate( const FileDescriptor& fDesc, } /// In place update of an existing object. -DbStatus DbStorageSvc::update( const FileDescriptor& fDesc, +DbStatus DbStorageSvc::update( FileDescriptor& fDesc, const void* object, ShapeH shape, - const Token& refToken ) + Token& refToken ) { DbStatus sc = Error; if( shape && object ) { - const void* handle = fDesc.dbc()->handle(); - DbDatabase dbH((DbDatabaseH)handle); + void* handle = fDesc.dbc()->handle(); + DbDatabase dbH((DbDatabaseHNC)handle); if ( dbH.isValid() ) { DbContainer cntH(dbH.find(dbH.cntName(refToken))); if ( !cntH.isValid() ) { @@ -282,10 +283,10 @@ DbStatus DbStorageSvc::update( const FileDescriptor& fDesc, /// Destroy an existing persistent object. DbStatus -DbStorageSvc::destroy( const FileDescriptor& refDB, const Token& refToken ) +DbStorageSvc::destroy( FileDescriptor& refDB, Token& refToken ) { - const void* handle = refDB.dbc()->handle(); - DbDatabase dbH((DbDatabaseH)handle); + void* handle = refDB.dbc()->handle(); + DbDatabase dbH((DbDatabaseHNC)handle); if ( dbH.isValid() ) { DbContainer cntH(dbH.find(dbH.cntName(refToken))); if ( !cntH.isValid() ) { @@ -436,7 +437,7 @@ DbStatus DbStorageSvc::connect(const SessionH session,int mod,FileDescriptor& fD DbStatus DbStorageSvc::reconnect(FileDescriptor& refDb, int mode) { DbConnection* dbc = dynamic_cast<DbConnection*>(refDb.dbc()); if ( dbc ) { - DbDatabase dbH(DbDatabaseH(dbc->handle())); + DbDatabase dbH(DbDatabaseHNC(dbc->handle())); return dbH.reopen(mode); } return Error; @@ -449,7 +450,7 @@ DbStatus DbStorageSvc::disconnect(FileDescriptor& fDesc) { log << DbPrintLvl::Debug << "Disconnect request for database: FID=" << fDesc.FID() << " PFN=" << fDesc.PFN() << DbPrint::endmsg; if ( dbc ) { - DbDatabase dbH(DbDatabaseH(dbc->handle())); + DbDatabase dbH(DbDatabaseHNC(dbc->handle())); dbc->release(); fDesc.setDbc(0); log << DbPrintLvl::Debug << "Closing database: FID=" << fDesc.FID() << DbPrint::endmsg; @@ -462,7 +463,7 @@ DbStatus DbStorageSvc::disconnect(FileDescriptor& fDesc) { DbStatus DbStorageSvc::openMode(FileDescriptor& refDB, int& mode) { DbConnection* dbc = dynamic_cast<DbConnection*>(refDB.dbc()); if ( dbc ) { - DbDatabase dbH(DbDatabaseH(dbc->handle())); + DbDatabase dbH(DbDatabaseHNC(dbc->handle())); if ( dbH.isOpen() ) { mode = dbH.openMode(); return Success; diff --git a/Database/APR/StorageSvc/src/DbStorageSvc.h b/Database/APR/StorageSvc/src/DbStorageSvc.h index d77448c40586..09fa0915a566 100644 --- a/Database/APR/StorageSvc/src/DbStorageSvc.h +++ b/Database/APR/StorageSvc/src/DbStorageSvc.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // $Header: /cvs/PF/pool/StorageSvc/src/DbStorageSvc.h,v 1.36 2008/03/04 18:34:59 frankb Exp $ @@ -112,7 +112,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus allocate( const FileDescriptor& refDB, + virtual DbStatus allocate( FileDescriptor& refDB, const std::string& refCont, int technology, const void* object, @@ -129,10 +129,10 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus update( const FileDescriptor& refDB, + virtual DbStatus update( FileDescriptor& refDB, const void* object, ShapeH shapeH, - const Token& refToken); + Token& refToken); /// Destroy an existing persistent object. /** @@ -142,8 +142,8 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus destroy( const FileDescriptor& refDB, - const Token& refToken); + virtual DbStatus destroy( FileDescriptor& refDB, + Token& refToken); /// Read a persistent object from the medium. @@ -166,8 +166,8 @@ namespace pool { * @param pToken [IN] Token to the persistent object. * @return std::string container name. */ - virtual std::string getContName(const FileDescriptor& refDB, - const Token& persToken); + virtual std::string getContName(FileDescriptor& refDB, + Token& persToken); /// Retrieve persistent shape from Storage manager. /** The persistent shape is saved at write time to a Database. @@ -182,7 +182,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus getShape( const FileDescriptor& refDB, + virtual DbStatus getShape( FileDescriptor& refDB, const Guid& objType, ShapeH& shapeH); diff --git a/Database/APR/StorageSvc/src/DbToken.cpp b/Database/APR/StorageSvc/src/DbToken.cpp index ee984724d783..f4846aafcfa2 100644 --- a/Database/APR/StorageSvc/src/DbToken.cpp +++ b/Database/APR/StorageSvc/src/DbToken.cpp @@ -1,8 +1,7 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ -// $Id: DbToken.cpp 726071 2016-02-25 09:23:05Z krasznaa $ //==================================================================== // Implementation file of a DbToken class //-------------------------------------------------------------------- @@ -12,6 +11,7 @@ // @author M.Frank //==================================================================== #include "StorageSvc/DbToken.h" +#include "CxxUtils/checker_macros.h" #include <cstdio> using namespace pool; @@ -87,7 +87,7 @@ void DbToken::setUserKey(int i, const Guid& guid) { /// Fast token comparison bool DbToken::equal(const Token& refTok) const { - DbToken* dbTok = (DbToken*)&refTok; + const DbToken* dbTok = static_cast<const DbToken*>(&refTok); if ( this == dbTok ) { return true; } @@ -99,7 +99,7 @@ bool DbToken::equal(const Token& refTok) const { /// Fast token comparison bool DbToken::less(const Token& refTok) const { - DbToken* dbTok = (DbToken*)&refTok; + const DbToken* dbTok = static_cast<const DbToken*>(&refTok); if ( this == dbTok ) { return false; } diff --git a/Database/APR/StorageSvc/src/DbTransform.cpp b/Database/APR/StorageSvc/src/DbTransform.cpp index 56d6a82fcb1c..babe9a57e0d9 100644 --- a/Database/APR/StorageSvc/src/DbTransform.cpp +++ b/Database/APR/StorageSvc/src/DbTransform.cpp @@ -5,6 +5,7 @@ #include "PersistentDataModel/Guid.h" #include "StorageSvc/DbTransform.h" #include "StorageSvc/DbTypeInfo.h" +#include "CxxUtils/checker_macros.h" #include <algorithm> #include <map> @@ -28,7 +29,7 @@ namespace { ShapeVector m_ownedShapes; static _Init& instance() { - static _Init _inst; + static _Init _inst ATLAS_THREAD_SAFE; // Protected by shapesMutex return _inst; } _Init() {} diff --git a/Database/APR/StorageSvc/src/DbTypeInfo.cpp b/Database/APR/StorageSvc/src/DbTypeInfo.cpp index a03b5cf6ff2c..c05b152a4549 100644 --- a/Database/APR/StorageSvc/src/DbTypeInfo.cpp +++ b/Database/APR/StorageSvc/src/DbTypeInfo.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ @@ -136,9 +136,11 @@ DbTypeInfo::DbTypeInfo(const Guid& guid, TypeH type, Columns& cols) : Shape(), m_refCount( 0 ), m_columns(), - m_mult( 0 ), - m_class( type ) + m_mult( 0 ) { + if (type) { + m_class.store (type); + } setShapeID(guid); if( cols.size() == 0 ) { std::string full = DbReflex::fullTypeName(type); @@ -175,8 +177,7 @@ DbTypeInfo::DbTypeInfo(const Guid& guid) : Shape(), m_refCount( 0 ), m_columns(), - m_mult( 0 ), - m_class( ) + m_mult( 0 ) { setShapeID(guid); } @@ -191,22 +192,21 @@ DbTypeInfo::~DbTypeInfo() { /// Access to reflection class (if availible) TypeH DbTypeInfo::clazz( bool noIdScan ) const { - if ( m_class || noIdScan ) { - return m_class; + if ( m_class.isValid() ) { + return *m_class.ptr(); + } + if ( noIdScan || m_columns.size() == 0 ) { + return TypeH(); } - else if ( !m_class && m_columns.size() > 0 ) { - static std::once_flag convert; - std::call_once (convert, - [&] { - DbTypeInfo* thisPtr = const_cast<DbTypeInfo*>(this); - try { - thisPtr->m_class = DbReflex::forGuid(m_id); - } - catch(...) {} - }); - return m_class; + TypeH cls; + try { + cls = DbReflex::forGuid (m_id); + if (cls.Class()) { + m_class.set (cls); + } } - return m_class; + catch(...) {} + return cls; } /// Allow usage of base classes @@ -227,10 +227,11 @@ const std::string DbTypeInfo::toString() const { rep = "{ID="; rep += shapeID().toString(); rep += "}"; - if ( !m_class ) + TypeH cls = clazz(); + if ( !cls ) rep += "{CL=<no_class>}"; else - rep += "{CL=" + DbReflex::fullTypeName(m_class) + "}"; + rep += "{CL=" + DbReflex::fullTypeName(cls) + "}"; sprintf(txt,"{NCOL=%ld}{CNT=%d}", long(m_columns.size()), m_mult); rep += txt; for(Columns::const_iterator i=m_columns.begin(); i<m_columns.end();++i) { @@ -274,12 +275,19 @@ Again: setShapeID(s); // this->clazz(); break; - case 1: - m_class = DbReflex::forTypeName(s); - if ( m_class && shapeID() == Guid::null() ) { - setShapeID(DbReflex::guid(m_class)); + case 1: { + TypeH cls = DbReflex::forTypeName(s); + if (cls) { + m_class.store (cls); + } + else { + m_class.reset(); + } + if ( cls && shapeID() == Guid::null() ) { + setShapeID(DbReflex::guid(cls)); } break; + } case 2: ::sscanf(s.c_str(), "%99d", &ncol); break; @@ -326,9 +334,13 @@ const DbTypeInfo* DbTypeInfo::fromString(const std::string& string_rep) // find existing typeinfo or create a fresh one based on transient dictionary // do this first to ensure current type is first in the DbTransform list //cout << " -- fromDbString DbTypeInfo: " << string_rep << " GUID=" << new_type_info->shapeID() << endl; + TypeH cls; + if (new_type_info->m_class.isValid()) { + cls = *new_type_info->m_class.ptr(); + } if( DbTransform::getShape( new_type_info->shapeID() , main_type_info) != DbStatus::Success) { // new shape - if( !new_type_info->m_class ) { + if( !cls ) { // no transient type info for this type, use the string description as it is DbTransform::regShape( new_type_info ); //cout << "DbTypeInfo::fromString: registered new " << string_rep << endl; @@ -336,13 +348,13 @@ const DbTypeInfo* DbTypeInfo::fromString(const std::string& string_rep) } // create new shape from transient type Columns cols; - main_type_info = new DbTypeInfo( new_type_info->shapeID(), new_type_info->m_class, cols ); + main_type_info = new DbTypeInfo( new_type_info->shapeID(), cls, cols ); DbTransform::regShape(main_type_info); created_main_ti = true; // cout << "DbTypeInfo::fromString: registered new " << main_type_info->toString() << endl; } // current shape is now registered, check if the one from DB has the same column names - if( new_type_info->m_class && main_type_info->toString() != string_rep ) { + if( cls && main_type_info->toString() != string_rep ) { // difference. See if DB shape is already known if( created_main_ti ) { // store pointer for later deletion to avoid memory leak diff --git a/Database/APR/StorageSvc/test/StorageSvc_getGuid_test.cxx b/Database/APR/StorageSvc/test/StorageSvc_getGuid_test.cxx index 9b179bd3ea74..91ec0d34f544 100644 --- a/Database/APR/StorageSvc/test/StorageSvc_getGuid_test.cxx +++ b/Database/APR/StorageSvc/test/StorageSvc_getGuid_test.cxx @@ -9,9 +9,7 @@ using namespace pool; using namespace std; -DbPrint mylog("APR Guid TEST"); - -bool testGuid( const string& guid, bool shouldwork ) +bool testGuid( const string& guid, bool shouldwork, DbPrint& mylog ) { TypeH typ = DbReflex::forGuid( Guid(guid) ); @@ -28,10 +26,11 @@ bool testGuid( const string& guid, bool shouldwork ) int main() { + DbPrint mylog("APR Guid TEST"); mylog.setLevel( DbPrintLvl::Verbose ); bool res = true; - res = testGuid( "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAF", false ) and res; - res = testGuid( "F41DF744-242D-11E6-B472-02163E010CEC", true ) and res; + res = testGuid( "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAF", false, mylog ) and res; + res = testGuid( "F41DF744-242D-11E6-B472-02163E010CEC", true, mylog ) and res; mylog << DbPrintLvl::Info << "Test " << (res?"SUCCESS":"FAILURE") << DbPrint::endmsg; return res? 0 : -1; -- GitLab From be684ab0b294ae6fc9b9d8b6d80db4734b2a83d9 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Tue, 20 Apr 2021 13:12:05 -0400 Subject: [PATCH 2/3] PersistencySvc: Thread-safety checker fixes. Adjust for interface changes in StorageSvc to fix thread-safety checker warnings. --- Database/APR/PersistencySvc/src/Container.cpp | 4 ++-- Database/APR/PersistencySvc/src/Container.h | 6 +++--- Database/APR/PersistencySvc/src/DatabaseHandler.cpp | 9 +++++---- Database/APR/PersistencySvc/src/DatabaseHandler.h | 8 ++++---- Database/APR/PersistencySvc/src/TokenIterator.cpp | 4 ++-- Database/APR/PersistencySvc/src/TokenIterator.h | 4 ++-- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Database/APR/PersistencySvc/src/Container.cpp b/Database/APR/PersistencySvc/src/Container.cpp index a2116991a855..8596b45d890f 100644 --- a/Database/APR/PersistencySvc/src/Container.cpp +++ b/Database/APR/PersistencySvc/src/Container.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "Container.h" @@ -8,7 +8,7 @@ #include "StorageSvc/DbOption.h" #include "TokenIterator.h" -pool::PersistencySvc::Container::Container( const FileDescriptor& fileDescriptor, +pool::PersistencySvc::Container::Container( FileDescriptor& fileDescriptor, IStorageExplorer& storageExplorer, long technology, const std::string& name ): diff --git a/Database/APR/PersistencySvc/src/Container.h b/Database/APR/PersistencySvc/src/Container.h index 11423cf16af3..7da9897ba9c2 100644 --- a/Database/APR/PersistencySvc/src/Container.h +++ b/Database/APR/PersistencySvc/src/Container.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef INCLUDE_PERSISTENCYSVC_CONTAINER_H @@ -26,7 +26,7 @@ namespace pool { class Container : virtual public IContainer, virtual public ITechnologySpecificAttributes { public: - Container( const FileDescriptor& fileDescriptor, + Container( FileDescriptor& fileDescriptor, IStorageExplorer& storageExplorer, long technology, const std::string& name ); @@ -64,7 +64,7 @@ namespace pool { private: /// Reference to file descriptor of the parent database - const FileDescriptor& m_fileDescriptor; + FileDescriptor& m_fileDescriptor; /// Reference to the storage explorer IStorageExplorer& m_storageExplorer; diff --git a/Database/APR/PersistencySvc/src/DatabaseHandler.cpp b/Database/APR/PersistencySvc/src/DatabaseHandler.cpp index d7e40b61b3c9..bcb2eec23998 100644 --- a/Database/APR/PersistencySvc/src/DatabaseHandler.cpp +++ b/Database/APR/PersistencySvc/src/DatabaseHandler.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "DatabaseHandler.h" @@ -79,7 +79,8 @@ pool::PersistencySvc::DatabaseHandler::containers() m_storageExplorer.containers( m_fileDescriptor, containerTokens ); for ( std::vector<const Token*>::const_iterator iToken = containerTokens.begin(); iToken != containerTokens.end(); ++iToken ) { - result.push_back( m_storageSvc.getContName(m_fileDescriptor, **iToken) ); + Token tok (*iToken); + result.push_back( m_storageSvc.getContName(m_fileDescriptor, tok) ); } return result; } @@ -192,7 +193,7 @@ bool pool::PersistencySvc::DatabaseHandler::attribute( const std::string& attributeName, void* data, const std::type_info& typeInfo, - const std::string& option ) const + const std::string& option ) { pool::DbOption databaseOption( attributeName, option ); pool::DbStatus sc = m_storageExplorer.getDatabaseOption( m_fileDescriptor, databaseOption ); @@ -227,7 +228,7 @@ pool::PersistencySvc::DatabaseHandler::setAttribute( const std::string& attribut pool::DbDatabase::Redirections -pool::PersistencySvc::DatabaseHandler::redirections() const +pool::PersistencySvc::DatabaseHandler::redirections() { pool::DbDatabase::Redirections redirections; m_storageExplorer.dbRedirections( m_fileDescriptor, redirections ); diff --git a/Database/APR/PersistencySvc/src/DatabaseHandler.h b/Database/APR/PersistencySvc/src/DatabaseHandler.h index 2df46d1ac272..9ad73b491525 100644 --- a/Database/APR/PersistencySvc/src/DatabaseHandler.h +++ b/Database/APR/PersistencySvc/src/DatabaseHandler.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef INCLUDE_PERSISTENCYSVC_DATABASEHANDLER_H @@ -67,7 +67,7 @@ namespace pool { const std::string& fid() const; /// Returns the merged file identifier - pool::DbDatabase::Redirections redirections() const; + pool::DbDatabase::Redirections redirections(); /// Returns the technology identifier long technology() const; @@ -87,11 +87,11 @@ namespace pool { /// Reads an object given a token void* readObject( const Token& token, void* object = 0 ); - /// Returns an attrtibute + /// Returns an attribute bool attribute( const std::string& attributeName, void* data, const std::type_info& typeInfo, - const std::string& option ) const; + const std::string& option ); /// Sets an attrtibute bool setAttribute( const std::string& attributeName, diff --git a/Database/APR/PersistencySvc/src/TokenIterator.cpp b/Database/APR/PersistencySvc/src/TokenIterator.cpp index 436280494629..4bcf16ea7ba6 100644 --- a/Database/APR/PersistencySvc/src/TokenIterator.cpp +++ b/Database/APR/PersistencySvc/src/TokenIterator.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "TokenIterator.h" @@ -10,7 +10,7 @@ #include "PersistencySvc/PersistencySvcException.h" -pool::PersistencySvc::TokenIterator::TokenIterator( const FileDescriptor& fileDescriptor, +pool::PersistencySvc::TokenIterator::TokenIterator( FileDescriptor& fileDescriptor, const std::string& containerName, IStorageExplorer& storageExplorer, const std::string& selection ): diff --git a/Database/APR/PersistencySvc/src/TokenIterator.h b/Database/APR/PersistencySvc/src/TokenIterator.h index ca79c288d2d4..e1724746a36d 100644 --- a/Database/APR/PersistencySvc/src/TokenIterator.h +++ b/Database/APR/PersistencySvc/src/TokenIterator.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef PERSISTENCYSVC_TOKENITERATOR_H @@ -33,7 +33,7 @@ namespace pool { /** Constructor taking as argument a DbSelection object, * the file descriptor, the container name and the selection string */ - TokenIterator( const FileDescriptor& fileDescriptor, + TokenIterator( FileDescriptor& fileDescriptor, const std::string& containerName, IStorageExplorer& storageExplorer, const std::string& selection ); -- GitLab From 1435a6754d869adf7c3d229c36b454a3102de4d8 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Fri, 22 Nov 2019 21:59:08 -0500 Subject: [PATCH 3/3] RootStorageSvc: Thread-safety checker fixes. Adjust for interface changes in StorageSvc to fix thread-safety checker warnings. --- Database/APR/RootStorageSvc/src/RootDatabase.cpp | 2 +- Database/APR/RootStorageSvc/src/RootDatabase.h | 2 +- Database/APR/RootStorageSvc/src/RootKeyContainer.cpp | 2 +- Database/APR/RootStorageSvc/src/RootKeyContainer.h | 2 +- Database/APR/RootStorageSvc/src/RootTreeContainer.cpp | 8 ++++---- Database/APR/RootStorageSvc/src/RootTreeContainer.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Database/APR/RootStorageSvc/src/RootDatabase.cpp b/Database/APR/RootStorageSvc/src/RootDatabase.cpp index ff3a54964a44..e70034f4c391 100644 --- a/Database/APR/RootStorageSvc/src/RootDatabase.cpp +++ b/Database/APR/RootStorageSvc/src/RootDatabase.cpp @@ -70,7 +70,7 @@ long long int RootDatabase::size() const { } /// Callback after successful open of a database object -DbStatus RootDatabase::onOpen(const DbDatabase& dbH, DbAccessMode mode) { +DbStatus RootDatabase::onOpen(DbDatabase& dbH, DbAccessMode mode) { std::string par_val; DbPrint log("RootDatabase.onOpen"); if ( !dbH.param("FORMAT_VSN", par_val).isSuccess() ) { diff --git a/Database/APR/RootStorageSvc/src/RootDatabase.h b/Database/APR/RootStorageSvc/src/RootDatabase.h index a93b04e93ec8..07b7517a4aa9 100644 --- a/Database/APR/RootStorageSvc/src/RootDatabase.h +++ b/Database/APR/RootStorageSvc/src/RootDatabase.h @@ -165,7 +165,7 @@ namespace pool { * * @return DbStatus code indicating success or failure. */ - virtual DbStatus onOpen(const DbDatabase& dbH, DbAccessMode mode); + virtual DbStatus onOpen(DbDatabase& dbH, DbAccessMode mode); /// Close database access /** @param mode [IN] Desired session access mode. diff --git a/Database/APR/RootStorageSvc/src/RootKeyContainer.cpp b/Database/APR/RootStorageSvc/src/RootKeyContainer.cpp index e19fa699bc43..85db148eb429 100755 --- a/Database/APR/RootStorageSvc/src/RootKeyContainer.cpp +++ b/Database/APR/RootStorageSvc/src/RootKeyContainer.cpp @@ -330,7 +330,7 @@ DbStatus RootKeyContainer::close() { return DbContainerImp::close(); } -DbStatus RootKeyContainer::open(const DbDatabase& dbH, +DbStatus RootKeyContainer::open(DbDatabase& dbH, const std::string& dir_nam, const DbTypeInfo* /* info */, DbAccessMode mode) diff --git a/Database/APR/RootStorageSvc/src/RootKeyContainer.h b/Database/APR/RootStorageSvc/src/RootKeyContainer.h index 1c61647ccd0c..a7fe84e742ed 100755 --- a/Database/APR/RootStorageSvc/src/RootKeyContainer.h +++ b/Database/APR/RootStorageSvc/src/RootKeyContainer.h @@ -69,7 +69,7 @@ namespace pool { /// Close the container and deallocate resources virtual DbStatus close(); /// Open the container for object access - virtual DbStatus open(const DbDatabase& dbH, + virtual DbStatus open(DbDatabase& dbH, const std::string& nam, const DbTypeInfo* info, DbAccessMode mod); diff --git a/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp b/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp index 65c5a3a6898e..9f9eed8b16e0 100755 --- a/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp +++ b/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp @@ -506,10 +506,10 @@ DbStatus RootTreeContainer::close() { } -DbStatus RootTreeContainer::open( const DbDatabase& dbH, - const std::string& nam, - const DbTypeInfo* info, - DbAccessMode mode) +DbStatus RootTreeContainer::open( DbDatabase& dbH, + const std::string& nam, + const DbTypeInfo* info, + DbAccessMode mode) { DbPrint log(nam); m_branches.clear(); diff --git a/Database/APR/RootStorageSvc/src/RootTreeContainer.h b/Database/APR/RootStorageSvc/src/RootTreeContainer.h index 5f25ac66c054..1dd8e1ba336f 100755 --- a/Database/APR/RootStorageSvc/src/RootTreeContainer.h +++ b/Database/APR/RootStorageSvc/src/RootTreeContainer.h @@ -196,7 +196,7 @@ namespace pool { virtual DbStatus close(); /// Open the container for object access - virtual DbStatus open(const DbDatabase& dbH, + virtual DbStatus open(DbDatabase& dbH, const std::string& nam, const DbTypeInfo* info, DbAccessMode mod); -- GitLab