From 2d2876a226a586542839863cfd8afc02b5d8a587 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 30 Aug 2017 12:48:12 -0700 Subject: [PATCH] ArduPlane: use static method to construct AP_Arming_Plane --- ArduPlane/AP_Arming.h | 20 ++++++++++++++++---- ArduPlane/Plane.h | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ArduPlane/AP_Arming.h b/ArduPlane/AP_Arming.h index bf694221c3..a1782a58cc 100644 --- a/ArduPlane/AP_Arming.h +++ b/ArduPlane/AP_Arming.h @@ -14,11 +14,16 @@ public: ARMING_RUDDER_ARMDISARM = 2 }; - AP_Arming_Plane(const AP_AHRS &ahrs_ref, const AP_Baro &baro, Compass &compass, - const AP_BattMonitor &battery) : - AP_Arming(ahrs_ref, baro, compass, battery) { - AP_Param::setup_object_defaults(this, var_info); + static AP_Arming_Plane create(const AP_AHRS &ahrs_ref, const AP_Baro &baro, Compass &compass, const AP_BattMonitor &battery) { + return AP_Arming_Plane{ahrs_ref, baro, compass, battery}; } + + constexpr AP_Arming_Plane(AP_Arming_Plane &&other) = default; + + /* Do not allow copies */ + AP_Arming_Plane(const AP_Arming_Plane &other) = delete; + AP_Arming_Plane &operator=(const AP_Baro&) = delete; + bool pre_arm_checks(bool report); ArmingRudder rudder_arming() const { return (ArmingRudder)rudder_arming_value.get(); } @@ -27,6 +32,13 @@ public: static const struct AP_Param::GroupInfo var_info[]; protected: + AP_Arming_Plane(const AP_AHRS &ahrs_ref, const AP_Baro &baro, Compass &compass, + const AP_BattMonitor &battery) + : AP_Arming(ahrs_ref, baro, compass, battery) + { + AP_Param::setup_object_defaults(this, var_info); + } + bool ins_checks(bool report); enum HomeState home_status() const override; diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 92598cb48b..ac74b13052 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -772,7 +772,7 @@ private: #endif // Arming/Disarming mangement class - AP_Arming_Plane arming {ahrs, barometer, compass, battery}; + AP_Arming_Plane arming = AP_Arming_Plane::create(ahrs, barometer, compass, battery); AP_Param param_loader {var_info};