From bd8f0a9e93e2f524d148f69c342069c7bc718285 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 28 Aug 2017 17:41:49 -0700 Subject: [PATCH] AP_BattMonitor: add static create method --- libraries/AP_BattMonitor/AP_BattMonitor.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/AP_BattMonitor/AP_BattMonitor.h b/libraries/AP_BattMonitor/AP_BattMonitor.h index e3f15aca5f..4f58264d85 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor.h @@ -37,9 +37,13 @@ class AP_BattMonitor friend class AP_BattMonitor_SMBus_Maxell; public: + static AP_BattMonitor create() { return AP_BattMonitor{}; } - /// Constructor - AP_BattMonitor(); + constexpr AP_BattMonitor(AP_BattMonitor &&other) = default; + + /* Do not allow copies */ + AP_BattMonitor(const AP_BattMonitor &other) = delete; + AP_BattMonitor &operator=(const AP_BattMonitor&) = delete; // Battery monitor driver types enum BattMonitor_Type { @@ -175,6 +179,8 @@ protected: AP_Int8 _low_voltage_source; /// voltage type used for detection of low voltage event private: + AP_BattMonitor(); + BattMonitor_State state[AP_BATT_MONITOR_MAX_INSTANCES]; AP_BattMonitor_Backend *drivers[AP_BATT_MONITOR_MAX_INSTANCES]; uint8_t _num_instances; /// number of monitors