diff options
Diffstat (limited to 'core/src/participant.cpp')
| -rw-r--r-- | core/src/participant.cpp | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/core/src/participant.cpp b/core/src/participant.cpp deleted file mode 100644 index ff2c2fb..0000000 --- a/core/src/participant.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "turns/core/participant.hpp" - -#include "turns/core/disposition.hpp" -#include "turns/core/json_ext.hpp" - -#include <glibmm/object.h> -#include <glibmm/objectbase.h> -#include <glibmm/refptr.h> -#include <glibmm/ustring.h> - -#include <nlohmann/json.hpp> - -#include <compare> -#include <string> - -namespace turns::core -{ - 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}); - } - - auto Participant::create(nlohmann::json const & serialized) -> Glib::RefPtr<Participant> - { - auto disposition = serialized.value("disposition", Disposition::Neutral); - auto priority = serialized.value("priority", 0.0f); - auto name = serialized.value("name", std::string{}); - - auto instance = create(name, priority, disposition); - instance->property_is_active() = serialized.value("is-active", false); - instance->property_is_defeated() = serialized.value("is-defeated", false); - ; - - return instance; - } - - Participant::Participant() - : Glib::ObjectBase{"TurnsParticipant"} - , Glib::Object{} - { - } - - 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 - { - return m_priority <=> other.m_priority; - } - - auto Participant::get_disposition() const -> Disposition - { - return m_disposition.get_value(); - } - - auto Participant::get_is_active() const -> bool - { - return m_is_active.get_value(); - } - - auto Participant::get_is_defeated() const -> bool - { - return m_is_defeated.get_value(); - } - - auto Participant::get_name() const -> Glib::ustring - { - return m_name.get_value(); - } - - auto Participant::get_priority() const -> float - { - return m_priority.get_value(); - } - - auto Participant::set_disposition(Disposition value) -> void - { - return m_disposition.set_value(value); - } - - auto Participant::set_is_active(bool value) -> void - { - return m_is_active.set_value(value); - } - - auto Participant::set_is_defeated(bool value) -> void - { - return m_is_defeated.set_value(value); - } - - auto Participant::set_name(Glib::ustring const & value) -> void - { - return m_name.set_value(value); - } - - auto Participant::set_priority(float value) -> void - { - return m_priority.set_value(value); - } - - auto Participant::serialize() -> nlohmann::json - { - return nlohmann::json{ - {"disposition", m_disposition}, - {"is-active", m_is_active }, - {"is-defeated", m_is_defeated}, - {"name", m_name }, - {"priority", m_priority }, - }; - } -} // namespace turns::core
\ No newline at end of file |
