FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_flag.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_C_FLAG_HPP_INCLUDED
18#define _FGE_C_FLAG_HPP_INCLUDED
19
20namespace fge
21{
22
30class Flag
31{
32public:
33 inline Flag(bool defaultValue = false) :
34 g_flag(defaultValue)
35 {}
36
45 inline bool check(bool input)
46 {
47 if (!this->g_flag)
48 {
49 this->g_flag = input;
50 return input;
51 }
52 if (!input)
53 {
54 this->g_flag = false;
55 }
56 return false;
57 }
58
64 inline void set(bool value) { this->g_flag = value; }
70 [[nodiscard]] inline bool get() const { return this->g_flag; }
71
78 inline bool operator=(bool value) { return this->g_flag = value; }
79
85 inline operator bool() const { return this->g_flag; }
86
87private:
88 bool g_flag;
89};
90
91} // namespace fge
92
93#endif // _FGE_C_FLAG_HPP_INCLUDED
A class to handle flags.
Definition C_flag.hpp:31
void set(bool value)
Manually set the flag value.
Definition C_flag.hpp:64
bool operator=(bool value)
Manually set the flag value operator.
Definition C_flag.hpp:78
bool check(bool input)
Check the input and return the flag value.
Definition C_flag.hpp:45
bool get() const
Get the flag value.
Definition C_flag.hpp:70