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

63 lines
1.1 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.

/*
* 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_ */