AP_ServoRelayEvents: add static create method

This commit is contained in:
Lucas De Marchi 2017-08-29 11:26:07 -07:00 committed by Francisco Ferreira
parent 13d7f58036
commit df29015533
1 changed files with 21 additions and 10 deletions

View File

@ -11,16 +11,15 @@
class AP_ServoRelayEvents {
public:
AP_ServoRelayEvents(AP_Relay &_relay) :
relay(_relay),
mask(0),
type(EVENT_TYPE_RELAY),
start_time_ms(0),
delay_ms(0),
repeat(0),
channel(0),
servo_value(0)
{}
static AP_ServoRelayEvents create(AP_Relay &_relay) {
return AP_ServoRelayEvents{_relay};
}
constexpr AP_ServoRelayEvents(AP_ServoRelayEvents &&other) = default;
/* Do not allow copies */
AP_ServoRelayEvents(const AP_ServoRelayEvents &other) = delete;
AP_ServoRelayEvents &operator=(const AP_ServoRelayEvents&) = delete;
// set allowed servo channel mask
void set_channel_mask(uint16_t _mask) { mask = _mask; }
@ -32,6 +31,18 @@ public:
void update_events(void);
private:
AP_ServoRelayEvents(AP_Relay &_relay)
: relay(_relay)
, mask(0)
, type(EVENT_TYPE_RELAY)
, start_time_ms(0)
, delay_ms(0)
, repeat(0)
, channel(0)
, servo_value(0)
{
}
AP_Relay &relay;
uint16_t mask;