diff --git a/Database/APR/CollectionBase/CMakeLists.txt b/Database/APR/CollectionBase/CMakeLists.txt index fc861d1f9f4a5e34c6ea1864bae743a7a45c4a98..346d4cd3e1aaa3677608e0fc91c05a669c11c60d 100644 --- a/Database/APR/CollectionBase/CMakeLists.txt +++ b/Database/APR/CollectionBase/CMakeLists.txt @@ -12,7 +12,7 @@ atlas_add_library( CollectionBase src/*.cpp PUBLIC_HEADERS CollectionBase INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} FileCatalog + LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} FileCatalog CxxUtils PRIVATE_LINK_LIBRARIES POOLCore PersistentDataModel ) atlas_add_dictionary( CollectionDict diff --git a/Database/APR/CollectionBase/CollectionBase/ATLAS_CHECK_THREAD_SAFETY b/Database/APR/CollectionBase/CollectionBase/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..51c5d7f4f8a73de80eb350f76d93e4f29d78681c --- /dev/null +++ b/Database/APR/CollectionBase/CollectionBase/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +Database/APR/CollectionBase diff --git a/Database/APR/CollectionBase/CollectionBase/CollectionDescription.h b/Database/APR/CollectionBase/CollectionBase/CollectionDescription.h index 6ea5ed57953fbcfa17db518922ece96be2ad4324..47ad8118aa8266e4fd45d09eca0c74568aefbae8 100755 --- a/Database/APR/CollectionBase/CollectionBase/CollectionDescription.h +++ b/Database/APR/CollectionBase/CollectionBase/CollectionDescription.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef COLLECTIONBASE_COLLECTIONDESCRIPTION_H @@ -573,13 +573,16 @@ namespace pool { // check if the column contains tokens virtual bool isTokenColumn( const std::string& columnName, const std::string& method ) const; - // this version includes the 'mothod name' in the error message - virtual pool::CollectionColumn* column( const std::string& columnName, const std::string& methodName ) const; + // this version includes the 'method name' in the error message + virtual pool::CollectionColumn* column( const std::string& columnName, const std::string& methodName ); + virtual const pool::CollectionColumn* column( const std::string& columnName, const std::string& methodName ) const; // returns non-const fragment pointer - virtual pool::CollectionFragment* collectionFragment( int fragmentId, const std::string& method ) const; + virtual pool::CollectionFragment* collectionFragment( int fragmentId, const std::string& method ); + virtual const pool::CollectionFragment* collectionFragment( int fragmentId, const std::string& method ) const; // returns non-const fragment pointer - virtual pool::CollectionFragment* collectionFragment( const std::string& fragmentName, const std::string& method ) const; + virtual pool::CollectionFragment* collectionFragment( const std::string& fragmentName, const std::string& method ); + virtual const pool::CollectionFragment* collectionFragment( const std::string& fragmentName, const std::string& method ) const; public: /// print out the description (debugging) diff --git a/Database/APR/CollectionBase/CollectionBase/CollectionFactory.h b/Database/APR/CollectionBase/CollectionBase/CollectionFactory.h index 3c77051ffebe5ee65a4e65f6f38808cec70c49d3..3adbcc2f53d72a7c24fdc3a321413a04cb49da82 100755 --- a/Database/APR/CollectionBase/CollectionBase/CollectionFactory.h +++ b/Database/APR/CollectionBase/CollectionBase/CollectionFactory.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef COLLECTIONBASE_COLLECTIONFACTORY_H @@ -8,6 +8,7 @@ #include "CollectionBase/ICollection.h" #include "CollectionBase/CollectionDescription.h" #include "FileCatalog/IFileCatalog.h" +#include "CxxUtils/checker_macros.h" #include <string> #include <vector> @@ -27,7 +28,8 @@ namespace pool { * collection fragments, the latter of which contain a subset of the metadata of a * full collection. */ - class CollectionFactory + class ATLAS_NOT_THREAD_SAFE CollectionFactory + // not thread-safe due to constness violations wrt the catalog. { public: /// Retrieves the collection factory singleton. diff --git a/Database/APR/CollectionBase/CollectionBase/CollectionRowBuffer.h b/Database/APR/CollectionBase/CollectionBase/CollectionRowBuffer.h index 9dc1bf61ac5a611be15592c3527e388d364ff91e..38320ada3607d4cc0a7069fe302e767e9d87833b 100755 --- a/Database/APR/CollectionBase/CollectionBase/CollectionRowBuffer.h +++ b/Database/APR/CollectionBase/CollectionBase/CollectionRowBuffer.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef COLLECTIONBASE_COLLECTIONROWBUFFER_H @@ -8,6 +8,7 @@ #include "CollectionBase/TokenList.h" #include "CoralBase/AttributeList.h" +#include "CxxUtils/checker_macros.h" #include <string> @@ -102,7 +103,12 @@ namespace pool { TokenList m_tokenList; /// List of Attributes. - coral::AttributeList m_attributeList; + // Changed to a pointed to be able to avoid thread-safety checker + // warnings about AttributeList. We can change back to holding + // this by value once those warnings are removed. + coral::AttributeList* m_attributeList; + + bool deleteAL ATLAS_NOT_THREAD_SAFE (); }; } diff --git a/Database/APR/CollectionBase/CollectionBase/CollectionService.h b/Database/APR/CollectionBase/CollectionBase/CollectionService.h index bee57353970a01c9c92db8873de8cae6d97f2f60..4800f1a4d1e7c93317ed0cbfd6d3ae1e78e4f622 100755 --- a/Database/APR/CollectionBase/CollectionBase/CollectionService.h +++ b/Database/APR/CollectionBase/CollectionBase/CollectionService.h @@ -1,11 +1,12 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef COLLECTIONBASE_COLLECTIONSERVICE_H #define COLLECTIONBASE_COLLECTIONSERVICE_H #include "CollectionBase/ICollectionService.h" +#include "CxxUtils/checker_macros.h" namespace pool { @@ -21,7 +22,7 @@ namespace pool { * of the metadata of an existing collection. Note that a class that inherits from this * interface must also inherit from the SEAL Service base class. */ - class CollectionService : virtual public ICollectionService + class ATLAS_NOT_THREAD_SAFE CollectionService : virtual public ICollectionService { // DECLARE_SEAL_COMPONENT; diff --git a/Database/APR/CollectionBase/CollectionBase/ICollectionMetadata.h b/Database/APR/CollectionBase/CollectionBase/ICollectionMetadata.h index d78254187815c0c2a0f50531fb9a50d865705b87..7f5b8667cdbd8d6f69c17196cb3f6506c1d97a65 100644 --- a/Database/APR/CollectionBase/CollectionBase/ICollectionMetadata.h +++ b/Database/APR/CollectionBase/CollectionBase/ICollectionMetadata.h @@ -1,11 +1,12 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef ICollectionMetadata_h #define ICollectionMetadata_h #include <string> +#include <memory> namespace pool { @@ -35,25 +36,11 @@ namespace pool { const std::string& key() const { return m_iterator->key(); } const char * value() const { return m_iterator->value(); } - ~const_iterator() { delete m_iterator; } - - const_iterator( ICollectionMetadataIterator* iter ) - : m_iterator( iter ) {} - - const_iterator& operator=( const const_iterator& rhs ) { - m_iterator = rhs.releaseIter(); - return *this; - } - - protected: - ICollectionMetadataIterator* releaseIter() const { - ICollectionMetadataIterator *iter = m_iterator; - m_iterator = 0; - return iter; - } - + const_iterator( std::unique_ptr<ICollectionMetadataIterator> iter ) + : m_iterator( std::move(iter) ) {} - mutable ICollectionMetadataIterator* m_iterator; + private: + std::unique_ptr<ICollectionMetadataIterator> m_iterator; }; diff --git a/Database/APR/CollectionBase/CollectionBase/ICollectionService.h b/Database/APR/CollectionBase/CollectionBase/ICollectionService.h index 4d542886c352ddd39f27e40b3f6bd46f2cd8e3d6..025742afce303d581bb0d0f1cd94657a62841b73 100755 --- a/Database/APR/CollectionBase/CollectionBase/ICollectionService.h +++ b/Database/APR/CollectionBase/CollectionBase/ICollectionService.h @@ -1,11 +1,12 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef COLLECTIONBASE_ICOLLECTIONSERVICE_H #define COLLECTIONBASE_ICOLLECTIONSERVICE_H #include "CollectionBase/ICollection.h" +#include "CxxUtils/checker_macros.h" #include <string> #include <vector> @@ -29,7 +30,7 @@ namespace pool { * Note that a class that inherits from this interface must also inherit from the SEAL * Service base class. */ - class ICollectionService + class ATLAS_NOT_THREAD_SAFE ICollectionService { public: /** diff --git a/Database/APR/CollectionBase/src/CollectionDescription.cpp b/Database/APR/CollectionBase/src/CollectionDescription.cpp index fa90e718772851db3ad8738f9290f3be33a2a063..b9e9902a8cf0c74626c949ced96b54ebbd5f7559 100755 --- a/Database/APR/CollectionBase/src/CollectionDescription.cpp +++ b/Database/APR/CollectionBase/src/CollectionDescription.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "CollectionBase/CollectionDescription.h" @@ -1450,7 +1450,7 @@ pool::CollectionDescription::numberOfColumns( std::string fragmentName ) const if( !fragmentName.size() ) { return m_attributeColumnForColumnName.size() + m_tokenColumnForColumnName.size(); } - CollectionFragment* fragment = collectionFragment( fragmentName, "numberOfColumns" ); + const CollectionFragment* fragment = collectionFragment( fragmentName, "numberOfColumns" ); return fragment->attributeColumns().size() + fragment->tokenColumns().size(); } @@ -1481,7 +1481,7 @@ pool::CollectionDescription::columnPtr( const std::string& name ) const // internal use protected method (when non-const column is needed). throws exceptions pool::CollectionColumn * -pool::CollectionDescription::column( const std::string& name, const std::string& method ) const +pool::CollectionDescription::column( const std::string& name, const std::string& method ) { std::map< std::string, pool::CollectionColumn* >::const_iterator iColumn; iColumn = m_attributeColumnForColumnName.find( name ); @@ -1497,6 +1497,22 @@ pool::CollectionDescription::column( const std::string& name, const std::string& +const pool::CollectionColumn * +pool::CollectionDescription::column( const std::string& name, const std::string& method ) const +{ + std::map< std::string, pool::CollectionColumn* >::const_iterator iColumn; + iColumn = m_attributeColumnForColumnName.find( name ); + if( iColumn == m_attributeColumnForColumnName.end() ) { + iColumn = m_tokenColumnForColumnName.find( name ); + if( iColumn == m_tokenColumnForColumnName.end() ) { + std::string errorMsg = "Column with name `" + name + "' does NOT exist."; + throw pool::Exception(errorMsg, "CollectionDescription::" + method, "CollectionBase"); + } + } + return iColumn->second; +} + + int pool::CollectionDescription::numberOfTokenColumns( std::string fragmentName ) const { @@ -1609,7 +1625,7 @@ pool::CollectionDescription::attributeColumn( const std::string& columnName ) co const pool::ICollectionColumn& pool::CollectionDescription::attributeColumn( int columnId, int fragmentId ) const { - CollectionFragment* fragment = collectionFragment( fragmentId, "attributeColumn" ); + const CollectionFragment* fragment = collectionFragment( fragmentId, "attributeColumn" ); std::vector< pool::CollectionColumn* > columns = fragment->attributeColumns(); if( columnId >= 0 && columnId < (int) columns.size() ) { @@ -1630,7 +1646,7 @@ pool::CollectionDescription::attributeColumn( int columnId, int fragmentId ) con const pool::ICollectionColumn& pool::CollectionDescription::attributeColumn( int columnId, const std::string& fragmentName ) const { - CollectionFragment* fragment = collectionFragment( fragmentName, "attributeColumn" ); + const CollectionFragment* fragment = collectionFragment( fragmentName, "attributeColumn" ); std::vector< pool::CollectionColumn* > columns = fragment->attributeColumns(); if( columnId >= 0 && columnId < (int)columns.size() ) { return *( columns[ columnId ] ); @@ -1777,6 +1793,22 @@ pool::CollectionDescription::collectionFragment( const std::string& fragmentName pool::CollectionFragment * +pool::CollectionDescription::collectionFragment( const std::string& fragmentName, const std::string& method ) +{ + std::map< std::string, pool::CollectionFragment* >::const_iterator iFragment = + m_fragmentForFragmentName.find( fragmentName ); + + if( iFragment == m_fragmentForFragmentName.end() ) { + std::string errorMsg = "Collection fragment `" + fragmentName + "' NOT found."; + throw pool::Exception( errorMsg, + "CollectionDescription::" + method, + "CollectionBase" ); + } + return iFragment->second; +} + + +const pool::CollectionFragment * pool::CollectionDescription::collectionFragment( const std::string& fragmentName, const std::string& method ) const { std::map< std::string, pool::CollectionFragment* >::const_iterator iFragment = @@ -1800,6 +1832,24 @@ pool::CollectionDescription::collectionFragment( int fragmentId ) const pool::CollectionFragment * +pool::CollectionDescription::collectionFragment( int fragmentId, const std::string& method ) +{ + std::map< int, pool::CollectionFragment* >::const_iterator iFragment = m_fragmentForFragmentId.find( fragmentId ); + + if ( iFragment == m_fragmentForFragmentId.end() ) + { + std::string errorMsg = "Not using a collection fragment with ID " + std::to_string(fragmentId); + throw pool::Exception( errorMsg, + "CollectionDescription::" + method, + "CollectionBase" ); + } + + return iFragment->second; +} + + + +const pool::CollectionFragment * pool::CollectionDescription::collectionFragment( int fragmentId, const std::string& method ) const { std::map< int, pool::CollectionFragment* >::const_iterator iFragment = m_fragmentForFragmentId.find( fragmentId ); diff --git a/Database/APR/CollectionBase/src/CollectionFactory.cpp b/Database/APR/CollectionBase/src/CollectionFactory.cpp index 803958d8deaaf111a5ff1f0a6d64fe92091e97d5..29de465160de9195c60d968731b9388e1aed5894 100755 --- a/Database/APR/CollectionBase/src/CollectionFactory.cpp +++ b/Database/APR/CollectionBase/src/CollectionFactory.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "CollectionBase/CollectionFactory.h" @@ -24,7 +24,7 @@ using namespace std; using namespace pool; pool::CollectionFactory pool::CollectionFactory::s_instance; -static string thisModule( "POOLCollFactory" ); +static const string thisModule( "POOLCollFactory" ); const std::string pool::CollectionFactory::c_fileType = "PoolCollection"; diff --git a/Database/APR/CollectionBase/src/CollectionRowBuffer.cpp b/Database/APR/CollectionBase/src/CollectionRowBuffer.cpp index 459879a031aa60e49f8a00fe51dd1811bd5b6e4d..143b19bd7c9a280a24dccab0f86ecddcfba4658c 100755 --- a/Database/APR/CollectionBase/src/CollectionRowBuffer.cpp +++ b/Database/APR/CollectionBase/src/CollectionRowBuffer.cpp @@ -1,44 +1,53 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "CollectionBase/CollectionRowBuffer.h" - pool::CollectionRowBuffer::CollectionRowBuffer() : m_tokenList(), - m_attributeList() + m_attributeList (new coral::AttributeList) {} pool::CollectionRowBuffer::CollectionRowBuffer( const pool::TokenList& tokenList, coral::AttributeList& attributeList ) - : m_tokenList( tokenList ) - //m_attributeList( attributeList ) + : m_tokenList( tokenList ), + m_attributeList( new coral::AttributeList ) { // share data - m_attributeList.merge( attributeList ); + m_attributeList->merge( attributeList ); } pool::CollectionRowBuffer::CollectionRowBuffer( const pool::CollectionRowBuffer& rhs ) - : m_tokenList( rhs.m_tokenList ) - // m_attributeList( rhs.m_attributeList ) + : m_tokenList( rhs.m_tokenList ), + m_attributeList( new coral::AttributeList ) { // share the data - m_attributeList.merge( rhs.m_attributeList ); + m_attributeList->merge( *rhs.m_attributeList ); +} + + +bool pool::CollectionRowBuffer::deleteAL ATLAS_NOT_THREAD_SAFE() +{ + delete m_attributeList; + m_attributeList = nullptr; + return true; } pool::CollectionRowBuffer::~CollectionRowBuffer() -{} +{ + [[maybe_unused]] bool flag ATLAS_THREAD_SAFE = deleteAL(); +} pool::CollectionRowBuffer& pool::CollectionRowBuffer::operator=( const pool::CollectionRowBuffer& rhs ) { m_tokenList = rhs.m_tokenList; - m_attributeList = rhs.m_attributeList; + *m_attributeList = *rhs.m_attributeList; return *this; } @@ -47,7 +56,7 @@ pool::CollectionRowBuffer::operator=( const pool::CollectionRowBuffer& rhs ) bool pool::CollectionRowBuffer::operator==( const pool::CollectionRowBuffer& rhs ) const { - if ( ( m_tokenList != rhs.m_tokenList ) || ( m_attributeList != rhs.m_attributeList ) ) + if ( ( m_tokenList != rhs.m_tokenList ) || ( *m_attributeList != *rhs.m_attributeList ) ) { return false; } @@ -73,7 +82,7 @@ pool::CollectionRowBuffer::setTokenList( const pool::TokenList& tokenList ) void pool::CollectionRowBuffer::setAttributeList( const coral::AttributeList& attributeList ) { - m_attributeList = attributeList; + *m_attributeList = attributeList; } @@ -87,7 +96,7 @@ pool::CollectionRowBuffer::tokenList() coral::AttributeList& pool::CollectionRowBuffer::attributeList() { - return m_attributeList; + return *m_attributeList; } @@ -101,6 +110,6 @@ pool::CollectionRowBuffer::tokenList() const const coral::AttributeList& pool::CollectionRowBuffer::attributeList() const { - return m_attributeList; + return *m_attributeList; } diff --git a/Database/APR/CollectionBase/src/TokenList.cpp b/Database/APR/CollectionBase/src/TokenList.cpp index 093858682129bee6888af15c9af646b8a0d15a70..17b8cf9a4727140cda03d54931ba3247d4c6065a 100755 --- a/Database/APR/CollectionBase/src/TokenList.cpp +++ b/Database/APR/CollectionBase/src/TokenList.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "CollectionBase/TokenList.h" @@ -99,14 +99,29 @@ pool::TokenList::extend( const std::string& name ) Token& pool::TokenList::operator[]( const std::string& name ) { - return const_cast<Token&>( ((const TokenList&)*this)[name] ); + std::map< std::string, Token* >::iterator iData = m_tokenMap.find( name ); + + if( iData == m_tokenMap.end() ) { + std::string errorMsg = "Cannot find Token with name `" + name + "' in Token list."; + throw pool::Exception( errorMsg, + "TokenList::operator[](name)", + "CollectionBase" ); + } + return *( iData->second ); } Token& pool::TokenList::operator[]( unsigned int index ) { - return const_cast<Token&>( ((const TokenList&)*this)[index] ); + if( index >= m_tokenVector.size() ) { + std::ostringstream errorMsg; + errorMsg << "Cannot find Token with index `" << index << "' in Token list."; + throw pool::Exception( errorMsg.str(), + "TokenList::operator[](index)", + "CollectionBase" ); + } + return *m_tokenVector[index]; } diff --git a/Database/APR/CollectionBase/test/Factory_test.cxx b/Database/APR/CollectionBase/test/Factory_test.cxx index 6d389082da3af0880606002bc22cfffe6f1fb832..8bdaa1bbd61bf67f885a376b1a5b64c385af261b 100644 --- a/Database/APR/CollectionBase/test/Factory_test.cxx +++ b/Database/APR/CollectionBase/test/Factory_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include <cstdio> // For sprintf on gcc45 @@ -15,6 +15,10 @@ #include "CollectionBase/ICollection.h" #include "CollectionBase/CollectionDescription.h" #include "CollectionBase/CollectionFactory.h" +#include "CxxUtils/checker_macros.h" + + +ATLAS_NO_CHECK_FILE_THREAD_SAFETY; using namespace std; diff --git a/Database/APR/ImplicitCollection/src/ImplicitCollectionMetadata.h b/Database/APR/ImplicitCollection/src/ImplicitCollectionMetadata.h index d15bd4ac5d0d7f601cd56a997b64d3cfd21a05fd..ca69348a4e05b4cb7e188fbd04dca0e0bbef45f1 100644 --- a/Database/APR/ImplicitCollection/src/ImplicitCollectionMetadata.h +++ b/Database/APR/ImplicitCollection/src/ImplicitCollectionMetadata.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef ImplicitCollectionMetadata_h @@ -51,6 +51,7 @@ namespace pool { class ImplicitCollectionMetadataIterator : public ICollectionMetadata::ICollectionMetadataIterator { + public: friend class ImplicitCollectionMetadata; ImplicitCollectionMetadataIterator() {} @@ -74,12 +75,12 @@ namespace pool { ICollectionMetadata::const_iterator begin() const { - return ICollectionMetadata::const_iterator( new ImplicitCollectionMetadataIterator() ); + return ICollectionMetadata::const_iterator( std::make_unique<ImplicitCollectionMetadataIterator>() ); } ICollectionMetadata::const_iterator end() const { - return ICollectionMetadata::const_iterator( new ImplicitCollectionMetadataIterator() ); + return ICollectionMetadata::const_iterator( std::make_unique<ImplicitCollectionMetadataIterator>() ); } }; // end ImplicitCollectionMetadata diff --git a/Database/APR/RelationalCollection/src/RelationalCollectionMetadata.cpp b/Database/APR/RelationalCollection/src/RelationalCollectionMetadata.cpp index b9a506a2930bcf9194a0955087d7408b948a28c6..488bdbd32a166b5477f76862a68b0a575e02facd 100644 --- a/Database/APR/RelationalCollection/src/RelationalCollectionMetadata.cpp +++ b/Database/APR/RelationalCollection/src/RelationalCollectionMetadata.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "RelationalCollectionMetadata.h" @@ -334,7 +334,7 @@ namespace pool { query->setCondition( RelationalCollectionBindVariables::whereClauseForMetadata(), m_whereDataForMetadata ); return ICollectionMetadata::const_iterator( - new RelationalCollectionMetadataIterator( this, query.release(), + std::make_unique<RelationalCollectionMetadataIterator>( this, query.release(), entries() < 10000? &m_keyInfo : 0 ) ); } @@ -343,7 +343,7 @@ namespace pool { RelationalCollectionMetadata::end() const { return ICollectionMetadata::const_iterator( - new RelationalCollectionMetadataIterator( 0, 0, 0 ) ); + std::make_unique<RelationalCollectionMetadataIterator>( nullptr, nullptr, nullptr ) ); } diff --git a/Database/APR/RelationalCollection/src/RelationalCollectionMetadata.h b/Database/APR/RelationalCollection/src/RelationalCollectionMetadata.h index 2194c1230ae1f59e1a56b455b9c4a94fccd6340f..6aa064fa6e8859dbb16d6e7dc40869b347e48572 100644 --- a/Database/APR/RelationalCollection/src/RelationalCollectionMetadata.h +++ b/Database/APR/RelationalCollection/src/RelationalCollectionMetadata.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef RelationalCollectionMetadata_h @@ -58,6 +58,7 @@ namespace pool { class RelationalCollectionMetadataIterator : public ICollectionMetadata::ICollectionMetadataIterator { + public: friend class RelationalCollectionMetadata; RelationalCollectionMetadataIterator( const RelationalCollectionMetadata* meta, diff --git a/Database/APR/RootCollection/src/RootCollectionMetadata.cpp b/Database/APR/RootCollection/src/RootCollectionMetadata.cpp index 016ec419de80cdc7197b1613c2dd2cb816a31777..1da914ab43b3e27dad3908d6dbc549761c88f9ed 100644 --- a/Database/APR/RootCollection/src/RootCollectionMetadata.cpp +++ b/Database/APR/RootCollection/src/RootCollectionMetadata.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "RootCollectionMetadata.h" @@ -232,7 +232,7 @@ namespace pool { if( !m_hasKeys ) readKeys(); return ICollectionMetadata::const_iterator( - new RootCollectionMetadataIterator( m_keyMap.begin(), this ) ); + std::make_unique<RootCollectionMetadataIterator>( m_keyMap.begin(), this ) ); } @@ -243,7 +243,7 @@ namespace pool { if( !m_hasKeys ) // check also here, in case End is evaluated before Begin readKeys(); return ICollectionMetadata::const_iterator( - new RootCollectionMetadataIterator( m_keyMap.end(), this ) ); + std::make_unique<RootCollectionMetadataIterator>( m_keyMap.end(), this ) ); } } // end namespace diff --git a/Database/APR/RootCollection/src/RootCollectionMetadata.h b/Database/APR/RootCollection/src/RootCollectionMetadata.h index 473524a4d3da1e178edc9ec20cf71fdb4732dad3..0a128659cdcd90c7ff695beccb78d1b131eff26e 100644 --- a/Database/APR/RootCollection/src/RootCollectionMetadata.h +++ b/Database/APR/RootCollection/src/RootCollectionMetadata.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef RootCollectionMetadata_h @@ -55,6 +55,7 @@ namespace pool { class RootCollectionMetadataIterator : public ICollectionMetadata::ICollectionMetadataIterator { + public: friend class RootCollectionMetadata; RootCollectionMetadataIterator( const MetadataKeyMap_t::const_iterator& iter, diff --git a/Database/AthenaPOOL/PoolSvc/CMakeLists.txt b/Database/AthenaPOOL/PoolSvc/CMakeLists.txt index 140900a73ad9a93da028be034ad043af4d78b99c..3dd1d70b2a5b33f558f8ba72a42e44aefcbe84d5 100644 --- a/Database/AthenaPOOL/PoolSvc/CMakeLists.txt +++ b/Database/AthenaPOOL/PoolSvc/CMakeLists.txt @@ -10,7 +10,7 @@ find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) atlas_add_library( PoolSvcLib INTERFACE PUBLIC_HEADERS PoolSvc - LINK_LIBRARIES GaudiKernel CollectionBase PersistencySvc DataModelRoot ) + LINK_LIBRARIES GaudiKernel CollectionBase PersistencySvc DataModelRoot CxxUtils ) # Component(s) in the package: atlas_add_component( PoolSvc diff --git a/Database/AthenaPOOL/PoolSvc/PoolSvc/IPoolSvc.h b/Database/AthenaPOOL/PoolSvc/PoolSvc/IPoolSvc.h index ae024f6888657e6b569b974ab58a66181f1b9427..477f74db55115b4cf8e59c7842a99fde51fab068 100644 --- a/Database/AthenaPOOL/PoolSvc/PoolSvc/IPoolSvc.h +++ b/Database/AthenaPOOL/PoolSvc/PoolSvc/IPoolSvc.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef POOLSVC_IPOOLSVC_H @@ -14,6 +14,7 @@ #include "CollectionBase/ICollection.h" #include "PersistencySvc/ITransaction.h" #include "DataModelRoot/RootType.h" +#include "CxxUtils/checker_macros.h" #include <string> @@ -92,7 +93,8 @@ public: // Non-static members /// @param collectionName [IN] string containing the persistent name of the collection. /// @param openMode [IN] ICollection open mode of the collection. /// @param contextId [IN] id for PoolSvc persistency service to use for input. - virtual pool::ICollection* createCollection(const std::string& collectionType, + virtual pool::ICollection* createCollection ATLAS_NOT_THREAD_SAFE + (const std::string& collectionType, const std::string& connection, const std::string& collectionName, const pool::ICollection::OpenMode& openMode = pool::ICollection::READ, @@ -102,7 +104,7 @@ public: // Non-static members /// @param c [IN] collection to be registered /// @param overwrite [IN] whether to overwrite /// @param sharedCat [IN] whether to use same catalog as data - virtual void registerExistingCollection(pool::ICollection* c, bool overwrite, bool sharedCat = true) = 0; + virtual void registerExistingCollection ATLAS_NOT_THREAD_SAFE (pool::ICollection* c, bool overwrite, bool sharedCat = true) = 0; /// @return a token for a container entry. /// @param connection [IN] string containing the connection/file name. diff --git a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx index 4ccd4b01123d3422a3c5220178af77b763c32ad6..e525cb142b89a68aebbef52ada8ee94c0ee7d661 100644 --- a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx +++ b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx @@ -426,7 +426,8 @@ void PoolSvc::renamePfn(const std::string& pf, const std::string& newpf) const { m_catalog->renamePFN(pf, newpf); } //__________________________________________________________________________ -pool::ICollection* PoolSvc::createCollection(const std::string& collectionType, +pool::ICollection* PoolSvc::createCollection ATLAS_NOT_THREAD_SAFE + (const std::string& collectionType, const std::string& connection, const std::string& collectionName, const pool::ICollection::OpenMode& openMode, @@ -531,7 +532,9 @@ pool::ICollection* PoolSvc::createCollection(const std::string& collectionType, return(collPtr); } //__________________________________________________________________________ -void PoolSvc::registerExistingCollection(pool::ICollection* coll, bool overwrite, bool sharedCat) { +void PoolSvc::registerExistingCollection ATLAS_NOT_THREAD_SAFE + (pool::ICollection* coll, bool overwrite, bool sharedCat) +{ std::lock_guard<CallMutex> lock(m_pool_mut); m_catalog->commit(); pool::CollectionFactory* collFac = pool::CollectionFactory::get(); diff --git a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.h b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.h index ff7e581c9d1f4a550e4a1c155bc2cb15f16b814e..aad4e1a7e14c61c04af4023cd2430867ae071651 100644 --- a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.h +++ b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.h @@ -98,7 +98,8 @@ public: // Non-static members /// @param collectionName [IN] string containing the persistent name of the collection. /// @param openMode [IN] ICollection open mode of the collection. /// @param contextId [IN] id for PoolSvc persistency service to use for input. - pool::ICollection* createCollection(const std::string& collectionType, + pool::ICollection* createCollection ATLAS_NOT_THREAD_SAFE + (const std::string& collectionType, const std::string& connection, const std::string& collectionName, const pool::ICollection::OpenMode& openMode = pool::ICollection::READ, @@ -108,7 +109,7 @@ public: // Non-static members /// @param c [IN] collection to be registered /// @param overwrite [IN] whether to overwrite /// @param sharedCat [IN] whether to use same catalog as data - void registerExistingCollection(pool::ICollection* c, bool overwrite, bool sharedCat = true); + void registerExistingCollection ATLAS_NOT_THREAD_SAFE (pool::ICollection* c, bool overwrite, bool sharedCat = true); /// @return a token for a container entry. /// @param connection [IN] string containing the connection/file name.