63 lines
1.1 KiB
C++
63 lines
1.1 KiB
C++
|
|
/*
|
|||
|
|
* CacheSetAsync.hpp
|
|||
|
|
*
|
|||
|
|
* Created on: 27 нояб. 2023 г.
|
|||
|
|
* Author: titov
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#ifndef UMLIBRARY_SCHEMATIC_CACHESETASYNC_HPP_
|
|||
|
|
#define UMLIBRARY_SCHEMATIC_CACHESETASYNC_HPP_
|
|||
|
|
|
|||
|
|
#include "../systemic/IValueAsync.hpp"
|
|||
|
|
#include "../systemic/IValue.hpp"
|
|||
|
|
|
|||
|
|
namespace schematic {
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
class CacheSetAsync : public systemic::IValueType<T> {
|
|||
|
|
public:
|
|||
|
|
CacheSetAsync( systemic::IValueType<T> & async );
|
|||
|
|
|
|||
|
|
const T & getCachedValue() const;
|
|||
|
|
|
|||
|
|
void set( T );
|
|||
|
|
T get() const;
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
T cached;
|
|||
|
|
systemic::IValueType<T> & async;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
inline schematic::CacheSetAsync<T>::CacheSetAsync(
|
|||
|
|
systemic::IValueType<T> &async) :
|
|||
|
|
async(async), cached(async.get()) {}
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
inline const T & schematic::CacheSetAsync<T>::getCachedValue() const {
|
|||
|
|
|
|||
|
|
return cached;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
inline void schematic::CacheSetAsync<T>::set(T valueType) {
|
|||
|
|
|
|||
|
|
cached = valueType;
|
|||
|
|
async.set(cached);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
inline T schematic::CacheSetAsync<T>::get() const {
|
|||
|
|
|
|||
|
|
return cached;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endif /* UMLIBRARY_SCHEMATIC_CACHESETASYNC_HPP_ */
|