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

73 lines
1.6 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.

/*
* ValueLazyFast.hpp
*
* Created on: 29 нояб. 2018 г.
* Author: titov
*/
#ifndef SOURCE_SYSTEMIC_VALUELAZYFAST_HPP_
#define SOURCE_SYSTEMIC_VALUELAZYFAST_HPP_
#include "IValue.hpp"
#include "IValueOverride.hpp"
namespace systemic { namespace detail {
template<typename V, typename T, V (T::* pf)() const>
class ValueLazyFast : public IValue<V> {
private:
const T & object;
public:
ValueLazyFast( const T & obj );
operator V() const final;
ValueLazyFast(const ValueLazyFast &) = delete;
ValueLazyFast & operator=(const ValueLazyFast &) = delete;
IValue<V> * getValue();
IValueOverride<V> * getValueOverride();
volatile const V * getBase();
~ValueLazyFast() = default;
};
}
}
template<typename V, typename T, V (T::*pf)() const>
inline systemic::detail::ValueLazyFast<V, T, pf>::ValueLazyFast( const T & obj ) :
object(obj) {}
template<typename V, typename T, V (T::*pf)() const>
inline systemic::detail::ValueLazyFast<V, T, pf>::operator V() const {
return (object.*pf)();
}
template<typename V, typename T, V (T::*pf)() const>
inline systemic::IValue<V> * systemic::detail::ValueLazyFast<V, T, pf>::getValue() {
return this;
}
template<typename V, typename T, V (T::*pf)() const>
inline systemic::IValueOverride<V> * systemic::detail::ValueLazyFast<V, T, pf>::getValueOverride() {
return nullptr;
}
template<typename V, typename T, V (T::*pf)() const>
inline const volatile V * systemic::detail::ValueLazyFast<V, T, pf>::getBase() {
return nullptr;
}
#endif /* SOURCE_SYSTEMIC_VALUELAZYFAST_HPP_ */