diff options
Diffstat (limited to 'engine/include/core/priority.hpp')
-rw-r--r-- | engine/include/core/priority.hpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/engine/include/core/priority.hpp b/engine/include/core/priority.hpp new file mode 100644 index 0000000..7a23803 --- /dev/null +++ b/engine/include/core/priority.hpp @@ -0,0 +1,63 @@ +#pragma once + +#include <set> + +namespace flat +{ + namespace core + { + enum class prior_t : unsigned + { + max = 0, + higher = 1, + high = 2, + none = 3, + low = 4, + lower = 5, + min = 6, + }; + + class prioritized + { + const prior_t m_priority; + + public: + + prioritized(prior_t m_priority = prior_t::none) : m_priority(m_priority) {} + + const prior priority() const + { + return m_priority; + } + }; + + struct prior_criteria + { + bool operator()(const prioritized& a, const prioritized& b) const + { + return a.priority() < b.priority(); + } + }; + + /* Compiler will complain if don't pass a non prioritized object */ + + template <class T> + using prior_set = std::set<T, prior_criteria>; + + + /* Equivalent but with pointers */ + + struct prior_ptr_criteria + { + bool operator()(const prioritized* a, const prioritized* b) const + { + return a->priority() < b->priority(); + } + }; + + /* Compiler will complain if don't pass a non prioritized object */ + + template <class T> + using prior_ptr_set = std::set<T*, prior_criteria>; + } +}; |