MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/schematic/action/ValueUpdateAction.hpp
2024-06-07 11:12:56 +03:00

52 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* ValueUpdateAction.hpp
*
* Created on: 21 дек. 2020 г.
* Author: titov
*/
#ifndef UMLIBRARY_SCHEMATIC_ACTION_VALUEUPDATEACTION_HPP_
#define UMLIBRARY_SCHEMATIC_ACTION_VALUEUPDATEACTION_HPP_
#include "../../systemic/IFunctor.hh"
#include "../../systemic/IValue.hpp"
#include "../../systemic/IProcess.hh"
namespace schematic { namespace functor {
template<typename ValueType>
struct ValueUpdateAction : public systemic::IProcess {
typedef systemic::IValue<ValueType> Value;
typedef systemic::IFunctor<void> Action;
Value & value;
Action & action;
ValueType previous;
void process();
ValueUpdateAction( Value & value, Action & action ) : value(value), action(action), previous(value) {}
};
}
}
template<typename ValueType>
inline void schematic::functor::ValueUpdateAction<ValueType>::process() {
ValueType current = value;
if( previous != current )
action();
previous = current;
}
#endif /* UMLIBRARY_SCHEMATIC_ACTION_VALUEUPDATEACTION_HPP_ */