diff --git a/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx b/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx index d221181fcb0858b0d492669662ee5fb1e188438b..98d7bc24794ff846db9f5827662ba2d488946cea 100644 --- a/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx +++ b/Event/xAOD/xAODMetaData/Root/FileMetaData_v1.cxx @@ -9,6 +9,7 @@ // Core include(s): #include "AthContainers/AuxTypeRegistry.h" #include "AthContainers/normalizedTypeinfoName.h" +#include "AthContainers/ConstAccessor.h" // Local include(s): #include "xAODMetaData/versions/FileMetaData_v1.h" @@ -76,8 +77,9 @@ namespace xAOD { if( *ti == typeid( std::string ) ) { // Retrieve the values: - const std::string& value1 = this->auxdata< std::string >( name ); - const std::string& value2 = rhs.auxdata< std::string >( name ); + SG::ConstAccessor< std::string >acc( name ); + const std::string& value1 = acc( *this ); + const std::string& value2 = acc( rhs ); // And simply compare them: if( value1 != value2 ) { return false; @@ -86,8 +88,9 @@ namespace xAOD { } else if( *ti == typeid( uint32_t ) ) { // Retrieve the values: - const uint32_t& value1 = this->auxdata< uint32_t >( name ); - const uint32_t& value2 = rhs.auxdata< uint32_t >( name ); + SG::ConstAccessor< uint32_t >acc( name ); + const uint32_t& value1 = acc( *this ); + const uint32_t& value2 = acc( rhs ); // And simply compare them: if( value1 != value2 ) { return false; @@ -96,8 +99,9 @@ namespace xAOD { } else if( *ti == typeid( float ) ) { // Retrieve the values: - const float& value1 = this->auxdata< float >( name ); - const float& value2 = rhs.auxdata< float >( name ); + SG::ConstAccessor< float >acc( name ); + const float& value1 = acc( *this ); + const float& value2 = acc( rhs ); // And (not so simply) compare them: if( std::abs( value1 - value2 ) > 0.001 ) { return false; @@ -106,18 +110,18 @@ namespace xAOD { } else if( *ti == typeid( char ) ) { // Retrieve the values: - const char& value1 = this->auxdata< char >( name ); - const char& value2 = rhs.auxdata< char >( name ); + SG::ConstAccessor< char >acc( name ); + const char& value1 = acc( *this ); + const char& value2 = acc( rhs ); // And (not so simply) compare them: if( value1 != value2 ) { return false; } } else if ( *ti == typeid( std::vector<uint32_t> ) ) { // One code to retrieve them - const std::vector<uint32_t>& value1 = - this->auxdata< std::vector<uint32_t> >(name); - const std::vector<uint32_t>& value2 = - rhs.auxdata< std::vector<uint32_t> >(name); + SG::ConstAccessor< std::vector<uint32_t> >acc( name ); + const std::vector<uint32_t>& value1 = acc( *this ); + const std::vector<uint32_t>& value2 = acc( rhs ); // and in simplicity compare them if( value1 != value2 ) { return false; diff --git a/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx b/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx index 55aab03c0b02468e42b715bac1e1f6a4343d3b28..03f0f131cfea87243e8e28c43e4b37965be2d5ac 100644 --- a/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx +++ b/Event/xAOD/xAODMetaData/test/ut_xaodmetadata_filemetadata_eq_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ /// @@ -16,6 +16,7 @@ // Local include(s): #include "xAODMetaData/FileMetaData.h" +#include "AthContainers/ConstAccessor.h" /// Helper macro for evaluating logical tests #define SIMPLE_ASSERT( EXP ) \ @@ -142,8 +143,9 @@ int main() { // the code complains about them. But still lets the equivalence stand. SIMPLE_ASSERT( meta2.setValue( "AnalysisValue", 1.2f ) == true ); SIMPLE_ASSERT( meta1 == meta2 ); - meta1.auxdata< int >( "IntValue" ) = 1; - meta2.auxdata< int >( "IntValue" ) = 2; + SG::Accessor< int >IntValue( "IntValue" ); + IntValue( meta1 ) = 1; + IntValue( meta2 ) = 2; SIMPLE_ASSERT( meta1 == meta2 ); // Tell the user that everything went successfully: