acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
quantum.h
1// Created by camilo:hi5! on 2024-05-07 10:48 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5#include "acme/memory/quantum.h"
6//#include "subparticle_flags.h"
7
8
10{
11
12
13 ::e_flag m_eflagElement;
14
15
16};
17
18
19class CLASS_DECL_ACME quantum :
20 public memory_quantum,
21 virtual public quantum_flag
22{
23public:
24
25
26 ::e_status m_estatus;
27
28
29
30 inline quantum() { }
31
32
33 //inline quantum(const ::e_flag & eflag, const ::e_status & estatus = undefined) :
34 // m_eflagElement(eflag),
35 // m_estatus(estatus)
36 //{
37
38
39 //}
40
41
42 inline quantum(const ::quantum & quantum)
43 {
44
45
46 }
47
48 inline quantum(::quantum&& quantum)
49 {
50
51
52 }
53
54
55 virtual ~quantum();
56
57
58
59
60 [[nodiscard]] inline bool has_flag(enum_flag eflag) const { return m_eflagElement.is(eflag); }
61 inline void set_flag(enum_flag eflag) { m_eflagElement = m_eflagElement | eflag; }
62 inline void set_flag(enum_flag eflag, bool bSet) { if (bSet) set_flag(eflag); else clear_flag(eflag); }
63 inline void clear_flag(enum_flag eflag) { m_eflagElement = m_eflagElement & ~eflag; }
64
65
66 inline void set_ok_flag() { set_flag(e_flag_success); clear_flag(e_flag_timeout); clear_flag(e_flag_failure); }
67 inline void set_nok(enum_flag estatusFailure = e_flag_failure) { clear_flag(e_flag_success); set_flag(estatusFailure); }
68 inline void set_modified_flag(bool bModified = true) { set_flag(e_flag_changed, bModified); }
69
70
71 [[nodiscard]] inline bool has_proto_flag() const { return has_flag(e_flag_proto); }
72
73
74 inline void set_fail_flag() { set_flag(e_flag_failure); clear_flag(e_flag_success); }
75 inline void set_timed_out_flag() { set_flag(e_flag_timeout); }
76 inline void set_persistent_flag(bool bSet = true) { set_flag(e_flag_persist, bSet); }
77
78
79 [[nodiscard]] inline bool has_ok_flag() const { return has_flag(e_flag_success); }
80 [[nodiscard]] inline bool nok() const { return has_flag(e_flag_failure) || has_flag(e_flag_timeout); }
81 [[nodiscard]] inline bool has_timed_out_flag() { return has_flag(e_flag_timeout); }
82 [[nodiscard]] inline bool has_modified_flag() const { return has_flag(e_flag_changed); }
83 [[nodiscard]] inline bool has_persistent_flag() const { return has_flag(e_flag_persist); }
84
85 [[nodiscard]] inline bool has_shared_flag() const { return has_flag(e_flag_shared); }
86 inline void set_shared_flag(bool bSet = true) { set_flag(e_flag_shared, bSet); }
87
88
89 [[nodiscard]] inline bool has_finishing_flag() const { return has_flag(e_flag_finishing); }
90 //inline void set_finishing_flag() { set_flag(e_flag_finishing); };
91 void set_finishing_flag();
92 inline void clear_finishing_flag() { clear_flag(e_flag_finishing); }
93
94
95 [[nodiscard]] inline bool has_initialized_flag() const { return has_flag(e_flag_initialized); }
96 inline void set_initialized_flag() { set_flag(e_flag_initialized); }
97 inline void clear_initialized_flag() { clear_flag(e_flag_initialized); }
98
99
100 [[nodiscard]] inline bool has_acquired_flag() const { return has_flag(e_flag_acquired); }
101 inline void set_acquired_flag() { set_flag(e_flag_acquired); }
102 inline void clear_acquired_flag() { clear_flag(e_flag_acquired); }
103
104 [[nodiscard]] inline bool has_own_synchronization_flag() const { return has_flag(e_flag_own_synchronization); }
105 inline void set_own_synchronization_flag(bool bSet = true) { set_flag(e_flag_own_synchronization, bSet); }
106 inline void clear_own_synchronization_flag() { clear_flag(e_flag_own_synchronization); }
107
108
109 [[nodiscard]] inline bool has_already_exists_flag() const { return has_flag(e_flag_already_exists); }
110 inline void set_already_exists_flag(bool bSet = true) { set_flag(e_flag_already_exists, bSet); }
111 inline void clear_already_exists_flag() { clear_flag(e_flag_already_exists); }
112
113
114
115 [[nodiscard]] inline bool has_running_flag() const { return has_flag(e_flag_running); }
116 inline void set_running_flag() { set_flag(e_flag_running); }
117 inline void clear_running_flag() { clear_flag(e_flag_running); }
118
119 // [[nodiscard]] inline bool is_heap_allocated() const { return has_flag(e_flag_heap_allocated); }
120 // inline void set_heap_allocated() { set_flag(e_flag_heap_allocated); }
121 // inline void clear_heap_allocated() { clear_flag(e_flag_heap_allocated); }
122
123
124 [[nodiscard]] inline bool has_destroying_flag() const { return has_flag(e_flag_destroying); }
125 void set_destroying_flag();
126 inline void clear_destroying_flag() { clear_flag(e_flag_destroying); }
127
128
129 [[nodiscard]] inline bool has_storing_flag() const { return has_flag(e_flag_storing); }
130 [[nodiscard]] inline bool has_loading_flag() const { return !has_storing_flag(); }
131
132
133 inline void set_storing_flag() { set_flag(e_flag_storing); }
134 inline void set_loading_flag() { clear_flag(e_flag_storing); }
135
136
137 inline void defer_set_storing_flag() { if (!has_storing_flag()) set_storing_flag(); }
138 inline void defer_set_loading_flag() { if (!has_loading_flag()) set_loading_flag(); }
139
140
141 inline void set_statically_allocated_flag() { set_flag(e_flag_statically_allocated); }
142 inline void set_verbose_flag(bool bVerbose = true) { set_flag(e_flag_verbose, bVerbose); }
143 [[nodiscard]] inline bool has_verbose_flag() const { return has_flag(e_flag_verbose); }
144
145
146
147 [[nodiscard]] inline bool has_read_only_flag() const { return has_flag(e_flag_read_only); }
148 inline void set_read_only_flag() { set_flag(e_flag_read_only); }
149 inline void clear_read_only_flag() { clear_flag(e_flag_read_only); }
150
151 [[nodiscard]] inline bool has_owner_flag() const { return has_flag(e_flag_owner); }
152 inline void set_owner_flag() { set_flag(e_flag_owner); }
153 inline void clear_owner_flag() { clear_flag(e_flag_owner); }
154
155
156 inline bool is_status_ok() const { return m_estatus.ok(); }
157 inline bool has_failed_status() const { return !is_status_ok(); }
158
159 //[[nodiscard]] inline bool is_realized() const { return has_flag(e_flag_realized); }
161
162
163 virtual void call_request(::request* prequest);
164 virtual void request(::request * prequest);
165 virtual void on_request(::request * prequest);
166
167
168};
169
Definition e_status.h:30
virtual void call_request(::request *prequest)
inline void set_realized() { set_flag(e_flag_realized); }
Definition quantum.cpp:30
Definition quantum.h:10