/** * @RDE_HEADER@ * Helper class for storing a simple value and an implizit changed flag * $Id$ * $HeadURL$ * $Author$ */ #pragma once // Qt #include //---------------------------------------------------------------------------- namespace SituationMap { /*! \class SimpleValue \brief Simple storing fo values */ template class SimpleValue { protected: TYPE m_value = TYPE(); // '{}' to initialize the member (and avoid unconditional jumps@valgrind) bool m_changed = true; public: SimpleValue() = default; // cppcheck-suppress noExplicitConstructor SimpleValue(const TYPE &value) // should not be declared explicit to avoid additional writing stuff to cast values : m_value(value) {} SimpleValue &operator=(const TYPE &newValue) { if (this->m_value != newValue) { this->m_value = newValue; m_changed = true; } return *this; } const TYPE &operator()() const { return this->m_value; } const TYPE &value() const { return this->m_value; } TYPE &refValue() { m_changed = true; return this->m_value; } const TYPE &refValue() const { return this->m_value; } bool changed() const { return m_changed; } void reset() { m_changed = false; } void setChanged() { m_changed = true; } friend std::ostream &operator<<(std::ostream &stream, const SimpleValue &simpleVal) { stream << simpleVal.value(); return stream; } }; } // namespace SituationMap