IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
tasks
public
ice
task_flags.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/task_types.hxx
>
6
7
namespace
ice
8
{
9
11
template
<
typename
Enum>
12
static
constexpr
bool
Constant_IsTaskFlagsEnumeration
=
false
;
13
15
using
TaskFlagBaseType
=
ice::u32
;
16
18
static
constexpr
TaskFlagBaseType
Constant_TaskFlagLongValue
= 0x1;
19
static
constexpr
TaskFlagBaseType
Constant_TaskFlagLowPrioValue
= 0x2;
20
static
constexpr
TaskFlagBaseType
Constant_TaskFlagNormalPrioValue
= 0x4;
21
static
constexpr
TaskFlagBaseType
Constant_TaskFlagHighPrioValue
= 0x8;
22
23
template
<
typename
Enum>
24
concept
TaskFlagType
=
ice::FlagType<Enum>
&&
ice::FlagAllValue<Enum>
// Ensure it's a IceShard flag enabled type
25
// Ensure the flag type is manually enabled and matches the expected base type
26
&&
Constant_IsTaskFlagsEnumeration<Enum>
&& std::is_same_v<ice::TaskFlagBaseType, std::underlying_type_t<Enum>>
27
// Ensure the specified names are part of the enum.
28
&&
requires
(Enum t) {
29
{ Enum::Long } -> std::convertible_to<Enum>;
30
{ Enum::PrioLow } -> std::convertible_to<Enum>;
31
{ Enum::PrioNormal } -> std::convertible_to<Enum>;
32
{ Enum::PrioHigh } -> std::convertible_to<Enum>;
33
}
34
// Check if the flag is part of 'All' and does it have the expected value
35
&&
static_cast<
ice::TaskFlagBaseType
>
(Enum::All & Enum::Long) ==
Constant_TaskFlagLongValue
36
&&
static_cast<
ice::TaskFlagBaseType
>
(Enum::All & Enum::PrioLow) ==
Constant_TaskFlagLowPrioValue
37
&&
static_cast<
ice::TaskFlagBaseType
>
(Enum::All & Enum::PrioNormal) ==
Constant_TaskFlagNormalPrioValue
38
&&
static_cast<
ice::TaskFlagBaseType
>
(Enum::All & Enum::PrioHigh) ==
Constant_TaskFlagHighPrioValue
;
39
41
struct
TaskFlags
42
{
43
ice::TaskFlagBaseType
value
=
Constant_TaskFlagNormalPrioValue
;
44
45
constexpr
TaskFlags
() noexcept = default;
46
47
template<
ice
::
TaskFlagType
Flags>
48
constexpr
TaskFlags
(Flags flags) noexcept
49
:
value
{
static_cast<
ice::TaskFlagBaseType
>
(flags) }
50
{
51
}
52
53
template
<ice::TaskFlagType Flags>
54
constexpr
auto
operator=
(Flags flags)
noexcept
->
TaskFlags
&
55
{
56
value
=
static_cast<
ice::TaskFlagBaseType
>
(flags);
57
return
*
this
;
58
}
59
60
template
<ice::TaskFlagType Flags>
61
constexpr
operator
Flags() const noexcept
62
{
63
return
static_cast<
Flags
>
(
value
);
64
}
65
};
66
67
}
// namespace ice
ice::FlagAllValue
Definition
enum_flags.hxx:23
ice::FlagType
Definition
enum_flags.hxx:18
ice::TaskFlagType
Definition
task_flags.hxx:24
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ice::Constant_TaskFlagLongValue
static constexpr TaskFlagBaseType Constant_TaskFlagLongValue
Enumeration values used in the engine explicitly.
Definition
task_flags.hxx:18
ice::Constant_IsTaskFlagsEnumeration
static constexpr bool Constant_IsTaskFlagsEnumeration
Enables an enum type to be accepted as a task enumeration.
Definition
task_flags.hxx:12
ice::TaskFlagBaseType
ice::u32 TaskFlagBaseType
Base type required for an Enum to be a valid TaskFlag enumeration.
Definition
task_flags.hxx:15
ice::Constant_TaskFlagHighPrioValue
static constexpr TaskFlagBaseType Constant_TaskFlagHighPrioValue
Definition
task_flags.hxx:21
ice::u32
std::uint32_t u32
Definition
types.hxx:26
ice::Constant_TaskFlagLowPrioValue
static constexpr TaskFlagBaseType Constant_TaskFlagLowPrioValue
Definition
task_flags.hxx:19
ice::Constant_TaskFlagNormalPrioValue
static constexpr TaskFlagBaseType Constant_TaskFlagNormalPrioValue
Definition
task_flags.hxx:20
ice::TaskFlags::operator=
constexpr auto operator=(Flags flags) noexcept -> TaskFlags &
Definition
task_flags.hxx:54
ice::TaskFlags::value
ice::TaskFlagBaseType value
Definition
task_flags.hxx:43
ice::TaskFlags::TaskFlags
constexpr TaskFlags() noexcept=default
task_types.hxx
Generated by
1.18.0