From 5ec143072607696fb501a5d240a9b56a463284a2 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 30 Aug 2017 13:25:42 -0700 Subject: [PATCH] APMrover2: use static method to construct AP_Arming_Rover --- APMrover2/AP_Arming.h | 18 +++++++++++++----- APMrover2/Rover.h | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/APMrover2/AP_Arming.h b/APMrover2/AP_Arming.h index 2d83c1ca29..b3c0557a4a 100644 --- a/APMrover2/AP_Arming.h +++ b/APMrover2/AP_Arming.h @@ -8,16 +8,24 @@ class AP_Arming_Rover : public AP_Arming { public: - - AP_Arming_Rover(const AP_AHRS &ahrs_ref, const AP_Baro &baro, Compass &compass, - const AP_BattMonitor &battery) : - AP_Arming(ahrs_ref, baro, compass, battery) { + static AP_Arming_Rover create(const AP_AHRS &ahrs_ref, const AP_Baro &baro, Compass &compass, const AP_BattMonitor &battery) { + return AP_Arming_Rover{ahrs_ref, baro, compass, battery}; } + constexpr AP_Arming_Rover(AP_Arming_Rover &&other) = default; + + /* Do not allow copies */ + AP_Arming_Rover(const AP_Arming_Rover &other) = delete; + AP_Arming_Rover &operator=(const AP_Baro&) = delete; + bool pre_arm_rc_checks(const bool display_failure); protected: + AP_Arming_Rover(const AP_AHRS &ahrs_ref, const AP_Baro &baro, Compass &compass, + const AP_BattMonitor &battery) + : AP_Arming(ahrs_ref, baro, compass, battery) + { + } enum HomeState home_status() const override; }; - diff --git a/APMrover2/Rover.h b/APMrover2/Rover.h index 4f56e6e2dd..81c3235467 100644 --- a/APMrover2/Rover.h +++ b/APMrover2/Rover.h @@ -171,7 +171,7 @@ private: #endif // Arming/Disarming management class - AP_Arming_Rover arming {ahrs, barometer, compass, battery}; + AP_Arming_Rover arming = AP_Arming_Rover::create(ahrs, barometer, compass, battery); AP_L1_Control L1_controller;