diff options
Diffstat (limited to 'domain/src/turn_order.cpp')
| -rw-r--r-- | domain/src/turn_order.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/domain/src/turn_order.cpp b/domain/src/turn_order.cpp new file mode 100644 index 0000000..8b9e042 --- /dev/null +++ b/domain/src/turn_order.cpp @@ -0,0 +1,40 @@ +#include "turns/domain/turn_order.hpp" + +namespace turns::domain +{ + + namespace + { + auto constexpr comparator = [](auto lhs, auto rhs){ + auto result = *lhs <=> *rhs; + if(result == std::partial_ordering::equivalent || result == std::partial_ordering::unordered) + { + return 0; + } + else if(result == std::partial_ordering::less) + { + return 1; + } + return -1; + }; + } + + auto turn_order::create() -> Glib::RefPtr<turn_order> + { + return Glib::make_refptr_for_instance(new turn_order{}); + } + + auto turn_order::append(Glib::ustring const & name, float order_value) -> turn_order & + { + auto participant = participant::create(name, order_value); + participant->property_order_value().signal_changed().connect([this] { sort(); }); + insert_sorted(participant, comparator); + return *this; + } + + auto turn_order::sort() -> void + { + super::sort(comparator); + } + +} // namespace turns::domain
\ No newline at end of file |
