From cce51ec1c316aee01780b23ca8f73631547fd87d Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 29 Aug 2017 17:21:15 -0700 Subject: [PATCH] AP_ADSB: add static create method --- libraries/AP_ADSB/AP_ADSB.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/libraries/AP_ADSB/AP_ADSB.h b/libraries/AP_ADSB/AP_ADSB.h index 7c3b8f06a0..779270fd1e 100644 --- a/libraries/AP_ADSB/AP_ADSB.h +++ b/libraries/AP_ADSB/AP_ADSB.h @@ -29,22 +29,23 @@ #include -class AP_ADSB -{ +class AP_ADSB { public: + static AP_ADSB create(const AP_AHRS &ahrs) { + return AP_ADSB{ahrs}; + } + + constexpr AP_ADSB(AP_ADSB &&other) = default; + + /* Do not allow copies */ + AP_ADSB(const AP_ADSB &other) = delete; + AP_ADSB &operator=(const AP_ADSB&) = delete; + struct adsb_vehicle_t { mavlink_adsb_vehicle_t info; // the whole mavlink struct with all the juicy details. sizeof() == 38 uint32_t last_update_ms; // last time this was refreshed, allows timeouts }; - - // Constructor - AP_ADSB(const AP_AHRS &ahrs) : - _ahrs(ahrs) - { - AP_Param::setup_object_defaults(this, var_info); - } - // for holding parameters static const struct AP_Param::GroupInfo var_info[]; @@ -75,6 +76,11 @@ public: void handle_message(const mavlink_channel_t chan, const mavlink_message_t* msg); private: + AP_ADSB(const AP_AHRS &ahrs) + : _ahrs(ahrs) + { + AP_Param::setup_object_defaults(this, var_info); + } // initialize _vehicle_list void init();