[valve] Inline the trivial Valve and ValveCall accessors

This commit is contained in:
J. Nick Koston
2026-08-22 01:18:16 -05:00
parent ef1d77885d
commit 18f7d1984f
2 changed files with 4 additions and 11 deletions
-7
View File
@@ -120,10 +120,6 @@ ValveCall &ValveCall::set_stop(bool stop) {
this->stop_ = stop;
return *this;
}
bool ValveCall::get_stop() const { return this->stop_; }
ValveCall Valve::make_call() { return {this}; }
void Valve::publish_state(bool save) {
this->position = clamp(this->position, 0.0f, 1.0f);
@@ -162,9 +158,6 @@ optional<ValveRestoreState> Valve::restore_state_() {
return recovered;
}
bool Valve::is_fully_open() const { return this->position == VALVE_OPEN; }
bool Valve::is_fully_closed() const { return this->position == VALVE_CLOSED; }
ValveCall ValveRestoreState::to_call(Valve *valve) {
auto call = valve->make_call();
call.set_position(this->position);
+4 -4
View File
@@ -47,7 +47,7 @@ class ValveCall {
void perform();
const optional<float> &get_position() const;
bool get_stop() const;
bool get_stop() const { return this->stop_; }
const optional<bool> &get_toggle() const;
protected:
@@ -114,7 +114,7 @@ class Valve : public EntityBase {
float position;
/// Construct a new valve call used to control the valve.
ValveCall make_call();
ValveCall make_call() { return {this}; }
template<typename F> void add_on_state_callback(F &&f) { this->state_callback_.add(std::forward<F>(f)); }
@@ -130,9 +130,9 @@ class Valve : public EntityBase {
virtual ValveTraits get_traits() = 0;
/// Helper method to check if the valve is fully open. Equivalent to comparing .position against 1.0
bool is_fully_open() const;
bool is_fully_open() const { return this->position == VALVE_OPEN; }
/// Helper method to check if the valve is fully closed. Equivalent to comparing .position against 0.0
bool is_fully_closed() const;
bool is_fully_closed() const { return this->position == VALVE_CLOSED; }
protected:
friend ValveCall;