73 lines
1.6 KiB
C++
73 lines
1.6 KiB
C++
|
|
/*
|
|||
|
|
* ValueLazyFast.hpp
|
|||
|
|
*
|
|||
|
|
* Created on: 29 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>. 2018 <EFBFBD>.
|
|||
|
|
* 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_ */
|