summaryrefslogtreecommitdiffhomepage
path: root/entity/erased-constraints.hpp
blob: c77d8166da1471cbda2fc56a20dc96a08e2b68d1 (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
#pragma once
#include <Corrade/Containers/StringView.h>
#include <Magnum/Math/Vector4.h>

namespace floormat::entities::erased_constraints {

struct range final
{
    using U = std::size_t;
    using I = std::make_signed_t<U>;
    enum type_ : unsigned char {
        type_none,
        type_float, type_uint, type_int,
        type_float4, type_uint4, type_int4,
    };
    union element {
        float f;
        U u;
        I i;
        Math::Vector4<float> f4;
        Math::Vector4<U> u4;
        Math::Vector4<I> i4;
    };

    element min {.i = 0}, max {.i = 0};
    type_ type = type_none;

    template<typename T> std::pair<T, T> convert() const;
    friend bool operator==(const range& a, const range& b);
};

struct max_length final {
    std::size_t value = std::size_t(-1);
    constexpr operator std::size_t() const { return value; }
};

struct group final {
    StringView group_name;
    constexpr operator StringView() const { return group_name; }
    constexpr group() = default;
    constexpr group(StringView name) : group_name{name} {}
};

} // namespace floormat::entities::erased_constraints