2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 /// @author Nils Krumnack
13 #include <AsgTools/MessageCheckAsgTools.h>
15 #ifdef XAOD_STANDALONE
16 #include <AsgTools/AsgComponent.h>
17 #include <AsgTools/TProperty.h>
21 // method implementations
26 #ifdef XAOD_STANDALONE
27 // This template specialization for `AsgComponent` contains most of
28 // the actual logic for creating/configuring components, allowing
29 // the templated version of the function to rely on this one.
30 template<> StatusCode AsgComponentConfig ::
31 makeComponentExpert<AsgComponent> (std::unique_ptr<AsgComponent>& component,
32 const std::string& newCommand,
33 bool nestedNames, std::string prefix) const;
37 template<typename T> StatusCode AsgComponentConfig ::
38 makeComponentExpert (std::unique_ptr<T>& component,
39 const std::string& newCommand,
40 bool nestedNames, std::string prefix) const
42 using namespace msgComponentConfig;
44 // for `AsgComponent` we have a non-templated implementation
45 std::unique_ptr<AsgComponent> baseComponent;
46 if (makeComponentExpert (baseComponent, newCommand, nestedNames, std::move (prefix)).isFailure())
47 return StatusCode::FAILURE;
49 // note: I delay releasing the baseComponent after I check the
50 // `dynamic_cast` succeeded, this way it is held temporarily by
51 // two smart pointers, but it simplifies the code.
52 component.reset (dynamic_cast<T*>(baseComponent.get()));
53 if (component == nullptr)
55 ANA_MSG_ERROR ("component " << type() << "/" << name() << " not of required type");
56 return StatusCode::FAILURE;
58 baseComponent.release();
60 return StatusCode::SUCCESS;
66 template<typename T> StatusCode AsgComponentConfig ::
67 setProperty (const std::string& name, const T& value)
69 using namespace asg::msgProperty;
70 std::string valueString;
72 #ifdef XAOD_STANDALONE
73 ANA_CHECK (asg::detail::GetCastStringHelper<T>::get (value, valueString));
75 valueString = Gaudi::Utils::toString (value);
78 setPropertyFromString (name, std::move (valueString));
79 return StatusCode::SUCCESS;