consting things
This commit is contained in:
@@ -25,7 +25,7 @@ public:
|
||||
virtual void register_event_handler(EventHandler* handler) = 0;
|
||||
virtual void unregister_event_handler(EventHandler* handler) = 0;
|
||||
|
||||
virtual void distribute_event(Event &event) = 0;
|
||||
virtual void distribute_event(const Event &event) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class InputPinController
|
||||
public:
|
||||
virtual ~InputPinController() = default;
|
||||
|
||||
virtual bool read_data(uint8_t pin) const = 0;
|
||||
virtual bool read_data(const uint8_t &pin) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ Detector::~Detector()
|
||||
this->detect_thread.join();
|
||||
}
|
||||
|
||||
void Detector::detect()
|
||||
void Detector::detect() const
|
||||
{
|
||||
while(this->is_running)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ void Detector::detect()
|
||||
}
|
||||
}
|
||||
|
||||
void Detector::check_inputs()
|
||||
void Detector::check_inputs() const
|
||||
{
|
||||
for(auto &event : events)
|
||||
{
|
||||
|
||||
@@ -40,8 +40,8 @@ public:
|
||||
~Detector() override;
|
||||
|
||||
private:
|
||||
void detect();
|
||||
void check_inputs();
|
||||
void detect() const;
|
||||
void check_inputs() const;
|
||||
|
||||
private:
|
||||
const std::unique_ptr<input::InputPinController> input_gpio_interface;
|
||||
|
||||
@@ -51,7 +51,7 @@ void EventNotifier::unregister_event_handler(EventHandler *handler)
|
||||
this->event_handlers.erase(handler);
|
||||
}
|
||||
|
||||
void EventNotifier::distribute_event(Event &event)
|
||||
void EventNotifier::distribute_event(const Event &event)
|
||||
{
|
||||
this->event_queue->push(event);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
void register_event_handler(EventHandler *handler) override;
|
||||
void unregister_event_handler(EventHandler *handler) override;
|
||||
|
||||
void distribute_event(Event &event) override;
|
||||
void distribute_event(const Event &event) override;
|
||||
|
||||
private:
|
||||
void notify();
|
||||
|
||||
@@ -28,7 +28,7 @@ InputPinController::InputPinController(std::map<std::string, uint8_t> pins)
|
||||
init_pins();
|
||||
}
|
||||
|
||||
bool InputPinController::read_data(uint8_t pin) const
|
||||
bool InputPinController::read_data(const uint8_t &pin) const
|
||||
{
|
||||
// setting address to read
|
||||
write_row(pin / INPUT_MATRIX_SIZE);
|
||||
@@ -40,14 +40,14 @@ bool InputPinController::read_data(uint8_t pin) const
|
||||
return read_pin(this->pins.at("data_address"));
|
||||
}
|
||||
|
||||
void InputPinController::write_row(u_int8_t data) const
|
||||
void InputPinController::write_row(const u_int8_t &data) const
|
||||
{
|
||||
write_pin(this->pins.at("row_address_A"), data & 0b001u);
|
||||
write_pin(this->pins.at("row_address_B"), data & 0b010u);
|
||||
write_pin(this->pins.at("row_address_C"), data & 0b100u);
|
||||
}
|
||||
|
||||
void InputPinController::write_col(uint8_t data) const
|
||||
void InputPinController::write_col(const uint8_t &data) const
|
||||
{
|
||||
write_pin(this->pins.at("col_address_A"), data & 0b001u);
|
||||
write_pin(this->pins.at("col_address_B"), data & 0b010u);
|
||||
|
||||
@@ -26,12 +26,12 @@ class InputPinController : public input::InputPinController, public PinControlle
|
||||
{
|
||||
public:
|
||||
explicit InputPinController(std::map<std::string, uint8_t> pins);
|
||||
bool read_data(uint8_t pin) const override;
|
||||
bool read_data(const uint8_t &pin) const override;
|
||||
|
||||
private:
|
||||
void init_pins() const;
|
||||
void write_row(u_int8_t data) const;
|
||||
void write_col(uint8_t data) const;
|
||||
void write_row(const u_int8_t &data) const;
|
||||
void write_col(const uint8_t &data) const;
|
||||
|
||||
private:
|
||||
const std::map<std::string, uint8_t> pins;
|
||||
|
||||
Reference in New Issue
Block a user