41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
/*
|
||
* ValueTransformation.hpp
|
||
*
|
||
* Created on: 9 июл. 2020 г.
|
||
* Author: LeonidTitov
|
||
*/
|
||
|
||
#ifndef UMLIBRARY_SCHEMATIC_VALUETRANSFORMATION_HPP_
|
||
#define UMLIBRARY_SCHEMATIC_VALUETRANSFORMATION_HPP_
|
||
|
||
#include "../systemic/IValue.hpp"
|
||
|
||
namespace schematic {
|
||
|
||
template<typename T, class Transformation>
|
||
class ValueTransformation : public systemic::IValue<T> {
|
||
public:
|
||
ValueTransformation( systemic::IValue<T> & value, const Transformation & transformation );
|
||
|
||
operator T() const;
|
||
|
||
private:
|
||
systemic::IValue<T> & value;
|
||
const Transformation & transformation;
|
||
};
|
||
|
||
}
|
||
|
||
template<typename T, class Transformation>
|
||
inline schematic::ValueTransformation<T, Transformation>::ValueTransformation(
|
||
systemic::IValue<T> & value, const Transformation & transformation ) : value(value), transformation(transformation) {}
|
||
|
||
template<typename T, class Transformation>
|
||
inline schematic::ValueTransformation<T, Transformation>::operator T() const {
|
||
|
||
return transformation( value );
|
||
|
||
}
|
||
|
||
#endif /* UMLIBRARY_SCHEMATIC_VALUETRANSFORMATION_HPP_ */
|