summaryrefslogtreecommitdiffstats
path: root/engine/include/core/priority.hpp
blob: 773b2f7cd447bee46d19cd0e8e5700175f1cd126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include <set>

namespace flat {
    namespace core {
        enum class priority_t : unsigned  {
            max = 0,
            higher = 1,
            high = 2,
            none = 3,
            low = 4,
            lower = 5,
            min = 6,
        };

        class prioritized {
        private:
            const priority_t m_priority;

        public:
            prioritized(priority_t priority = priority_t::none)
                : m_priority(priority) {}

            const priority_t priority() const {
                return m_priority;
            }
        };       

        struct prioritize {
            bool operator()(const prioritized& lhs, const prioritized& rhs) {
                return lhs.priority() < rhs.priority();
            }

            bool operator()(const prioritized * const& lhs, const prioritized * const& rhs) {
                return lhs->priority() < rhs->priority();
            }
        };

        template<typename Prioritized>
        using queue = std::multiset<Prioritized, prioritize>;
    }
}