MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/driver/IParamStorage.hh
2024-06-07 11:12:56 +03:00

67 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.

/*
* IParamStorage.h
*
* Created on: 21 нояб. 2018 г.
* Author: titov
*/
#ifndef SOURCE_DRIVER_IPARAMSTORAGE_H_
#define SOURCE_DRIVER_IPARAMSTORAGE_H_
#include <cstddef>
#include <utility>
#include <exception>
#include "../systemic/IParameterProvider.hh"
namespace driver {
struct IParamStorage : public systemic::IParameterProvider {
/*!\brief Запись данных на энергонезависимую память.
*/
virtual void flush() = 0;
/*!\brief Чтение данных с энергонезависимой памяти.
*/
virtual void load() = 0;
/*!\brief Функция проверки соотвествия данных в текущей памяти и ПЗУ.
* \return Признак соотвествия.
*/
virtual bool isDataSync() const = 0;
/*!\brief Очистка структуры данных.
*/
virtual void clear() = 0;
};
}
#include "../systemic/SystemException.hh"
namespace {
struct LackOfMemory : public systemic::SystemException {
typedef systemic::IParameterProvider::Id Id;
std::size_t requested_memory;
Id param_id;
LackOfMemory( std::size_t mem, Id id ) : requested_memory(mem), param_id(id) {}
std::size_t id() const noexcept { return 403; }
const char * what() const noexcept { return "lack of memory in storage"; }
std::pair<const char *, std::size_t> binary() const noexcept {
return { reinterpret_cast<const char *>( &requested_memory ), sizeof(std::size_t) + sizeof(Id) };
}
};
}
#endif /* SOURCE_DRIVER_IPARAMSTORAGE_H_ */