From 71fe1d395a3c1d94dac68469826118e357f7086d Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 9 May 2025 10:48:30 +0200 Subject: core: rename turn_order to TurnOderModel --- core/include/turns/core/fwd.hpp | 2 +- core/include/turns/core/turn_order.hpp | 102 --------------------------- core/include/turns/core/turn_order_model.hpp | 102 +++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 103 deletions(-) delete mode 100644 core/include/turns/core/turn_order.hpp create mode 100644 core/include/turns/core/turn_order_model.hpp (limited to 'core/include') 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.hpp deleted file mode 100644 index 030f4c9..0000000 --- a/core/include/turns/core/turn_order.hpp +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef TURNS_CORE_TURN_ORDER_HPP -#define TURNS_CORE_TURN_ORDER_HPP - -#include "turns/core/fwd.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -namespace turns::core -{ - - struct turn_order : Gio::ListModel, - Glib::Object - { - using value_type = Glib::RefPtr; - using container_type = std::vector; - using iterator = container_type::iterator; - using const_iterator = container_type::const_iterator; - - using active_participant_type = unsigned int; - using is_empty_type = bool; - using has_next_type = bool; - using has_previous_type = bool; - using is_running_type = bool; - using progress_type = double; - using round_number_type = unsigned int; - using skip_defeated_type = bool; - - auto static constexpr invalid_participant_index = std::numeric_limits::max(); - auto static constexpr invalid_round_number = std::numeric_limits::max(); - - /** Life-time */ - turn_order(); - - auto static create() -> Glib::RefPtr; - auto static create(nlohmann::json const & from) -> Glib::RefPtr; - - /** Properties */ - auto is_empty() const -> Glib::PropertyProxy_ReadOnly; - auto has_next() const -> Glib::PropertyProxy_ReadOnly; - auto has_previous() const -> Glib::PropertyProxy_ReadOnly; - auto is_running() const -> Glib::PropertyProxy_ReadOnly; - auto progress() const -> Glib::PropertyProxy_ReadOnly; - auto round_number() const -> Glib::PropertyProxy_ReadOnly; - auto skip_defeated() -> Glib::PropertyProxy; - - /** Element Modifications */ - auto add(Glib::ustring const & name, float priority, Disposition disposition) -> void; - auto clear() -> void; - auto remove(unsigned index) -> void; - - /** Turn Modification */ - auto next() -> void; - auto previous() -> void; - auto start() -> void; - auto stop() -> void; - - /** Serialization */ - auto load(nlohmann::json const & from) -> void; - auto serialize() -> nlohmann::json; - - private: - explicit turn_order(nlohmann::json const & from); - - auto get_item_type_vfunc() -> GType override; - auto get_n_items_vfunc() -> unsigned override; - auto get_item_vfunc(unsigned position) -> void * override; - - /** Signal handlers */ - auto handle_priority_changed(value_type entry) -> void; - - /** Data management */ - auto find(value_type entry) const -> const_iterator; - auto insert(value_type entry) -> const_iterator; - - container_type m_data{}; - std::optional m_active{}; - - Glib::Property m_has_next{*this, "has-next", false}; - Glib::Property m_has_previous{*this, "has-previous", false}; - Glib::Property m_is_empty{*this, "is-empty", true}; - Glib::Property m_is_running{*this, "is-running", false}; - Glib::Property m_progress{*this, "progress", 0.0}; - Glib::Property m_round_number{*this, "round-number", invalid_round_number}; - Glib::Property m_skip_defeated{*this, "skip-defeated", false}; - }; - -} // namespace turns::core - -#endif \ No newline at end of file diff --git a/core/include/turns/core/turn_order_model.hpp b/core/include/turns/core/turn_order_model.hpp new file mode 100644 index 0000000..7d9947d --- /dev/null +++ b/core/include/turns/core/turn_order_model.hpp @@ -0,0 +1,102 @@ +#ifndef TURNS_CORE_TURN_ORDER_MODEL_HPP +#define TURNS_CORE_TURN_ORDER_MODEL_HPP + +#include "turns/core/fwd.hpp" + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +namespace turns::core +{ + + struct TurnOderModel : Gio::ListModel, + Glib::Object + { + using value_type = Glib::RefPtr; + using container_type = std::vector; + using iterator = container_type::iterator; + using const_iterator = container_type::const_iterator; + + using active_participant_type = unsigned int; + using is_empty_type = bool; + using has_next_type = bool; + using has_previous_type = bool; + using is_running_type = bool; + using progress_type = double; + using round_number_type = unsigned int; + using skip_defeated_type = bool; + + auto static constexpr invalid_participant_index = std::numeric_limits::max(); + auto static constexpr invalid_round_number = std::numeric_limits::max(); + + /** Life-time */ + TurnOderModel(); + + auto static create() -> Glib::RefPtr; + auto static create(nlohmann::json const & from) -> Glib::RefPtr; + + /** Properties */ + auto is_empty() const -> Glib::PropertyProxy_ReadOnly; + auto has_next() const -> Glib::PropertyProxy_ReadOnly; + auto has_previous() const -> Glib::PropertyProxy_ReadOnly; + auto is_running() const -> Glib::PropertyProxy_ReadOnly; + auto progress() const -> Glib::PropertyProxy_ReadOnly; + auto round_number() const -> Glib::PropertyProxy_ReadOnly; + auto skip_defeated() -> Glib::PropertyProxy; + + /** Element Modifications */ + auto add(Glib::ustring const & name, float priority, Disposition disposition) -> void; + auto clear() -> void; + auto remove(unsigned index) -> void; + + /** Turn Modification */ + auto next() -> void; + auto previous() -> void; + auto start() -> void; + auto stop() -> void; + + /** Serialization */ + auto load(nlohmann::json const & from) -> void; + auto serialize() -> nlohmann::json; + + private: + explicit TurnOderModel(nlohmann::json const & from); + + auto get_item_type_vfunc() -> GType override; + auto get_n_items_vfunc() -> unsigned override; + auto get_item_vfunc(unsigned position) -> void * override; + + /** Signal handlers */ + auto handle_priority_changed(value_type entry) -> void; + + /** Data management */ + auto find(value_type entry) const -> const_iterator; + auto insert(value_type entry) -> const_iterator; + + container_type m_data{}; + std::optional m_active{}; + + Glib::Property m_has_next{*this, "has-next", false}; + Glib::Property m_has_previous{*this, "has-previous", false}; + Glib::Property m_is_empty{*this, "is-empty", true}; + Glib::Property m_is_running{*this, "is-running", false}; + Glib::Property m_progress{*this, "progress", 0.0}; + Glib::Property m_round_number{*this, "round-number", invalid_round_number}; + Glib::Property m_skip_defeated{*this, "skip-defeated", false}; + }; + +} // namespace turns::core + +#endif \ No newline at end of file -- cgit v1.2.3