mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
Rename all member functions from p_ to m_
This commit is contained in:
+10
-10
@@ -1,19 +1,19 @@
|
||||
#include "simulator_base.hpp"
|
||||
|
||||
Simulator_base::Simulator_base(std::string name, std::chrono::milliseconds interval)
|
||||
: p_name(name), p_timer([this]{ timer(); }), m_interval(interval)
|
||||
: m_name(name), m_timer([this]{ timer(); }), m_interval(interval)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string Simulator_base::name() const {
|
||||
// Get the name of the simulator
|
||||
return p_name;
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool Simulator_base::is_ui_id_unique(std::string id) const {
|
||||
// Check if the UI name is unique
|
||||
for (UI_item* item : p_UI_items) {
|
||||
for (UI_item* item : m_UI_items) {
|
||||
if (item->id() == id) {
|
||||
return false;
|
||||
}
|
||||
@@ -27,15 +27,15 @@ void Simulator_base::add_UI_item(UI_item* item) {
|
||||
if (is_ui_id_unique(item->id()) == false) {
|
||||
throw std::runtime_error("UI item id " + item->id() + " is not unique");
|
||||
}
|
||||
p_UI_items_map[item->id()] = item;
|
||||
p_UI_items.push_back(item);
|
||||
m_UI_items_map[item->id()] = item;
|
||||
m_UI_items.push_back(item);
|
||||
}
|
||||
|
||||
json Simulator_base::get_UI_items() const {
|
||||
// Get the UI items
|
||||
json items;
|
||||
items["name"] = p_name;
|
||||
for (UI_item* item : p_UI_items) {
|
||||
items["name"] = m_name;
|
||||
for (UI_item* item : m_UI_items) {
|
||||
items["UI_items"].push_back(item->to_json());
|
||||
}
|
||||
|
||||
@@ -44,16 +44,16 @@ json Simulator_base::get_UI_items() const {
|
||||
|
||||
UI_item* Simulator_base::get_UI_item(std::string id) const {
|
||||
// Get a UI item by id
|
||||
return p_UI_items_map.at(id);
|
||||
return m_UI_items_map.at(id);
|
||||
}
|
||||
|
||||
void Simulator_base::run() {
|
||||
// Start the timer
|
||||
p_timer.setInterval(m_interval);
|
||||
m_timer.setInterval(m_interval);
|
||||
run_at_startup();
|
||||
}
|
||||
|
||||
void Simulator_base::stop() {
|
||||
// Stop the simulator
|
||||
p_timer.stop();
|
||||
m_timer.stop();
|
||||
}
|
||||
@@ -78,9 +78,9 @@ class Simulator_base {
|
||||
*/
|
||||
virtual void run_at_startup() {};
|
||||
protected:
|
||||
std::string p_name;
|
||||
std::vector<UI_item*> p_UI_items;
|
||||
std::map<std::string, UI_item*> p_UI_items_map;
|
||||
Timer p_timer;
|
||||
std::string m_name;
|
||||
std::vector<UI_item*> m_UI_items;
|
||||
std::map<std::string, UI_item*> m_UI_items_map;
|
||||
Timer m_timer;
|
||||
std::chrono::milliseconds m_interval;
|
||||
};
|
||||
@@ -3,17 +3,17 @@
|
||||
|
||||
Test_Sim::Test_Sim() :
|
||||
Simulator_base("Test_Sim"),
|
||||
p_button("button", "Button", Color(Color::White), Color(Color::Black), [](std::string id) { std::cout << "Button " << id << " clicked" << std::endl; }),
|
||||
p_combobox("combobox", "Combobox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, 0, [](std::string id, std::string selected) { std::cout << "Combobox " << id << " selected " << selected << std::endl; }),
|
||||
p_label("label", "Label", Color(Color::White), Color(Color::Black)),
|
||||
p_checkbox("checkbox", "Checkbox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, [](std::string id, std::vector<std::string> selected) { std::cout << "Checkbox " << id << " selected " << (selected.size() > 0 ? selected[0] : "") << std::endl; }),
|
||||
p_slider("slider", "Slider", Color(Color::White), Color(Color::Black), 0, 100, 50, [](std::string id, double value) { std::cout << "Slider " << id << " changed to " << value << std::endl; })
|
||||
m_button("button", "Button", Color(Color::White), Color(Color::Black), [](std::string id) { std::cout << "Button " << id << " clicked" << std::endl; }),
|
||||
m_combobox("combobox", "Combobox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, 0, [](std::string id, std::string selected) { std::cout << "Combobox " << id << " selected " << selected << std::endl; }),
|
||||
m_label("label", "Label", Color(Color::White), Color(Color::Black)),
|
||||
m_checkbox("checkbox", "Checkbox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, [](std::string id, std::vector<std::string> selected) { std::cout << "Checkbox " << id << " selected " << (selected.size() > 0 ? selected[0] : "") << std::endl; }),
|
||||
m_slider("slider", "Slider", Color(Color::White), Color(Color::Black), 0, 100, 50, [](std::string id, double value) { std::cout << "Slider " << id << " changed to " << value << std::endl; })
|
||||
{
|
||||
this->add_UI_item(&this->p_button);
|
||||
this->add_UI_item(&this->p_combobox);
|
||||
this->add_UI_item(&this->p_label);
|
||||
this->add_UI_item(&this->p_checkbox);
|
||||
this->add_UI_item(&this->p_slider);
|
||||
this->add_UI_item(&this->m_button);
|
||||
this->add_UI_item(&this->m_combobox);
|
||||
this->add_UI_item(&this->m_label);
|
||||
this->add_UI_item(&this->m_checkbox);
|
||||
this->add_UI_item(&this->m_slider);
|
||||
}
|
||||
|
||||
void Test_Sim::timer()
|
||||
|
||||
@@ -7,9 +7,9 @@ class Test_Sim : public Simulator_base {
|
||||
void timer() override;
|
||||
void run_at_startup() override;
|
||||
private:
|
||||
UI_button p_button;
|
||||
UI_combobox p_combobox;
|
||||
UI_label p_label;
|
||||
UI_checkbox p_checkbox;
|
||||
UI_slider p_slider;
|
||||
UI_button m_button;
|
||||
UI_combobox m_combobox;
|
||||
UI_label m_label;
|
||||
UI_checkbox m_checkbox;
|
||||
UI_slider m_slider;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user