Skip to content

Commit ea7f3bc

Browse files
committed
Make ValueConsumer::set argument a const ref
1 parent 3d3144d commit ea7f3bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+83
-83
lines changed

src/sensesp/controllers/smart_switch_controller.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ SmartSwitchController::SmartSwitchController(bool auto_initialize,
2626
}
2727
}
2828

29-
void SmartSwitchController::set(bool new_value) {
29+
void SmartSwitchController::set(const bool& new_value) {
3030
is_on = new_value;
3131
this->emit(is_on);
3232
}
3333

34-
void SmartSwitchController::set(ClickTypes new_value) {
34+
void SmartSwitchController::set(const ClickTypes& new_value) {
3535
if (!ClickType::is_click(new_value)) {
3636
// Ignore button presses (we only want interpreted clicks)
3737
return;
@@ -56,7 +56,7 @@ void SmartSwitchController::set(ClickTypes new_value) {
5656
}
5757
}
5858

59-
void SmartSwitchController::set(String new_value) {
59+
void SmartSwitchController::set(const String& new_value) {
6060
if (TextToTruth::is_valid_true(new_value)) {
6161
is_on = true;
6262
} else if (TextToTruth::is_valid_false(new_value)) {

src/sensesp/controllers/smart_switch_controller.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ class SmartSwitchController : public BooleanTransform,
6161
*/
6262
SmartSwitchController(bool auto_initialize = true, String config_path = "",
6363
const char* sk_sync_paths[] = NULL);
64-
void set(bool new_value) override;
65-
void set(String new_value) override;
66-
void set(ClickTypes new_value) override;
64+
void set(const bool& new_value) override;
65+
void set(const String& new_value) override;
66+
void set(const ClickTypes& new_value) override;
6767

6868
// For reading and writing the configuration of this transformation
6969
virtual void get_configuration(JsonObject& doc) override;

src/sensesp/controllers/system_status_controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace sensesp {
44

5-
void SystemStatusController::set(WiFiState new_value) {
5+
void SystemStatusController::set(const WiFiState& new_value) {
66
// FIXME: If pointers to member functions would be held in an array,
77
// this would be a simple array dereferencing
88
switch (new_value) {
@@ -22,7 +22,7 @@ void SystemStatusController::set(WiFiState new_value) {
2222
}
2323
}
2424

25-
void SystemStatusController::set(SKWSConnectionState new_value) {
25+
void SystemStatusController::set(const SKWSConnectionState& new_value) {
2626
switch (new_value) {
2727
case SKWSConnectionState::kSKWSDisconnected:
2828
if (current_state_ != SystemStatus::kWifiDisconnected &&

src/sensesp/controllers/system_status_controller.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class SystemStatusController : public ValueConsumer<WiFiState>,
3232

3333
/// ValueConsumer interface for ValueConsumer<WiFiState> (Networking object
3434
/// state updates)
35-
virtual void set(WiFiState new_value) override;
35+
virtual void set(const WiFiState& new_value) override;
3636
/// ValueConsumer interface for ValueConsumer<SKWSConnectionState>
3737
/// (SKWSClient object state updates)
38-
virtual void set(SKWSConnectionState new_value) override;
38+
virtual void set(const SKWSConnectionState& new_value) override;
3939

4040
protected:
4141
void update_state(const SystemStatus new_state) {

src/sensesp/sensors/digital_output.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DigitalOutput::DigitalOutput(int pin) {
99
pinMode(pin, OUTPUT);
1010
}
1111

12-
void DigitalOutput::set(bool new_value) {
12+
void DigitalOutput::set(const bool& new_value) {
1313
digitalWrite(pin_number_, new_value);
1414
this->emit(new_value);
1515
}

src/sensesp/sensors/digital_output.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace sensesp {
1717
class DigitalOutput : public BooleanTransform {
1818
public:
1919
DigitalOutput(int pin);
20-
void set(bool new_value) override;
20+
void set(const bool& new_value) override;
2121

2222
private:
2323
int pin_number_;

src/sensesp/signalk/signalk_output.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class SKOutput : public SKEmitter, public SymmetricTransform<T> {
4242

4343
SKOutput(String sk_path, SKMetadata* meta) : SKOutput(sk_path, "", meta) {}
4444

45-
virtual void set(T new_value) override {
45+
virtual void set(const T& new_value) override {
4646
this->ValueProducer<T>::emit(new_value);
4747
}
4848

src/sensesp/signalk/signalk_put_request.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class SKPutRequest : public SKPutRequestBase, public ValueConsumer<T> {
146146
: SKPutRequestBase(sk_path, config_path, timeout),
147147
ignore_duplicates{ignore_duplicates} {}
148148

149-
virtual void set(T new_value) override {
149+
virtual void set(const T& new_value) override {
150150
if (ignore_duplicates && new_value == value) {
151151
return;
152152
}

src/sensesp/system/lambda_consumer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class LambdaConsumer : public ValueConsumer<IN> {
2727
LambdaConsumer(std::function<void(IN)> function)
2828
: ValueConsumer<IN>(), function{function} {}
2929

30-
void set(IN input) override { function(input); }
30+
void set(const IN& input) override { function(input); }
3131

3232
protected:
3333
std::function<void(IN)> function;

src/sensesp/system/observablevalue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ObservableValue : public ValueConsumer<T>, public ValueProducer<T> {
3232
ObservableValue(const T& value)
3333
: ValueConsumer<T>(), ValueProducer<T>(value) {}
3434

35-
void set(T value) override { this->ValueProducer<T>::emit(value); }
35+
void set(const T& value) override { this->ValueProducer<T>::emit(value); }
3636

3737
const T& operator=(const T& value) {
3838
set(value);
@@ -65,7 +65,7 @@ class PersistingObservableValue : public ObservableValue<T>,
6565
load_configuration();
6666
}
6767

68-
virtual void set(T value) override {
68+
virtual void set(const T& value) override {
6969
ObservableValue<T>::set(value);
7070
this->save_configuration();
7171
}

src/sensesp/system/pwm_output.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ PWMOutput::PWMOutput(int pin, int pwm_channel) {
1818
}
1919
}
2020

21-
void PWMOutput::set(float new_value) {
21+
void PWMOutput::set(const float& new_value) {
2222
uint8_t pwm_channel = default_channel_;
2323

2424
set_pwm(pwm_channel, new_value);

src/sensesp/system/pwm_output.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class PWMOutput : public ValueConsumer<float> {
4848
* pwm_channel is zero, the channel assigned when the PWMOutput instance
4949
* was instantiated will be used.
5050
*/
51-
virtual void set(float new_value) override;
51+
virtual void set(const float& new_value) override;
5252

5353
/**
5454
* Assigns the specified GPIO pin to the specified pwm channel.

src/sensesp/system/rgb_led.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static float get_pwm(long rgb, int shift_right, bool common_anode) {
3232
}
3333
}
3434

35-
void RgbLed::set(long new_value) {
35+
void RgbLed::set(const long& new_value) {
3636
if (led_r_channel_ >= 0) {
3737
float r = get_pwm(new_value, 16, common_anode_);
3838
PWMOutput::set_pwm(led_r_channel_, r);
@@ -49,7 +49,7 @@ void RgbLed::set(long new_value) {
4949
}
5050
}
5151

52-
void RgbLed::set(bool new_value) {
52+
void RgbLed::set(const bool& new_value) {
5353
if (new_value) {
5454
set(led_on_rgb_);
5555
} else {

src/sensesp/system/rgb_led.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ class RgbLed : public Configurable,
5555
* Used to set the current display state of the LED.
5656
* @param new_value The RGB color to display.
5757
*/
58-
virtual void set(long new_value) override;
58+
virtual void set(const long& new_value) override;
5959

6060
/**
6161
* Used to set the current display state of the LED with a simple on/off
6262
* boolean value. Using TRUE for new_value sets the color to the ON color.
6363
* Using FALSE uses the OFF color.
6464
*/
65-
virtual void set(bool new_value) override;
65+
virtual void set(const bool& new_value) override;
6666

6767
virtual void get_configuration(JsonObject& doc) override;
6868
virtual bool set_configuration(const JsonObject& config) override;

src/sensesp/system/system_status_led.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void SystemStatusLed::set_ws_connected() {
5656
blinker_->set_pattern(ws_connected_pattern);
5757
}
5858

59-
void SystemStatusLed::set(SystemStatus new_value) {
59+
void SystemStatusLed::set(const SystemStatus& new_value) {
6060
switch (new_value) {
6161
case SystemStatus::kWifiNoAP:
6262
this->set_wifi_no_ap();
@@ -82,6 +82,6 @@ void SystemStatusLed::set(SystemStatus new_value) {
8282
}
8383
}
8484

85-
void SystemStatusLed::set(int new_value) { blinker_->blip(); }
85+
void SystemStatusLed::set(const int& new_value) { blinker_->blip(); }
8686

8787
} // namespace sensesp

src/sensesp/system/system_status_led.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class SystemStatusLed : public ValueConsumer<SystemStatus>,
2929
public:
3030
SystemStatusLed(int pin);
3131

32-
virtual void set(SystemStatus new_value) override;
33-
virtual void set(int new_value) override;
32+
virtual void set(const SystemStatus& new_value) override;
33+
virtual void set(const int& new_value) override;
3434
};
3535

3636
} // namespace sensesp

src/sensesp/system/task_queue_producer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TaskQueueProducer : public ObservableValue<T> {
4444
unsigned int poll_rate = 990)
4545
: TaskQueueProducer(value, ReactESP::app, queue_size, poll_rate) {}
4646

47-
virtual void set(T value) override {
47+
virtual void set(const T& value) override {
4848
int retval;
4949
if (queue_size_ == 1) {
5050
retval = xQueueOverwrite(queue_, &value);

src/sensesp/system/valueconsumer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class ValueConsumer {
2626
* automatically by a ValueProducer.
2727
* @param new_value the value of the input
2828
*/
29-
virtual void set(T new_value) {}
29+
virtual void set(const T& new_value) {}
3030

31-
virtual void set_input(T new_value) {
31+
virtual void set_input(const T& new_value) {
3232
static bool warned = false;
3333
if (!warned) {
3434
warned = true;

src/sensesp/system/valueproducer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class ValueProducer : virtual public Observable {
109109
/*
110110
* Set a new output value and notify consumers about it
111111
*/
112-
void emit(T new_value) {
112+
void emit(const T& new_value) {
113113
this->output = new_value;
114114
Observable::notify();
115115
}

src/sensesp/transforms/air_density.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace sensesp {
88

99
AirDensity::AirDensity() : FloatTransform() {}
1010

11-
void AirDensity::set(float input) {
11+
void AirDensity::set(const float& input) {
1212
// For more info on the calculation see
1313
// https://en.wikipedia.org/wiki/Density_of_air
1414

src/sensesp/transforms/air_density.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace sensesp {
1414
class AirDensity : public FloatTransform {
1515
public:
1616
AirDensity();
17-
virtual void set(float input) override;
17+
virtual void set(const float& input) override;
1818

1919
private:
2020
float inputs[3];

src/sensesp/transforms/analogvoltage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ AnalogVoltage::AnalogVoltage(float max_voltage, float multiplier, float offset,
1111
load_configuration();
1212
}
1313

14-
void AnalogVoltage::set(float input) {
14+
void AnalogVoltage::set(const float& input) {
1515
this->emit(((input * (max_voltage_ / MAX_ANALOG_OUTPUT)) * multiplier_) +
1616
offset_);
1717
}

src/sensesp/transforms/analogvoltage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AnalogVoltage : public FloatTransform {
4242
public:
4343
AnalogVoltage(float max_voltage = 3.3, float multiplier = 1.0,
4444
float offset = 0.0, String config_path = "");
45-
virtual void set(float input) override;
45+
virtual void set(const float& input) override;
4646
virtual void get_configuration(JsonObject& doc) override;
4747
virtual bool set_configuration(const JsonObject& config) override;
4848
virtual String get_config_schema() override;

src/sensesp/transforms/angle_correction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AngleCorrection::AngleCorrection(float offset, float min_angle,
1010
load_configuration();
1111
}
1212

13-
void AngleCorrection::set(float input) {
13+
void AngleCorrection::set(const float& input) {
1414
// first the correction
1515
float x = input + offset_;
1616

src/sensesp/transforms/angle_correction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace sensesp {
2020
class AngleCorrection : public FloatTransform {
2121
public:
2222
AngleCorrection(float offset, float min_angle = 0, String config_path = "");
23-
virtual void set(float input) override;
23+
virtual void set(const float& input) override;
2424
virtual void get_configuration(JsonObject& doc) override;
2525
virtual bool set_configuration(const JsonObject& config) override;
2626
virtual String get_config_schema() override;

src/sensesp/transforms/change_filter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ChangeFilter::ChangeFilter(float min_delta, float max_delta, int max_skips,
2020
skips_ = max_skips_ + 1;
2121
}
2222

23-
void ChangeFilter::set(float new_value) {
23+
void ChangeFilter::set(const float& new_value) {
2424
float delta = absf(new_value - output);
2525
if ((delta >= min_delta_ && delta <= max_delta_) || skips_ > max_skips_) {
2626
skips_ = 0;

src/sensesp/transforms/change_filter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ChangeFilter : public FloatTransform {
3535
ChangeFilter(float min_delta = 0.0, float max_delta = 9999.0,
3636
int max_skips = 99, String config_path = "");
3737

38-
virtual void set(float new_value) override;
38+
virtual void set(const float& new_value) override;
3939
virtual void get_configuration(JsonObject& doc) override;
4040
virtual bool set_configuration(const JsonObject& config) override;
4141
virtual String get_config_schema() override;

src/sensesp/transforms/click_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ClickType::ClickType(String config_path, uint16_t long_click_delay,
1616
load_configuration();
1717
}
1818

19-
void ClickType::set(bool input) {
19+
void ClickType::set(const bool& input) {
2020
if (input) {
2121
on_button_press();
2222
} else {

src/sensesp/transforms/click_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ClickType : public Transform<bool, ClickTypes> {
5858
*/
5959
static bool is_click(ClickTypes value);
6060

61-
virtual void set(bool input) override;
61+
virtual void set(const bool& input) override;
6262
virtual void get_configuration(JsonObject& doc) override;
6363
virtual bool set_configuration(const JsonObject& config) override;
6464
virtual String get_config_schema() override;

src/sensesp/transforms/curveinterpolator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CurveInterpolator::CurveInterpolator(std::set<Sample>* defaults,
3232
load_configuration();
3333
}
3434

35-
void CurveInterpolator::set(float input) {
35+
void CurveInterpolator::set(const float& input) {
3636
float x0 = 0.0;
3737
float y0 = 0.0;
3838

src/sensesp/transforms/curveinterpolator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CurveInterpolator : public FloatTransform {
5555
CurveInterpolator(std::set<Sample>* defaults = NULL, String config_path = "");
5656

5757
// Set and retrieve the transformed value
58-
void set(float input) override;
58+
void set(const float& input) override;
5959

6060
// Web UI configuration methods
6161
CurveInterpolator* set_input_title(String input_title) {

src/sensesp/transforms/debounce.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Debounce : public SymmetricTransform<T> {
4242
this->load_configuration();
4343
}
4444

45-
virtual void set(T input) override {
45+
virtual void set(const T& input) override {
4646
// Input has changed since the last emit, or this is the first
4747
// input since the program started to run.
4848

src/sensesp/transforms/dew_point.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace sensesp {
66

77
DewPoint::DewPoint() : FloatTransform() {}
88

9-
void DewPoint::set(float input) {
9+
void DewPoint::set(const float& input) {
1010
// Dew point is calculated with Arden Buck Equation and Arden Buck valuation
1111
// sets For more info on the calculation see
1212
// https://en.wikipedia.org/wiki/Dew_point#Calculating_the_dew_point

src/sensesp/transforms/dew_point.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace sensesp {
1515
class DewPoint : public FloatTransform {
1616
public:
1717
DewPoint();
18-
virtual void set(float input) override;
18+
virtual void set(const float& input) override;
1919

2020
private:
2121
float inputs[2];

src/sensesp/transforms/difference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Difference::Difference(float k1, float k2, String config_path)
99
load_configuration();
1010
}
1111

12-
void Difference::set(float input) {
12+
void Difference::set(const float& input) {
1313
this->emit(k1 * inputs[0] - k2 * inputs[1]);
1414
}
1515

src/sensesp/transforms/difference.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace sensesp {
99
class Difference : public FloatTransform {
1010
public:
1111
Difference(float k1, float k2, String config_path = "");
12-
virtual void set(float input) override;
12+
virtual void set(const float& input) override;
1313
virtual void get_configuration(JsonObject& doc) override;
1414
virtual bool set_configuration(const JsonObject& config) override;
1515
virtual String get_config_schema() override;

0 commit comments

Comments
 (0)