mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-13 00:07:12 +00:00
ffa3996a5e
* clang-format: AllowShortEnumsOnASingleLine: false * clang-format: InsertNewlineAtEOF: true * clang-format: Standard: c++20 * clang-format: AlignConsecutiveBitFields * clang-format: AlignConsecutiveMacros * clang-format: RemoveParentheses: ReturnStatement * clang-format: RemoveSemicolon: true * Restored RemoveParentheses: Leave, retained general changes for it * formatting: fixed logging TAGs * Formatting update for dev Co-authored-by: あく <alleteam@gmail.com>
47 lines
960 B
C++
47 lines
960 B
C++
#pragma once
|
|
#include <core/record.h>
|
|
|
|
/**
|
|
* @brief Class for opening, casting, holding and closing records
|
|
*
|
|
* @tparam TRecordClass record class
|
|
*/
|
|
template <typename TRecordClass>
|
|
class RecordController {
|
|
public:
|
|
/**
|
|
* @brief Construct a new Record Controller object for record with record name
|
|
*
|
|
* @param record_name record name
|
|
*/
|
|
RecordController(const char* record_name) {
|
|
name = record_name;
|
|
value = static_cast<TRecordClass*>(furi_record_open(name));
|
|
}
|
|
|
|
~RecordController() {
|
|
furi_record_close(name);
|
|
}
|
|
|
|
/**
|
|
* @brief Record getter
|
|
*
|
|
* @return TRecordClass* record value
|
|
*/
|
|
TRecordClass* get() {
|
|
return value;
|
|
}
|
|
|
|
/**
|
|
* @brief Record getter (by cast)
|
|
*
|
|
* @return TRecordClass* record value
|
|
*/
|
|
operator TRecordClass*() const {
|
|
return value;
|
|
}
|
|
|
|
private:
|
|
const char* name;
|
|
TRecordClass* value;
|
|
};
|