AP_ADSB: add static create method

This commit is contained in:
Lucas De Marchi 2017-08-29 17:21:15 -07:00 committed by Francisco Ferreira
parent 1263e20a0d
commit cce51ec1c3

View File

@ -29,22 +29,23 @@
#include <AP_Buffer/AP_Buffer.h>
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();