diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-04-30 11:01:48 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-04-30 11:01:48 +0200 |
| commit | 3e68879c7901384913c03bd587b248a3fd79d9ff (patch) | |
| tree | 3aa3395d6c84b064c60ad19f5d274a5d2bd575d4 | |
| parent | f729c62bf23061e33a362ef1322d8fed8ae632b1 (diff) | |
| download | turns-3e68879c7901384913c03bd587b248a3fd79d9ff.tar.xz turns-3e68879c7901384913c03bd587b248a3fd79d9ff.zip | |
core: rename participant to Participant
| -rw-r--r-- | core/include/turns/core/fwd.hpp | 2 | ||||
| -rw-r--r-- | core/include/turns/core/participant.hpp | 22 | ||||
| -rw-r--r-- | core/include/turns/core/turn_order.hpp | 2 | ||||
| -rw-r--r-- | core/src/init.cpp | 2 | ||||
| -rw-r--r-- | core/src/participant.cpp | 19 | ||||
| -rw-r--r-- | core/src/turn_order.cpp | 6 | ||||
| -rw-r--r-- | core/tests/participant.cpp | 24 | ||||
| -rw-r--r-- | core/tests/turn_order.cpp | 12 | ||||
| -rw-r--r-- | ui/include/turns/ui/participant_editor.hpp | 12 | ||||
| -rw-r--r-- | ui/include/turns/ui/participant_row.hpp | 2 | ||||
| -rw-r--r-- | ui/src/participant_editor.cpp | 10 | ||||
| -rw-r--r-- | ui/src/participant_row.cpp | 2 | ||||
| -rw-r--r-- | ui/src/tracker/actions.cpp | 2 | ||||
| -rw-r--r-- | ui/src/turn_order_view.cpp | 2 | ||||
| -rw-r--r-- | ui/tests/participant_row.cpp | 4 |
15 files changed, 61 insertions, 62 deletions
diff --git a/core/include/turns/core/fwd.hpp b/core/include/turns/core/fwd.hpp index 1646d4b..612e8c8 100644 --- a/core/include/turns/core/fwd.hpp +++ b/core/include/turns/core/fwd.hpp @@ -7,7 +7,7 @@ namespace turns::core { enum struct disposition : std::uint8_t; - struct participant; + struct Participant; struct turn_order; } // namespace turns::core diff --git a/core/include/turns/core/participant.hpp b/core/include/turns/core/participant.hpp index a7eb98d..2c02b1b 100644 --- a/core/include/turns/core/participant.hpp +++ b/core/include/turns/core/participant.hpp @@ -14,15 +14,15 @@ namespace turns::core { - struct participant : Glib::Object + struct Participant : Glib::Object { - auto static create(Glib::ustring name, float priority, disposition disposition) -> Glib::RefPtr<participant>; - auto static create(nlohmann::json const & serialized) -> Glib::RefPtr<participant>; + auto static create(Glib::ustring name, float priority, disposition disposition) -> Glib::RefPtr<Participant>; + auto static create(nlohmann::json const & serialized) -> Glib::RefPtr<Participant>; - participant(); - participant(Glib::ustring name, float priority, disposition disposition); + Participant(); + Participant(Glib::ustring name, float priority, disposition disposition); - auto operator<=>(participant const & other) const noexcept -> std::partial_ordering; + auto operator<=>(Participant const & other) const noexcept -> std::partial_ordering; auto property_disposition(this auto && self); auto property_is_active(this auto && self); @@ -40,27 +40,27 @@ namespace turns::core Glib::Property<float> m_priority{*this, "priority", 0.0f}; }; - auto participant::property_disposition(this auto && self) + auto Participant::property_disposition(this auto && self) { return self.m_disposition.get_proxy(); } - auto participant::property_is_active(this auto && self) + auto Participant::property_is_active(this auto && self) { return self.m_is_active.get_proxy(); } - auto participant::property_is_defeated(this auto && self) + auto Participant::property_is_defeated(this auto && self) { return self.m_is_defeated.get_proxy(); } - auto participant::property_name(this auto && self) + auto Participant::property_name(this auto && self) { return self.m_name.get_proxy(); } - auto participant::property_priority(this auto && self) + auto Participant::property_priority(this auto && self) { return self.m_priority.get_proxy(); } diff --git a/core/include/turns/core/turn_order.hpp b/core/include/turns/core/turn_order.hpp index 5e38d0c..6a0ee43 100644 --- a/core/include/turns/core/turn_order.hpp +++ b/core/include/turns/core/turn_order.hpp @@ -24,7 +24,7 @@ namespace turns::core struct turn_order : Gio::ListModel, Glib::Object { - using value_type = Glib::RefPtr<participant>; + using value_type = Glib::RefPtr<Participant>; using container_type = std::vector<value_type>; using iterator = container_type::iterator; using const_iterator = container_type::const_iterator; diff --git a/core/src/init.cpp b/core/src/init.cpp index 258aceb..3991248 100644 --- a/core/src/init.cpp +++ b/core/src/init.cpp @@ -8,7 +8,7 @@ namespace turns::core auto register_types() -> void { - static_cast<void>(participant{}); + static_cast<void>(Participant{}); static_cast<void>(turn_order{}); } diff --git a/core/src/participant.cpp b/core/src/participant.cpp index 9b0ec51..d4b3835 100644 --- a/core/src/participant.cpp +++ b/core/src/participant.cpp @@ -12,16 +12,15 @@ #include <compare> #include <string> -#include <typeinfo> namespace turns::core { - auto participant::create(Glib::ustring name, float priority, core::disposition disposition) -> Glib::RefPtr<participant> + auto Participant::create(Glib::ustring name, float priority, core::disposition disposition) -> Glib::RefPtr<Participant> { - return Glib::make_refptr_for_instance(new participant{name, priority, disposition}); + return Glib::make_refptr_for_instance(new Participant{name, priority, disposition}); } - auto participant::create(nlohmann::json const & serialized) -> Glib::RefPtr<participant> + auto Participant::create(nlohmann::json const & serialized) -> Glib::RefPtr<Participant> { auto disposition = serialized.value("disposition", disposition::neutral); auto priority = serialized.value("priority", 0.0f); @@ -35,26 +34,26 @@ namespace turns::core return instance; } - participant::participant() - : Glib::ObjectBase{typeid(participant)} + Participant::Participant() + : Glib::ObjectBase{"TurnsParticipant"} , Glib::Object{} { } - participant::participant(Glib::ustring name, float priority, core::disposition disposition) - : participant() + Participant::Participant(Glib::ustring name, float priority, core::disposition disposition) + : Participant() { m_name = name; m_priority = priority; m_disposition = disposition; } - auto participant::operator<=>(participant const & other) const noexcept -> std::partial_ordering + auto Participant::operator<=>(Participant const & other) const noexcept -> std::partial_ordering { return m_priority <=> other.m_priority; } - auto participant::serialize() -> nlohmann::json + auto Participant::serialize() -> nlohmann::json { return nlohmann::json{ {"disposition", m_disposition}, diff --git a/core/src/turn_order.cpp b/core/src/turn_order.cpp index d43ac7f..ef7bde6 100644 --- a/core/src/turn_order.cpp +++ b/core/src/turn_order.cpp @@ -102,7 +102,7 @@ namespace turns::core auto turn_order::add(Glib::ustring const & name, float priority, disposition disposition) -> void { - auto entry = participant::create(name, priority, disposition); + auto entry = Participant::create(name, priority, disposition); entry->property_priority().signal_changed().connect(sigc::bind(sigc::mem_fun(*this, &turn_order::handle_priority_changed), entry)); auto position = std::distance(m_data.cbegin(), insert(entry)); items_changed(position, 0, 1); @@ -220,7 +220,7 @@ namespace turns::core m_data.clear(); auto participants = from.value("participants", std::vector<nlohmann::json>{}); auto factory = [](auto s) { - return participant::create(s); + return Participant::create(s); }; auto inserter = std::bind(&turn_order::insert, this, _1); std::ranges::for_each(participants | std::views::transform(factory), inserter); @@ -256,7 +256,7 @@ namespace turns::core auto turn_order::get_item_type_vfunc() -> GType { - return participant::get_type(); + return Participant::get_type(); } auto turn_order::get_n_items_vfunc() -> unsigned diff --git a/core/tests/participant.cpp b/core/tests/participant.cpp index ed7b435..8c7c230 100644 --- a/core/tests/participant.cpp +++ b/core/tests/participant.cpp @@ -30,7 +30,7 @@ namespace turns::core::tests SECTION("Can be constructed using default ctor") { - auto instance = participant{}; + auto instance = Participant{}; REQUIRE(instance.property_name() == ""); REQUIRE(instance.property_priority() == 0); REQUIRE(instance.property_disposition() == disposition::neutral); @@ -40,7 +40,7 @@ namespace turns::core::tests SECTION("Can be constructed using ctor") { - auto instance = participant{name, priority, disposition}; + auto instance = Participant{name, priority, disposition}; REQUIRE(instance.property_name() == name); REQUIRE(instance.property_priority() == priority); REQUIRE(instance.property_disposition() == disposition); @@ -50,7 +50,7 @@ namespace turns::core::tests SECTION("Can be constructed using factory") { - auto instance = participant::create(name, priority, disposition); + auto instance = Participant::create(name, priority, disposition); REQUIRE(instance->property_name() == name); REQUIRE(instance->property_priority() == priority); REQUIRE(instance->property_disposition() == disposition); @@ -60,7 +60,7 @@ namespace turns::core::tests SECTION("Can be constructed using JSON factory", "[json]") { - auto instance = participant::create(json); + auto instance = Participant::create(json); REQUIRE(instance->property_name() == name); REQUIRE(instance->property_priority() == priority); REQUIRE(instance->property_disposition() == disposition); @@ -75,7 +75,7 @@ namespace turns::core::tests auto constexpr priority = 10; auto constexpr disposition = disposition::hostile; - auto instance = participant{name, priority, disposition}; + auto instance = Participant{name, priority, disposition}; SECTION("Setting '::disposition' via proxy changes the 'disposition' value") { @@ -153,11 +153,11 @@ namespace turns::core::tests auto constexpr constructed_name = "Vana Thistletop"; auto constexpr constructed_priority = 17; auto constexpr constructed_disposition = disposition::friendly; - auto instance = participant{constructed_name, constructed_priority, constructed_disposition}; + auto instance = Participant{constructed_name, constructed_priority, constructed_disposition}; SECTION("can be created") { - REQUIRE(participant::create(constructed_name, constructed_priority, constructed_disposition)); + REQUIRE(Participant::create(constructed_name, constructed_priority, constructed_disposition)); } SECTION("allows access to its disposition") @@ -222,9 +222,9 @@ namespace turns::core::tests SECTION("can be compared with another participant") { - auto equivalent_instance = participant{"Equivalent", constructed_priority, constructed_disposition}; - auto lesser_instance = participant{"Lesser", constructed_priority - 1, constructed_disposition}; - auto greater_instance = participant{"Greater", constructed_priority + 1, constructed_disposition}; + auto equivalent_instance = Participant{"Equivalent", constructed_priority, constructed_disposition}; + auto lesser_instance = Participant{"Lesser", constructed_priority - 1, constructed_disposition}; + auto greater_instance = Participant{"Greater", constructed_priority + 1, constructed_disposition}; SECTION("yielding std::partial_ordering::equivalent for itself") { @@ -250,7 +250,7 @@ namespace turns::core::tests TEST_CASE("Serializing a participant") { - auto instance = participant::create("Participant #0", 17.2, disposition::friendly); + auto instance = Participant::create("Participant #0", 17.2, disposition::friendly); auto serialized = instance->serialize(); SECTION("the active state is serialized correctly") @@ -284,7 +284,7 @@ namespace turns::core::tests "is-active": true } )"); - auto instance = participant::create(serialized); + auto instance = Participant::create(serialized); SECTION("the active state is de-serialized correctly") { diff --git a/core/tests/turn_order.cpp b/core/tests/turn_order.cpp index b4958c5..a7a0be0 100644 --- a/core/tests/turn_order.cpp +++ b/core/tests/turn_order.cpp @@ -20,12 +20,12 @@ namespace turns::core::tests THEN("get_type() returns participant::get_type()") { - REQUIRE(instance->get_item_type() == participant::get_type()); + REQUIRE(instance->get_item_type() == Participant::get_type()); } THEN("get_typed_object(0) returns nullptr") { - REQUIRE(instance->get_typed_object<participant>(0) == nullptr); + REQUIRE(instance->get_typed_object<Participant>(0) == nullptr); } THEN("has_next() returns false") @@ -70,7 +70,7 @@ namespace turns::core::tests THEN("get_typed_object(0) returns a non-null pointer") { - REQUIRE(instance->get_typed_object<participant>(0) != nullptr); + REQUIRE(instance->get_typed_object<Participant>(0) != nullptr); } THEN("has_next() returns true") @@ -109,7 +109,7 @@ namespace turns::core::tests THEN("get_typed_object(0) still returns a non-null pointer") { - REQUIRE(instance->get_typed_object<participant>(0) != nullptr); + REQUIRE(instance->get_typed_object<Participant>(0) != nullptr); } THEN("has_next() still returns true") @@ -148,7 +148,7 @@ namespace turns::core::tests THEN("get_typed_object(0) still returns a non-null pointer") { - REQUIRE(instance->get_typed_object<participant>(0) != nullptr); + REQUIRE(instance->get_typed_object<Participant>(0) != nullptr); } THEN("has_next() still returns true") @@ -188,7 +188,7 @@ namespace turns::core::tests THEN("get_typed_object(0) still returns a non-null pointer") { - REQUIRE(instance->get_typed_object<participant>(0) != nullptr); + REQUIRE(instance->get_typed_object<Participant>(0) != nullptr); } THEN("has_next() still returns true") diff --git a/ui/include/turns/ui/participant_editor.hpp b/ui/include/turns/ui/participant_editor.hpp index 0b1e0f1..3dfd7fb 100644 --- a/ui/include/turns/ui/participant_editor.hpp +++ b/ui/include/turns/ui/participant_editor.hpp @@ -41,20 +41,20 @@ namespace turns::ui "priority", }; - explicit ParticipantEditor(Glib::RefPtr<core::participant> participant); + explicit ParticipantEditor(Glib::RefPtr<core::Participant> participant); [[nodiscard]] auto get_disposition() const -> core::disposition; [[nodiscard]] auto get_name() const -> Glib::ustring; - [[nodiscard]] auto get_participant() const -> Glib::RefPtr<core::participant>; + [[nodiscard]] auto get_participant() const -> Glib::RefPtr<core::Participant>; [[nodiscard]] auto get_priority() const -> double; auto set_disposition(core::disposition value) -> void; auto set_name(Glib::ustring const & value) -> void; - auto set_participant(Glib::RefPtr<core::participant> const & value) -> void; + auto set_participant(Glib::RefPtr<core::Participant> const & value) -> void; auto set_priority(double value) -> void; - [[nodiscard]] auto property_participant() -> Glib::PropertyProxy<Glib::RefPtr<core::participant>>; - [[nodiscard]] auto property_participant() const -> Glib::PropertyProxy_ReadOnly<Glib::RefPtr<core::participant>>; + [[nodiscard]] auto property_participant() -> Glib::PropertyProxy<Glib::RefPtr<core::Participant>>; + [[nodiscard]] auto property_participant() const -> Glib::PropertyProxy_ReadOnly<Glib::RefPtr<core::Participant>>; auto signal_finished() -> SignalFinishedType; @@ -71,7 +71,7 @@ namespace turns::ui Glib::RefPtr<Gtk::SignalListItemFactory> m_disposition_factory; Glib::RefPtr<Gtk::StringList> m_disposition_model; - Glib::Property<Glib::RefPtr<core::participant>> m_participant; + Glib::Property<Glib::RefPtr<core::Participant>> m_participant; SignalFinishedType m_signal_finished{}; }; diff --git a/ui/include/turns/ui/participant_row.hpp b/ui/include/turns/ui/participant_row.hpp index ed7b47c..561214b 100644 --- a/ui/include/turns/ui/participant_row.hpp +++ b/ui/include/turns/ui/participant_row.hpp @@ -27,7 +27,7 @@ namespace turns::ui "toggle_defeated", }; - ParticipantRow(Glib::RefPtr<core::participant> participant); + ParticipantRow(Glib::RefPtr<core::Participant> participant); auto delete_enabled() -> Glib::PropertyProxy<bool>; auto edit_enabled() -> Glib::PropertyProxy<bool>; diff --git a/ui/src/participant_editor.cpp b/ui/src/participant_editor.cpp index 0016c02..9c0e0f1 100644 --- a/ui/src/participant_editor.cpp +++ b/ui/src/participant_editor.cpp @@ -40,7 +40,7 @@ namespace turns::ui auto constexpr static TEMPLATE = "/ch/arknet/Turns/participant_editor.ui"; } // namespace - ParticipantEditor::ParticipantEditor(Glib::RefPtr<core::participant> participant) + ParticipantEditor::ParticipantEditor(Glib::RefPtr<core::Participant> participant) : Glib::ObjectBase{TYPE_NAME} , template_widget{TEMPLATE} , m_disposition{get_widget<Adwaita::ComboRow>("disposition")} @@ -88,7 +88,7 @@ namespace turns::ui return m_name->get_text(); } - auto ParticipantEditor::get_participant() const -> Glib::RefPtr<core::participant> + auto ParticipantEditor::get_participant() const -> Glib::RefPtr<core::Participant> { return m_participant.get_value(); } @@ -108,7 +108,7 @@ namespace turns::ui m_name->set_text(value); } - auto ParticipantEditor::set_participant(Glib::RefPtr<core::participant> const & value) -> void + auto ParticipantEditor::set_participant(Glib::RefPtr<core::Participant> const & value) -> void { m_participant.set_value(value); } @@ -118,12 +118,12 @@ namespace turns::ui m_priority->set_value(value); } - auto ParticipantEditor::property_participant() -> Glib::PropertyProxy<Glib::RefPtr<core::participant>> + auto ParticipantEditor::property_participant() -> Glib::PropertyProxy<Glib::RefPtr<core::Participant>> { return m_participant.get_proxy(); } - auto ParticipantEditor::property_participant() const -> Glib::PropertyProxy_ReadOnly<Glib::RefPtr<core::participant>> + auto ParticipantEditor::property_participant() const -> Glib::PropertyProxy_ReadOnly<Glib::RefPtr<core::Participant>> { return m_participant.get_proxy(); } diff --git a/ui/src/participant_row.cpp b/ui/src/participant_row.cpp index e5075cd..782182d 100644 --- a/ui/src/participant_row.cpp +++ b/ui/src/participant_row.cpp @@ -47,7 +47,7 @@ namespace turns::ui } } // namespace - ParticipantRow::ParticipantRow(Glib::RefPtr<core::participant> participant) + ParticipantRow::ParticipantRow(Glib::RefPtr<core::Participant> participant) : Glib::ObjectBase(TYPE_NAME) , template_widget{TEMPLATE} , m_delete{get_widget<Gtk::Button>("delete")} diff --git a/ui/src/tracker/actions.cpp b/ui/src/tracker/actions.cpp index 796345a..08d321a 100644 --- a/ui/src/tracker/actions.cpp +++ b/ui/src/tracker/actions.cpp @@ -62,7 +62,7 @@ namespace turns::ui auto Tracker::edit_participant(Glib::VariantBase param) -> void { auto index = Glib::VariantBase::cast_dynamic<Glib::Variant<int>>(param); - auto participant = m_turn_order->get_typed_object<core::participant>(index.get()); + auto participant = m_turn_order->get_typed_object<core::Participant>(index.get()); auto dialog = Gtk::make_managed<ParticipantEditor>(participant); dialog->signal_finished().connect([participant](auto n, auto p, auto d) { participant->property_name() = n; diff --git a/ui/src/turn_order_view.cpp b/ui/src/turn_order_view.cpp index d1be0d4..08fdf5d 100644 --- a/ui/src/turn_order_view.cpp +++ b/ui/src/turn_order_view.cpp @@ -47,7 +47,7 @@ namespace turns::ui auto TurnOrderView::handle_create_row(Glib::RefPtr<Glib::Object> const item) -> Gtk::Widget * { - auto participant = std::dynamic_pointer_cast<core::participant>(item); + auto participant = std::dynamic_pointer_cast<core::Participant>(item); auto row = Gtk::make_managed<ParticipantRow>(participant); Glib::Binding::bind_property(m_model->is_running(), diff --git a/ui/tests/participant_row.cpp b/ui/tests/participant_row.cpp index 920858b..6e5319f 100644 --- a/ui/tests/participant_row.cpp +++ b/ui/tests/participant_row.cpp @@ -18,12 +18,12 @@ namespace turns::ui::tests { SECTION("can be created without a participant") { - REQUIRE(std::make_shared<ParticipantRow>(Glib::RefPtr<core::participant>{})); + REQUIRE(std::make_shared<ParticipantRow>(Glib::RefPtr<core::Participant>{})); } SECTION("can be created with a participant") { - REQUIRE(std::make_shared<ParticipantRow>(core::participant::create("Tazmyla Fireforge", 13, core::disposition::secret))); + REQUIRE(std::make_shared<ParticipantRow>(core::Participant::create("Tazmyla Fireforge", 13, core::disposition::secret))); } } |
