50 lines
1005 B
C++
50 lines
1005 B
C++
/*
|
|
* 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_ */
|