MotorControlModuleSDFM_TMS3.../Projects/EFC_Application/UMLibrary/schematic/ValueBoundaryCapturing.hpp

79 lines
1.5 KiB
C++

/*
* 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<typename T>
class ValueBoundaryCapturing : public systemic::IProcess, public systemic::IFunctor<void> {
public:
ValueBoundaryCapturing( systemic::IValue<T> & value );
const volatile T & getMaximum() const;
const volatile T & getMinimum() const;
void operator()();
void process();
private:
systemic::IValue<T> & value;
T maximum;
T minimum;
};
}
template<typename T>
inline schematic::ValueBoundaryCapturing<T>::ValueBoundaryCapturing(
systemic::IValue<T> & value ) : value(value), maximum(value), minimum(value) {}
template<typename T>
inline const volatile T & schematic::ValueBoundaryCapturing<T>::getMaximum() const {
return maximum;
}
template<typename T>
inline const volatile T & schematic::ValueBoundaryCapturing<T>::getMinimum() const {
return minimum;
}
template<typename T>
inline void schematic::ValueBoundaryCapturing<T>::operator()() {
maximum = minimum = value;
}
template<typename T>
inline void schematic::ValueBoundaryCapturing<T>::process() {
const T temp = value;
if( temp > maximum )
maximum = temp;
if( temp < minimum )
minimum = temp;
}
#endif /* UMLIBRARY_SCHEMATIC_VALUEBOUNDARYCAPTURING_HPP_ */