summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2025-05-09 10:48:30 +0200
committerFelix Morgner <felix.morgner@gmail.com>2025-05-09 10:48:30 +0200
commit71fe1d395a3c1d94dac68469826118e357f7086d (patch)
tree5db04ceaf4bf80c3f9566b26236f3d6f17266be2
parent87c6607602e969d94ed8b8f97bb45f416e37b22d (diff)
downloadturns-71fe1d395a3c1d94dac68469826118e357f7086d.tar.xz
turns-71fe1d395a3c1d94dac68469826118e357f7086d.zip
core: rename turn_order to TurnOderModel
-rw-r--r--core/CMakeLists.txt4
-rw-r--r--core/include/turns/core/fwd.hpp2
-rw-r--r--core/include/turns/core/turn_order_model.hpp (renamed from core/include/turns/core/turn_order.hpp)14
-rw-r--r--core/src/init.cpp4
-rw-r--r--core/src/turn_order_model.cpp (renamed from core/src/turn_order.cpp)66
-rw-r--r--core/tests/turn_order_bugs.cpp4
-rw-r--r--core/tests/turn_order_model.cpp (renamed from core/tests/turn_order.cpp)14
-rw-r--r--ui/include/turns/ui/tracker.hpp4
-rw-r--r--ui/include/turns/ui/turn_order_view.hpp4
-rw-r--r--ui/src/tracker.cpp12
10 files changed, 64 insertions, 64 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index b52519f..7b223d5 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -5,7 +5,7 @@ add_library("core"
"src/init.cpp"
"src/participant.cpp"
"src/settings.cpp"
- "src/turn_order.cpp"
+ "src/turn_order_model.cpp"
)
add_library("turns::core" ALIAS "core")
@@ -52,7 +52,7 @@ add_executable("core-tests"
"tests/disposition.cpp"
"tests/participant.cpp"
"tests/turn_order_bugs.cpp"
- "tests/turn_order.cpp"
+ "tests/turn_order_model.cpp"
)
target_link_libraries("core-tests" PRIVATE
diff --git a/core/include/turns/core/fwd.hpp b/core/include/turns/core/fwd.hpp
index 48380e3..c006084 100644
--- a/core/include/turns/core/fwd.hpp
+++ b/core/include/turns/core/fwd.hpp
@@ -8,7 +8,7 @@ namespace turns::core
enum struct Disposition : std::uint8_t;
struct Participant;
- struct turn_order;
+ struct TurnOderModel;
} // namespace turns::core
#endif \ No newline at end of file
diff --git a/core/include/turns/core/turn_order.hpp b/core/include/turns/core/turn_order_model.hpp
index 030f4c9..7d9947d 100644
--- a/core/include/turns/core/turn_order.hpp
+++ b/core/include/turns/core/turn_order_model.hpp
@@ -1,5 +1,5 @@
-#ifndef TURNS_CORE_TURN_ORDER_HPP
-#define TURNS_CORE_TURN_ORDER_HPP
+#ifndef TURNS_CORE_TURN_ORDER_MODEL_HPP
+#define TURNS_CORE_TURN_ORDER_MODEL_HPP
#include "turns/core/fwd.hpp"
@@ -21,7 +21,7 @@
namespace turns::core
{
- struct turn_order : Gio::ListModel,
+ struct TurnOderModel : Gio::ListModel,
Glib::Object
{
using value_type = Glib::RefPtr<Participant>;
@@ -42,10 +42,10 @@ namespace turns::core
auto static constexpr invalid_round_number = std::numeric_limits<round_number_type>::max();
/** Life-time */
- turn_order();
+ TurnOderModel();
- auto static create() -> Glib::RefPtr<turn_order>;
- auto static create(nlohmann::json const & from) -> Glib::RefPtr<turn_order>;
+ auto static create() -> Glib::RefPtr<TurnOderModel>;
+ auto static create(nlohmann::json const & from) -> Glib::RefPtr<TurnOderModel>;
/** Properties */
auto is_empty() const -> Glib::PropertyProxy_ReadOnly<is_empty_type>;
@@ -72,7 +72,7 @@ namespace turns::core
auto serialize() -> nlohmann::json;
private:
- explicit turn_order(nlohmann::json const & from);
+ explicit TurnOderModel(nlohmann::json const & from);
auto get_item_type_vfunc() -> GType override;
auto get_n_items_vfunc() -> unsigned override;
diff --git a/core/src/init.cpp b/core/src/init.cpp
index 3434f91..4f67817 100644
--- a/core/src/init.cpp
+++ b/core/src/init.cpp
@@ -2,7 +2,7 @@
#include "turns/core/disposition.hpp"
#include "turns/core/participant.hpp"
-#include "turns/core/turn_order.hpp"
+#include "turns/core/turn_order_model.hpp"
#include <glib-object.h>
@@ -12,7 +12,7 @@ namespace turns::core
auto register_types() -> void
{
static_cast<void>(Participant{});
- static_cast<void>(turn_order{});
+ static_cast<void>(TurnOderModel{});
g_type_ensure(Glib::Value<Disposition>::value_type());
}
diff --git a/core/src/turn_order.cpp b/core/src/turn_order_model.cpp
index 669f746..e430fed 100644
--- a/core/src/turn_order.cpp
+++ b/core/src/turn_order_model.cpp
@@ -1,4 +1,4 @@
-#include "turns/core/turn_order.hpp"
+#include "turns/core/turn_order_model.hpp"
#include "turns/core/disposition.hpp"
#include "turns/core/json_ext.hpp"
@@ -39,71 +39,71 @@ namespace turns::core
/** Construction */
- turn_order::turn_order()
- : Glib::ObjectBase{typeid(turn_order)}
+ TurnOderModel::TurnOderModel()
+ : Glib::ObjectBase{typeid(TurnOderModel)}
, Gio::ListModel{}
{
}
- turn_order::turn_order(nlohmann::json const & from)
- : turn_order{}
+ TurnOderModel::TurnOderModel(nlohmann::json const & from)
+ : TurnOderModel{}
{
load(from);
}
- auto turn_order::create() -> Glib::RefPtr<turn_order>
+ auto TurnOderModel::create() -> Glib::RefPtr<TurnOderModel>
{
- return Glib::make_refptr_for_instance(new turn_order{});
+ return Glib::make_refptr_for_instance(new TurnOderModel{});
}
- auto turn_order::create(nlohmann::json const & from) -> Glib::RefPtr<turn_order>
+ auto TurnOderModel::create(nlohmann::json const & from) -> Glib::RefPtr<TurnOderModel>
{
- return Glib::make_refptr_for_instance(new turn_order{from});
+ return Glib::make_refptr_for_instance(new TurnOderModel{from});
}
/** Queries */
- auto turn_order::is_empty() const -> Glib::PropertyProxy_ReadOnly<is_empty_type>
+ auto TurnOderModel::is_empty() const -> Glib::PropertyProxy_ReadOnly<is_empty_type>
{
return m_is_empty.get_proxy();
}
- auto turn_order::has_next() const -> Glib::PropertyProxy_ReadOnly<has_next_type>
+ auto TurnOderModel::has_next() const -> Glib::PropertyProxy_ReadOnly<has_next_type>
{
return m_has_next.get_proxy();
}
- auto turn_order::has_previous() const -> Glib::PropertyProxy_ReadOnly<has_previous_type>
+ auto TurnOderModel::has_previous() const -> Glib::PropertyProxy_ReadOnly<has_previous_type>
{
return m_has_previous.get_proxy();
}
- auto turn_order::is_running() const -> Glib::PropertyProxy_ReadOnly<is_running_type>
+ auto TurnOderModel::is_running() const -> Glib::PropertyProxy_ReadOnly<is_running_type>
{
return m_is_running.get_proxy();
}
- auto turn_order::progress() const -> Glib::PropertyProxy_ReadOnly<progress_type>
+ auto TurnOderModel::progress() const -> Glib::PropertyProxy_ReadOnly<progress_type>
{
return m_progress.get_proxy();
}
- auto turn_order::round_number() const -> Glib::PropertyProxy_ReadOnly<round_number_type>
+ auto TurnOderModel::round_number() const -> Glib::PropertyProxy_ReadOnly<round_number_type>
{
return m_round_number.get_proxy();
}
- auto turn_order::skip_defeated() -> Glib::PropertyProxy<skip_defeated_type>
+ auto TurnOderModel::skip_defeated() -> Glib::PropertyProxy<skip_defeated_type>
{
return m_skip_defeated.get_proxy();
}
/** Modifiers */
- auto turn_order::add(Glib::ustring const & name, float priority, Disposition disposition) -> void
+ auto TurnOderModel::add(Glib::ustring const & name, float priority, Disposition disposition) -> void
{
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));
+ entry->property_priority().signal_changed().connect(sigc::bind(sigc::mem_fun(*this, &TurnOderModel::handle_priority_changed), entry));
auto position = std::distance(m_data.cbegin(), insert(entry));
items_changed(position, 0, 1);
@@ -114,7 +114,7 @@ namespace turns::core
}
}
- auto turn_order::clear() -> void
+ auto TurnOderModel::clear() -> void
{
m_is_running = false;
m_is_empty = true;
@@ -129,7 +129,7 @@ namespace turns::core
items_changed(0, old_size, 0);
}
- auto turn_order::next() -> void
+ auto TurnOderModel::next() -> void
{
auto old_active = *m_active;
m_active = m_active.transform([this](auto index) { return (index + 1) % get_n_items(); });
@@ -146,7 +146,7 @@ namespace turns::core
}
}
- auto turn_order::previous() -> void
+ auto TurnOderModel::previous() -> void
{
if (!(m_has_previous && m_is_running))
{
@@ -168,7 +168,7 @@ namespace turns::core
}
}
- auto turn_order::remove(unsigned index) -> void
+ auto TurnOderModel::remove(unsigned index) -> void
{
if (index >= get_n_items())
{
@@ -186,7 +186,7 @@ namespace turns::core
}
}
- auto turn_order::start() -> void
+ auto TurnOderModel::start() -> void
{
if (!m_active)
{
@@ -202,14 +202,14 @@ namespace turns::core
m_progress = (static_cast<float>(*m_active) + 1) / get_n_items();
}
- auto turn_order::stop() -> void
+ auto TurnOderModel::stop() -> void
{
m_is_running = false;
m_progress = 0;
}
/** Serialization */
- auto turn_order::load(nlohmann::json const & from) -> void
+ auto TurnOderModel::load(nlohmann::json const & from) -> void
{
auto old_size = get_n_items();
@@ -222,7 +222,7 @@ namespace turns::core
auto factory = [](auto s) {
return Participant::create(s);
};
- auto inserter = std::bind(&turn_order::insert, this, _1);
+ auto inserter = std::bind(&TurnOderModel::insert, this, _1);
std::ranges::for_each(participants | std::views::transform(factory), inserter);
auto active = std::ranges::find_if(m_data, [](auto participant) { return participant->property_is_active(); });
@@ -240,7 +240,7 @@ namespace turns::core
items_changed(0, old_size, get_n_items());
}
- auto turn_order::serialize() -> nlohmann::json
+ auto TurnOderModel::serialize() -> nlohmann::json
{
auto serialized = nlohmann::json{};
if (m_round_number != invalid_round_number)
@@ -254,17 +254,17 @@ namespace turns::core
/** ListModel implementation */
- auto turn_order::get_item_type_vfunc() -> GType
+ auto TurnOderModel::get_item_type_vfunc() -> GType
{
return Participant::get_type();
}
- auto turn_order::get_n_items_vfunc() -> unsigned
+ auto TurnOderModel::get_n_items_vfunc() -> unsigned
{
return m_data.size();
}
- auto turn_order::get_item_vfunc(unsigned position) -> void *
+ auto TurnOderModel::get_item_vfunc(unsigned position) -> void *
{
if (position >= get_n_items())
{
@@ -277,7 +277,7 @@ namespace turns::core
/** Signal handlers */
- auto turn_order::handle_priority_changed(value_type entry) -> void
+ auto TurnOderModel::handle_priority_changed(value_type entry) -> void
{
auto original_position = find(entry);
auto original_index = distance(m_data.cbegin(), original_position);
@@ -299,12 +299,12 @@ namespace turns::core
/** Data management */
- auto turn_order::find(value_type entry) const -> const_iterator
+ auto TurnOderModel::find(value_type entry) const -> const_iterator
{
return std::ranges::find(m_data, entry);
}
- auto turn_order::insert(value_type entry) -> const_iterator
+ auto TurnOderModel::insert(value_type entry) -> const_iterator
{
return m_data.insert(std::ranges::upper_bound(m_data, entry, comparator), entry);
}
diff --git a/core/tests/turn_order_bugs.cpp b/core/tests/turn_order_bugs.cpp
index a79e9b4..7bfde78 100644
--- a/core/tests/turn_order_bugs.cpp
+++ b/core/tests/turn_order_bugs.cpp
@@ -1,5 +1,5 @@
#include "turns/core/disposition.hpp"
-#include "turns/core/turn_order.hpp"
+#include "turns/core/turn_order_model.hpp"
#include <catch2/catch_test_macros.hpp>
@@ -17,7 +17,7 @@ namespace turns::core::tests
{
GIVEN("a non-empty turn_order")
{
- auto instance = turn_order::create();
+ auto instance = TurnOderModel::create();
instance->add("A", 0, Disposition::Neutral);
diff --git a/core/tests/turn_order.cpp b/core/tests/turn_order_model.cpp
index a7633cd..1cd3633 100644
--- a/core/tests/turn_order.cpp
+++ b/core/tests/turn_order_model.cpp
@@ -1,4 +1,4 @@
-#include "turns/core/turn_order.hpp"
+#include "turns/core/turn_order_model.hpp"
#include "turns/core/disposition.hpp"
#include "turns/core/participant.hpp"
@@ -17,7 +17,7 @@ namespace turns::core::tests
{
GIVEN("an empty turn_order")
{
- auto instance = turn_order::create();
+ auto instance = TurnOderModel::create();
THEN("get_n_items() returns 0")
{
@@ -56,14 +56,14 @@ namespace turns::core::tests
THEN("round_number() returns invalid_round_number")
{
- REQUIRE(instance->round_number() == turn_order::invalid_round_number);
+ REQUIRE(instance->round_number() == TurnOderModel::invalid_round_number);
}
}
}
SCENARIO("Adding participants")
{
- auto instance = turn_order::create();
+ auto instance = TurnOderModel::create();
GIVEN("a participant has been added to a turn_order")
{
@@ -101,7 +101,7 @@ namespace turns::core::tests
THEN("round_number() returns invalid_round_number")
{
- REQUIRE(instance->round_number() == turn_order::invalid_round_number);
+ REQUIRE(instance->round_number() == TurnOderModel::invalid_round_number);
}
WHEN("the turn_order is start()ed")
@@ -230,7 +230,7 @@ namespace turns::core::tests
{
GIVEN("an empty turn order")
{
- auto instance = turn_order{};
+ auto instance = TurnOderModel{};
CHECK(instance.is_empty());
WHEN("loading a serialized turn order with one named participant")
@@ -284,7 +284,7 @@ namespace turns::core::tests
{
GIVEN("A turn order with 3 participants (A,B,C) of priorities 100, 0, and -100 respectively")
{
- auto instance = turn_order{};
+ auto instance = TurnOderModel{};
instance.add("A", 100, Disposition::Friendly);
instance.add("B", 0, Disposition::Friendly);
diff --git a/ui/include/turns/ui/tracker.hpp b/ui/include/turns/ui/tracker.hpp
index 58ed84a..2e3adf5 100644
--- a/ui/include/turns/ui/tracker.hpp
+++ b/ui/include/turns/ui/tracker.hpp
@@ -1,7 +1,7 @@
#ifndef TURNS_UI_TRACKER_HPP
#define TURNS_UI_TRACKER_HPP
-#include "turns/core/turn_order.hpp"
+#include "turns/core/turn_order_model.hpp"
#include "turns/ui/template_widget.hpp"
#include "turns/ui/turn_order_view.hpp"
@@ -87,7 +87,7 @@ namespace turns::ui
Gtk::Stack * m_stack;
Gtk::Button * m_start;
Adwaita::WindowTitle * m_title;
- Glib::RefPtr<core::turn_order> m_turn_order;
+ Glib::RefPtr<core::TurnOderModel> m_turn_order;
TurnOrderView * m_turn_order_view;
Glib::RefPtr<Gio::Settings> m_settings{};
Glib::PropertyProxy<Glib::ustring> m_subtitle;
diff --git a/ui/include/turns/ui/turn_order_view.hpp b/ui/include/turns/ui/turn_order_view.hpp
index f026854..8dae4e4 100644
--- a/ui/include/turns/ui/turn_order_view.hpp
+++ b/ui/include/turns/ui/turn_order_view.hpp
@@ -2,7 +2,7 @@
#define TURNS_UI_TURN_ORDER_VIEW_HPP
#include "turns/core/fwd.hpp"
-#include "turns/core/turn_order.hpp"
+#include "turns/core/turn_order_model.hpp"
#include "turns/ui/template_widget.hpp"
#include <glibmm/object.h>
@@ -19,7 +19,7 @@ namespace turns::ui
{
struct TurnOrderView : template_widget<TurnOrderView, Gtk::Box>
{
- using model_type = core::turn_order;
+ using model_type = core::TurnOderModel;
auto constexpr inline static children = std::array{
"progress",
diff --git a/ui/src/tracker.cpp b/ui/src/tracker.cpp
index cb4d79c..d67a6e0 100644
--- a/ui/src/tracker.cpp
+++ b/ui/src/tracker.cpp
@@ -1,7 +1,7 @@
#include "turns/ui/tracker.hpp"
#include "turns/core/settings.hpp"
-#include "turns/core/turn_order.hpp"
+#include "turns/core/turn_order_model.hpp"
#include "turns/lang/messages.hpp"
#include "turns/ui/template_widget.hpp"
#include "turns/ui/turn_order_view.hpp"
@@ -71,7 +71,7 @@ namespace turns::ui
, m_stack{get_widget<Gtk::Stack>("stack")}
, m_start{get_widget<Gtk::Button>("start")}
, m_title{get_widget<Adwaita::WindowTitle>("title")}
- , m_turn_order{core::turn_order::create()}
+ , m_turn_order{core::TurnOderModel::create()}
, m_turn_order_view{Gtk::make_managed<TurnOrderView>(m_turn_order)}
, m_settings{std::move(settings)}
, m_subtitle{m_title->property_subtitle()}
@@ -115,7 +115,7 @@ namespace turns::ui
// win.clear
// depends-on: turn_order:is_empty == false
{
- auto action = add_action("clear", sigc::mem_fun(*m_turn_order, &core::turn_order::clear));
+ auto action = add_action("clear", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::clear));
Glib::Binding::bind_property(m_turn_order->is_empty(),
action->property_enabled(),
@@ -125,7 +125,7 @@ namespace turns::ui
// win.next
// depends-on: turn_order:state == running
{
- auto action = add_action("next", sigc::mem_fun(*m_turn_order, &core::turn_order::next));
+ auto action = add_action("next", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::next));
Glib::Binding::bind_property(m_turn_order->is_running(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE);
}
@@ -133,7 +133,7 @@ namespace turns::ui
// win.previous
// depends-on: turn_order:has_previous == true
{
- auto action = add_action("previous", sigc::mem_fun(*m_turn_order, &core::turn_order::previous));
+ auto action = add_action("previous", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::previous));
Glib::Binding::bind_property(m_turn_order->has_previous(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE);
}
@@ -141,7 +141,7 @@ namespace turns::ui
// win.start
// depends-on: turn_order:is_empty == false
{
- auto action = add_action("start", sigc::mem_fun(*m_turn_order, &core::turn_order::start));
+ auto action = add_action("start", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::start));
Glib::Binding::bind_property(m_turn_order->is_empty(),
action->property_enabled(),