/* * ValueBoundaryCapturing.hpp * * Created on: 29 нояб. 2023 г. * Author: titov */ #ifndef UMLIBRARY_SCHEMATIC_VALUEBOUNDARYCAPTURING_HPP_ #define UMLIBRARY_SCHEMATIC_VALUEBOUNDARYCAPTURING_HPP_ #include "../systemic/IValue.hpp" #include "../systemic/IProcess.hh" #include "../systemic/IFunctor.hh" namespace schematic { template class ValueBoundaryCapturing : public systemic::IProcess, public systemic::IFunctor { public: ValueBoundaryCapturing( systemic::IValue & value ); const volatile T & getMaximum() const; const volatile T & getMinimum() const; void operator()(); void process(); private: systemic::IValue & value; T maximum; T minimum; }; } template inline schematic::ValueBoundaryCapturing::ValueBoundaryCapturing( systemic::IValue & value ) : value(value), maximum(value), minimum(value) {} template inline const volatile T & schematic::ValueBoundaryCapturing::getMaximum() const { return maximum; } template inline const volatile T & schematic::ValueBoundaryCapturing::getMinimum() const { return minimum; } template inline void schematic::ValueBoundaryCapturing::operator()() { maximum = minimum = value; } template inline void schematic::ValueBoundaryCapturing::process() { const T temp = value; if( temp > maximum ) maximum = temp; if( temp < minimum ) minimum = temp; } #endif /* UMLIBRARY_SCHEMATIC_VALUEBOUNDARYCAPTURING_HPP_ */