diff --git a/core/algorithms/property.h b/core/algorithms/property.h index ec53ac3b212e18199cd0e2b7e1ef687dca5d8dec..f05b92ad1b5ddb06239ee2ab3db1ae6c6ba953ed 100644 --- a/core/algorithms/property.h +++ b/core/algorithms/property.h @@ -140,8 +140,12 @@ using PropertyMixin = Configurable; // operator== overload not needed in C++20 as it will call the member version #if __cpp_impl_three_way_comparison < 201711 template <class T, class U> -bool operator==(const U& rhs, algorithms::Configurable::Property<T>& p) { +bool operator==(const U& rhs, const algorithms::Configurable::Property<T>& p) { return p == rhs; } +template <class T> +std::ostream& operator<<(std::ostream& os, const algorithms::Configurable::Property<T>& p) { + return os << p.value(); +} #endif // others needed??? TODO diff --git a/core/algorithms/test.cpp b/core/algorithms/test.cpp index 0ef0216417421f8d5b9df3247b0b7722879aa9f9..b9c3d1bb60e39f8ccada8d9915e1273faf0ad700 100644 --- a/core/algorithms/test.cpp +++ b/core/algorithms/test.cpp @@ -2,9 +2,6 @@ using namespace algorithms; -// TODO implement PropertyBase? or use boost::any? need something better for setProperty -// so we don't need to repeat the type unnecessarily. Hard without type erasure though... - class testLogger : public LoggerMixin { public: testLogger() @@ -32,13 +29,13 @@ class propTest : public PropertyMixin, LoggerMixin { public: propTest() : LoggerMixin("propTest") {} void print() const { - info() << "integer property: " << getProperty<int>("integer") << endmsg; - info() << "foo property: " << getProperty<std::string>("foo") << endmsg; + info() << "integer property: " << m_int << endmsg; + info() << "foo property: " << m_foo << endmsg; if (hasProperty("bar")) { - info() << "bar property: " << getProperty<std::string>("bar") << endmsg; + info() << "bar property: " << m_bar << endmsg; } if (hasProperty("double")) { - info() << "double (non-def.) property: " << getProperty<double>("double") << endmsg; + info() << "double (non-def.) property: " << m_double << endmsg; } } private: @@ -70,6 +67,5 @@ int main() { tp.setProperty<double>("double", 3.1415f); tp.print(); - return 0; }