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

@ -171,14 +171,13 @@ namespace v1 {
control_t(uint32_t timeout_ms) :
base_control_t(make_base_control_t(REPEAT_UNDECLR, timeout_ms)) {}
control_t(base_control_t other) :
control_t(base_control_t other) :
base_control_t(other) {}
control_t
inline operator+(const control_t& rhs) const {
friend control_t operator+(const control_t& lhs, const control_t& rhs) {
control_t result(
repeat_t(this->repeat | rhs.repeat),
(rhs.timeout == TIMEOUT_NONE) ? rhs.timeout : this->timeout);
repeat_t(lhs.repeat | rhs.repeat),
(rhs.timeout == TIMEOUT_NONE) ? rhs.timeout : lhs.timeout);
if (result.timeout != TIMEOUT_NONE && result.timeout > rhs.timeout) {
result.timeout = rhs.timeout;
@ -208,8 +207,7 @@ namespace v1 {
return timeout;
}
private:
static base_control_t make_base_control_t(repeat_t repeat, uint32_t timeout) {
operator base_control_t() const {
base_control_t result = {
repeat,
timeout
@ -217,6 +215,15 @@ namespace v1 {
return result;
}
private:
static base_control_t make_base_control_t(repeat_t repeat, uint32_t timeout) {
base_control_t result = {
repeat,
timeout
};
return result;
}
friend class Harness;
};