Enhance compatibility between control_t and base_control_t:

* Add conversion operator in control_t to convert instances to base_control_t
pull/2559/head
Vincent Coubard 2016-08-26 14:20:20 +01:00
parent 6d319c521f
commit 7a6edda44c
1 changed files with 14 additions and 7 deletions

View File

@ -174,11 +174,10 @@ namespace v1 {
control_t(base_control_t other) : control_t(base_control_t other) :
base_control_t(other) {} base_control_t(other) {}
control_t friend control_t operator+(const control_t& lhs, const control_t& rhs) {
inline operator+(const control_t& rhs) const {
control_t result( control_t result(
repeat_t(this->repeat | rhs.repeat), repeat_t(lhs.repeat | rhs.repeat),
(rhs.timeout == TIMEOUT_NONE) ? rhs.timeout : this->timeout); (rhs.timeout == TIMEOUT_NONE) ? rhs.timeout : lhs.timeout);
if (result.timeout != TIMEOUT_NONE && result.timeout > rhs.timeout) { if (result.timeout != TIMEOUT_NONE && result.timeout > rhs.timeout) {
result.timeout = rhs.timeout; result.timeout = rhs.timeout;
@ -208,6 +207,14 @@ namespace v1 {
return timeout; return timeout;
} }
operator base_control_t() const {
base_control_t result = {
repeat,
timeout
};
return result;
}
private: private:
static base_control_t make_base_control_t(repeat_t repeat, uint32_t timeout) { static base_control_t make_base_control_t(repeat_t repeat, uint32_t timeout) {
base_control_t result = { base_control_t result = {