9#ifndef ASG_TOOLS__PROPERTY_WRAPPER_H
10#define ASG_TOOLS__PROPERTY_WRAPPER_H
13#ifndef XAOD_STANDALONE
15#include <GaudiKernel/PropertyHolder.h>
37 template<
typename T>
class Property
final
41 Property (T2 *owner,
const std::string& name,
const T& value,
42 const std::string& title =
"");
46 Property (T2 *owner,
const std::string& name, T&& value,
47 const std::string& title =
"");
50 operator const T& ()
const noexcept;
51 const T&
value () const noexcept {
return m_value;}
55 Property<T>& operator = (T2&& that);
59 decltype(
auto)
operator + (T2&& that)
const;
62 decltype(
auto)
empty ()
const {
return m_value.empty();}
63 decltype(
auto) size ()
const {
return m_value.size();};
64 decltype(
auto) begin ()
const {
return m_value.begin();}
65 decltype(
auto) end ()
const {
return m_value.end();}
66 template<
typename T2>
decltype(
auto)
operator [] (
const T2& index)
const {
67 return m_value[
index];}
80 const PropertyMgr::PropMap_t::value_type *m_property =
nullptr;
88 template<
typename T>
template<
typename T2>
90 Property (T2 *owner,
const std::string& name,
const T& value,
91 const std::string& title)
94 owner->declareProperty (name, m_value, title);
95 if (
auto iter = owner->getPropertyMgr()->getProperties().find(name);
96 iter != owner->getPropertyMgr()->getProperties().end())
99 throw std::logic_error (
"PropertyWrapper::Property - property not found");
104 template<
typename T>
template<
typename T2>
106 Property (T2 *owner,
const std::string& name, T&& value,
107 const std::string& title)
110 owner->declareProperty (name, m_value, title);
111 if (
auto iter = owner->getPropertyMgr()->getProperties().find(name);
112 iter != owner->getPropertyMgr()->getProperties().end())
115 throw std::logic_error (
"PropertyWrapper::Property - property not found");
122 operator
const T& ()
const noexcept
129 template<
typename T>
template<
typename T2>
133 m_value = std::forward<T2>(that);
139 template<
typename T>
template<
typename T2>
143 return m_value + std::forward<T2>(that);
148 template<
typename T1,
typename T2>
149 decltype(
auto)
operator + (T1&& lh,
const Property<T2>& rh)
151 return std::forward<T1>(lh) + rh.value();
156 template<
typename T,
typename T2>
159 return lhs.value() == rhs;
164 template<
typename T,
typename T2>
167 return lhs.value() != rhs;
175 std::string propertyString;
176 if (property.getProperty()->second->getString (propertyString).isFailure())
177 throw std::runtime_error (
"PropertyWrapper::operator << - no string conversion available");
178 return str <<
"'" <<
property.getProperty()->first <<
"': " << propertyString;
bool operator!=(const DataVector< T > &a, const DataVector< T > &b)
Based on operator==.
bool operator==(const DataVector< T > &a, const DataVector< T > &b)
Vector equality comparison.
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
static const Attributes_t empty
Support class for PropertyMgr.
=============================================================================
T getProperty(const asg::IAsgTool *interface_tool, const std::string &prop_name)