2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5#ifndef ASGTOOLS_PROPERTYMGR_ICC
6#define ASGTOOLS_PROPERTYMGR_ICC
12#include "AsgTools/TProperty.h"
13#include "AsgMessaging/MsgStreamMacros.h"
16Property* PropertyMgr::declareProperty( const std::string& name, T& loc ) {
18 // Create the property object:
19 Property* pprop = createProperty( loc );
22 ATH_MSG_DEBUG( "Declaring " << pprop->typeName() << " property: " << name );
23 m_props[ name ] = pprop;
25 // Return a pointer to it:
30StatusCode PropertyMgr::setProperty( const std::string& name, const T& rval ) {
32 // Look for the property:
33 PropMap_t::const_iterator iprop = m_props.find( name );
34 if( iprop == m_props.end() ) {
35 ATH_MSG_ERROR( "Property not found: " << name );
36 return StatusCode::FAILURE;
39 // Access the property object:
40 Property* pprop = iprop->second;
41 // Create a helper property object:
42 std::unique_ptr< Property > pinprop( createProperty( rval ) );
43 // Try setting the managed property using the helper property object:
44 if( pprop->setFrom( *pinprop ) ) {
45 ATH_MSG_ERROR( "Value assignment failed for " << name );
46 return StatusCode::FAILURE;
49 // We were successful:
50 return StatusCode::SUCCESS;
54StatusCode PropertyMgr::getProperty( const std::string& name,
57 // Look for the property:
58 PropMap_t::const_iterator iprop = m_props.find( name );
59 if( iprop == m_props.end() ) {
60 ATH_MSG_ERROR( "Property not found: " << name );
61 return StatusCode::FAILURE;
64 // Access the property object:
65 Property* pprop = iprop->second;
66 // Create a helper property object:
67 std::unique_ptr< Property > pretprop( createProperty( valout ) );
68 // Try retrieving the property using the helper property object:
69 if( pretprop->setFrom( *pprop ) ) {
70 ATH_MSG_ERROR( "Value retrieval failed for " << name );
71 return StatusCode::FAILURE;
74 // We were successful:
75 return StatusCode::SUCCESS;
78#endif // ASGTOOLS_PROPERTYMGR_ICC