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

50 lines
1010 B
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.

/*
* LateBindingValue.hpp
*
* Created on: 28 сент. 2020 г.
* Author: LeonidTitov
*/
#ifndef UMLIBRARY_SCHEMATIC_LATEBINDINGVALUE_HPP_
#define UMLIBRARY_SCHEMATIC_LATEBINDINGVALUE_HPP_
#include "../systemic/IValue.hpp"
namespace schematic {
template<typename T>
class LateBindingValue : public systemic::IValue<T> {
T default_value;
systemic::IValue<T> * binded_value;
public:
LateBindingValue( T default_value );
void bind( systemic::IValue<T> * );
operator T() const;
};
}
template<typename T>
inline schematic::LateBindingValue<T>::LateBindingValue( T default_value ) :
default_value(default_value), binded_value(nullptr) {}
template<typename T>
inline void schematic::LateBindingValue<T>::bind( systemic::IValue<T> * value ) {
binded_value = value;
}
template<typename T>
inline schematic::LateBindingValue<T>::operator T() const {
return binded_value ? *binded_value : default_value;
}
#endif /* UMLIBRARY_SCHEMATIC_LATEBINDINGVALUE_HPP_ */