DataFlash: allow access to DataFlash instance as a static singleton
This commit is contained in:
parent
11dd254498
commit
9a1cbff850
@ -2,6 +2,8 @@
|
||||
|
||||
#include "DataFlash_Backend.h"
|
||||
|
||||
DataFlash_Class *DataFlash_Class::_instance;
|
||||
|
||||
const AP_Param::GroupInfo DataFlash_Class::var_info[] = {
|
||||
// @Param: _BACKEND_TYPE
|
||||
// @DisplayName: DataFlash Backend Storage type
|
||||
|
@ -56,6 +56,15 @@ public:
|
||||
_firmware_string(firmware_string)
|
||||
{
|
||||
AP_Param::setup_object_defaults(this, var_info);
|
||||
if (_instance != nullptr) {
|
||||
AP_HAL::panic("DataFlash must be singleton");
|
||||
}
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
// get singleton instance
|
||||
static DataFlash_Class *instance(void) {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void set_mission(const AP_Mission *mission);
|
||||
@ -230,4 +239,7 @@ private:
|
||||
// calculate the length of a message using fields specified in
|
||||
// fmt; includes the message header
|
||||
int16_t Log_Write_calc_msg_len(const char *fmt) const;
|
||||
|
||||
private:
|
||||
static DataFlash_Class *_instance;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user