acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
device_context.h
1//
2// device_context.h
3// acme
4// Created by camilo on 2026-02-39 15:09 <3ThomasBorregaardSørensen!!
5//
6// Created by Camilo Sasuke Thomas Borregaard Sørensen on 20/02/26.
7// Copyright © 2026 ca2 Software Development. All rights reserved.
8//
9#pragma once
10
11
12struct opaque_t {};
13
14
15namespace operating_system
16{
17
18
19 //struct device_context_opaque_union_type
20 //{
21
22 // union
23 // {
24
25 // ::u8 m_opaque[32];
26 // ::u64 m_la[4];
27
28 // };
29
30 //};
31
32
33 struct device_context_opaque_t
34 //: public device_context_opaque_union_type
35 {
36
37
38 union
39 {
40
41 ::u8 m_opaque[24];
42 ::u64 m_ulla[3];
43
44 };
45
46
47 device_context_opaque_t(nullptr_t)
48 {
49
50 this->Null();
51
52 }
53
54
55 device_context_opaque_t() :
56 device_context_opaque_t(nullptr)
57 {
58
59 }
60
61
62 device_context_opaque_t(const device_context_opaque_t& device_context)
63 {
64
65 this->operator = (device_context);
66
67 }
68
69
70 void Null()
71 {
72
73 this->m_ulla[0] = 0;
74 this->m_ulla[1] = 0;
75 this->m_ulla[2] = 0;
76 this->m_ulla[3] = 0;
77
78 }
79
80
81 bool is_null() const
82 {
83
84 return
85 this->m_ulla[0] == 0
86 && this->m_ulla[1] == 0
87 && this->m_ulla[2] == 0
88 && this->m_ulla[3] == 0;
89
90 }
91
92
93 bool is_set() const
94 {
95
96 return !this->is_null();
97
98 }
99
100
101 bool operator == (const device_context_opaque_t& device_contextopaque) const
102 {
103
104 return
105 this->m_ulla[0] == device_contextopaque.m_ulla[0]
106 && this->m_ulla[1] == device_contextopaque.m_ulla[1]
107 && this->m_ulla[2] == device_contextopaque.m_ulla[2];
108
109 }
110
111
112 device_context_opaque_t& operator = (const device_context_opaque_t& device_contextopaque)
113 {
114
115 this->m_ulla[0] = device_contextopaque.m_ulla[0];
116 this->m_ulla[1] = device_contextopaque.m_ulla[1];
117 this->m_ulla[2] = device_contextopaque.m_ulla[2];
118
119 return *this;
120
121 }
122
123
124 operator ::hash32() const
125 {
126 return ::as_hash32(this->m_ulla[0])
127 + ::as_hash32(this->m_ulla[1])
128 + ::as_hash32(this->m_ulla[2])
129 + ::as_hash32(this->m_ulla[3]);
130 }
131
132
133
134 };
135
136
137 template < typename WINDOW_T >
138 struct a_device_context_t
139 {
140
141
142 using WINDOW_TYPE = WINDOW_T;
143
144
145 union
146 {
147
149 WINDOW_T m_device_context;
150
151 };
152
153
154 a_device_context_t(nullptr_t) { this->Null(); }
155
156
157 a_device_context_t() : a_device_context_t(nullptr) {}
158
159
160 template < typename WINDOW_OPAQUE_T >
161 requires (!::is_same < WINDOW_T, device_context_opaque_t >
162 && ::is_same < WINDOW_OPAQUE_T, device_context_opaque_t >)
163 a_device_context_t(const WINDOW_OPAQUE_T& device_contextopaque)
164 {
165
166 this->operator = (device_contextopaque);
167
168 }
169
170
171 a_device_context_t(const WINDOW_T & device_context)
172 {
173
174 this->operator = (device_context);
175
176 }
177
178
179 void Null() { this->m_device_context.Null(); }
180
181
182 bool operator == (const a_device_context_t & adevice_contextt) const
183 {
184
185 return this->m_device_context == adevice_contextt.m_device_context;
186
187 }
188
189
190 template < typename WINDOW_OPAQUE_T >
191 requires (!::is_same < WINDOW_T, device_context_opaque_t >
192 && ::is_same < WINDOW_OPAQUE_T, device_context_opaque_t >)
193 bool operator ==(const WINDOW_OPAQUE_T & device_contextopaque) const
194 {
195
196 return this->m_opaque == device_contextopaque;
197
198 }
199
200
201 bool operator == (const WINDOW_TYPE & device_context) const
202 {
203
204 return this->m_device_context == device_context;
205
206 }
207
208
209 a_device_context_t& operator = (const a_device_context_t & adevice_contextt)
210 {
211
212 this->m_device_context = adevice_contextt.m_device_context;
213
214 return *this;
215
216 }
217
218
219 template < typename WINDOW_OPAQUE_T >
220 requires (!::is_same < WINDOW_T, device_context_opaque_t >
221 && ::is_same < WINDOW_OPAQUE_T, device_context_opaque_t >)
222 a_device_context_t& operator = (const WINDOW_OPAQUE_T & device_contextopaque)
223 {
224
225 this->m_opaque = device_contextopaque;
226
227 return *this;
228
229 }
230
231
232 a_device_context_t& operator = (const WINDOW_T & device_context)
233 {
234
235 this->m_device_context = device_context;
236
237 return *this;
238
239 }
240
241
242 bool is_null() const
243 {
244
245 return m_device_context.is_null();
246
247 }
248
249
250 bool is_set() const
251 {
252
253 return !this->is_null();
254
255 }
256
257
258 operator ::hash32() const { return m_opaque; }
259
260
261 };
262
263
264 template < enum_operating_system t_eoperatingsystem, typename WINDOW_T >
265 class a_device_context;
266
267
268 using device_context = a_device_context < e_operating_system_none, device_context_opaque_t >;
269
270
271 template < enum_operating_system t_eoperatingsystem, typename WINDOW_T >
272 class a_device_context :
273 public a_device_context_t < WINDOW_T >
274 {
275 protected:
276 ::acme::device_contexting::device_context * m_pacmedevice_contextingdevice_context;
277 public:
278
279
280 using BASE_TYPE = a_device_context_t < WINDOW_T >;
281
282
283 using WINDOW_TYPE = typename BASE_TYPE::WINDOW_TYPE;
284
285 enum_operating_system m_eoperatingsystem;
286
287
288 a_device_context(nullptr_t)
289 {
290
291 this->Null();
292
293 }
294
295
296 a_device_context() :
297 a_device_context(nullptr)
298 {
299
300 }
301
302
303 a_device_context(const a_device_context & adevice_context) :
304 m_pacmedevice_contextingdevice_context(adevice_context.m_pacmedevice_contextingdevice_context),
305 m_eoperatingsystem(adevice_context.m_eoperatingsystem),
306 BASE_TYPE(adevice_context.m_device_context)
307 {
308
309 }
310
311
312 template < typename WINDOW >
313 requires (!::is_same < WINDOW_TYPE, device_context_opaque_t >
314 && ::is_same < WINDOW, device_context >)
315 a_device_context(const WINDOW & device_context) :
316 m_pacmedevice_contextingdevice_context(device_context._get_acme_device_contexting_device_context()),
317 m_eoperatingsystem(device_context.m_eoperatingsystem),
318 BASE_TYPE(device_context.m_opaque)
319 {
320
321 }
322
323
324 a_device_context(const WINDOW_TYPE & device_context, ::acme::device_contexting::device_context * pacmedevice_contextingdevice_context = nullptr) :
325 m_pacmedevice_contextingdevice_context(pacmedevice_contextingdevice_context),
326 m_eoperatingsystem(t_eoperatingsystem),
327 BASE_TYPE(device_context)
328 {
329
330 }
331
332
333 template < typename WINDOW_OPAQUE_T >
334 requires (!::is_same < WINDOW_T, device_context_opaque_t >
335 && ::is_same < WINDOW_OPAQUE_T, device_context_opaque_t >)
336 a_device_context(const enum_operating_system& eoperatingsystem, const WINDOW_OPAQUE_T & device_contextopaque, ::acme::device_contexting::device_context* pacmedevice_contextingdevice_context = nullptr) :
337 m_pacmedevice_contextingdevice_context(pacmedevice_contextingdevice_context),
338 m_eoperatingsystem(eoperatingsystem),
339 BASE_TYPE(device_contextopaque)
340 {
341
342 }
343
344
345
346 void _set_acme_device_contexting_device_context(::acme::device_contexting::device_context * pdevice_context)
347 {
348
349 m_pacmedevice_contextingdevice_context = pdevice_context;
350
351 }
352
353
354 ::acme::device_contexting::device_context * _get_acme_device_contexting_device_context() const
355 {
356
357 return m_pacmedevice_contextingdevice_context;
358
359 }
360
361
362
363 void Null()
364 {
365 this->m_device_context.Null();
366 m_pacmedevice_contextingdevice_context = nullptr;
367 m_eoperatingsystem = e_operating_system_none;
368 }
369
370
371 ::operating_system::device_context & as_operating_system_device_context()
372 {
373
374 auto pthis = (::operating_system::device_context*)this;
375
376 return *pthis;
377
378 }
379
380
381 const ::operating_system::device_context & as_operating_system_device_context() const
382 {
383
384 auto pthis = (::operating_system::device_context*)this;
385
386 return *pthis;
387
388 }
389
390
391 bool is_null() const
392 {
393
394 return (m_eoperatingsystem == e_operating_system_none
395 || BASE_TYPE::is_null()) && m_pacmedevice_contextingdevice_context == nullptr;
396
397 }
398
399
400 bool is_set() const
401 {
402
403 return !this->is_null();
404
405 }
406
407
408 bool operator == (const ::operating_system::device_context& operatingsystemdevice_context) const
409 {
410
411 if (operatingsystemdevice_context.m_eoperatingsystem != e_operating_system_none)
412 {
413
414 return (this->m_eoperatingsystem == operatingsystemdevice_context.m_eoperatingsystem
415 && BASE_TYPE::operator == (operatingsystemdevice_context.m_device_context));
416
417 }
418
419 return m_pacmedevice_contextingdevice_context == operatingsystemdevice_context.m_pacmedevice_contextingdevice_context;
420
421 }
422
423
424
425 template < typename WINDOW >
426 requires (!::is_same < WINDOW_TYPE, device_context_opaque_t >
427 && ::is_same < WINDOW, device_context >)
428 ::operating_system::device_context & operator = (const WINDOW & device_context)
429 {
430
431 this->m_pacmedevice_contextingdevice_context = device_context.m_pacmedevice_contextingdevice_context;
432 this->m_eoperatingsystem = device_context.m_eoperatingsystem;
433 BASE_TYPE::operator = (device_context.m_device_context);
434
435 return *this;
436
437 }
438
439
440 a_device_context & operator = (const a_device_context & adevice_context)
441 {
442
443 this->m_pacmedevice_contextingdevice_context = adevice_context.m_pacmedevice_contextingdevice_context;
444 this->m_eoperatingsystem = adevice_context.m_eoperatingsystem;
445 BASE_TYPE::operator = (adevice_context.m_device_context);
446
447 return *this;
448
449 }
450
451
452 };
453
454
455 //class device_context
456 //{
457 //public:
458
459 // enum_operating_system m_eoperatingsystem;
460 // device_context_t m_device_context;
461
462
463 // device_context(nullptr_t) :
464 // m_eoperatingsystem(e_operating_system_none),
465 // m_device_context(nullptr)
466 // {
467
468 // }
469
470
471 // device_context() :
472 // device_context(nullptr)
473 // {
474
475 // }
476
477
478 // device_context(const device_context& device_context) :
479 // m_eoperatingsystem(device_context.m_eoperatingsystem),
480 // m_device_context(device_context.m_device_context)
481 // {
482
483 // }
484
485
486 // device_context(const enum_operating_system& eoperatingsystem, const device_context_t& device_context) :
487 // m_eoperatingsystem(eoperatingsystem),
488 // m_device_context(device_context)
489 // {
490
491 // }
492
493
494 // bool is_null() const
495 // {
496 // return m_eoperatingsystem == e_operating_system_none
497 // || m_device_context.is_null();
498
499 // }
500
501
502 // bool is_set() const
503 // {
504
505 // return !this->is_null();
506
507 // }
508
509 // bool operator == (const ::operating_system::device_context& operatingsystemdevice_context) const
510 // {
511
512 // return this->m_eoperatingsystem == operatingsystemdevice_context.m_eoperatingsystem
513 // && this->m_device_context == operatingsystemdevice_context.m_device_context;
514
515 // }
516
517 //};
518
519
520
521} // namespace operating_system
522
523
524
Definition device_context.h:274
Definition device_context.h:12
Definition device_context.h:35