acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
platform.h
1// Created by camilo on 2022-10-09 20:55 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5
6//#include "acme/constant/windowing.h"
7#include "acme/parallelization/mutex.h"
8#include "acme/parallelization/task.h"
9#include "acme/parallelization/types.h"
10#include "acme/platform/library.h"
11#include "acme/platform/release_time_for_project.h"
12#include "acme/prototype/collection/atom_map.h"
13#include "acme/prototype/collection/string_map.h"
14#include "acme/user/user/activation.h"
15
16
17#ifdef LINUX
18
19
20#endif
21
22
23class main;
24
25
26namespace acme
27{
28
29
30 using library_map = string_map_base < ::pointer < ::acme::library > >;
31
32 class acme;
33
34} // namespace acme
35
36
37namespace factory
38{
39
40 using factory_pointer = ::pointer < ::factory::factory >;
41 using factory_map = ::string_map_base < factory_pointer >;
42 using component_factory_map = ::string_map_base < factory_map >;
43
44} // namespace factory
45
46
47namespace platform
48{
49
50
51 class CLASS_DECL_ACME platform :
52 virtual public ::acme::acme,
53 virtual public ::particle
54 {
55 public:
56
57
58 bool m_bConsole : 1;
59
60
61 static ::platform::platform * s_pplatform;
62
63 //::acme::acme * m_pacme;
64
65 ::critical_section m_criticalsection;
66
67 ::e_display m_edisplay;
68 ::user::e_activation m_eactivation;
69 ::i32 m_argc = 0;
70 char_pointer * m_args = nullptr;
71 char_pointer * m_envp = nullptr;
72 ::platform::system * m_psystem;
73 //::i32 m_iExitCode;
74
75#ifdef WINDOWS
76
77 wchar_t ** m_wargs = nullptr;
78 wchar_t ** m_wenvp = nullptr;
79
80 hinstance m_hinstanceThis = nullptr;
81 hinstance m_hinstancePrev = nullptr;
82 ::i32 m_nCmdShow = -1;
83
84#endif
85
86#ifdef LINUX
87
88 ::locale_t m_localeC;
89
90#endif
91
92#ifdef __APPLE__
93
94 void * m_pApplicationDelegate = nullptr;
95
96#endif
97
98
99
100#if defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || defined(__BSD__)
101
102 ::critical_section m_criticalsectionTz;
103
104 ::critical_section m_criticalsectionThreadHandleLock;
105
106#endif // defined(LINUX) || defined(__APPLE__)
107
108
109 ::critical_section m_criticalsectionGlobals;
110
111
112 ::critical_section m_criticalsectionFactory;
113
114
115#if !defined(WINDOWS)
116
117
118 ::critical_section m_criticalsectionDemangle;
119
120
121#endif
122
123
124 //::critical_section m_criticalsectionSystemHeap;
125
126
127#ifdef WINDOWS
128
129
130 ::critical_section m_criticalsectionSymDbgHelp;
131
132
133#endif
134
135
136 //::critical_section m_criticalsectionMessageDispatch;
137 //
138 //
139 //::critical_section * message_dispatch_critical_section() { return &m_criticalsectionMessageDispatch; }
140 //
141
142
143#ifdef __ANDROID__
144
145
146 ::critical_section m_criticalsectionOutputDebugStringA;
147
148
149#endif
150
151
152 //#ifdef __APPLE__
153 //
154 //
155 // ::critical_section m_criticalsectionCvt;
156 //
157 //
158 // ::critical_section* cvt_critical_section() { return &m_criticalsectionCvt; }
159 //
160 //#endif
161
162
163 ::memory_counter * m_pmemorycounter;
164
165
166 bool m_bOutputDebugString;
167
168 bool m_bCommandLineCalculated = false;
169 string m_strCommandLineCalculated;
170 bool m_bCommandLineSystemNative = false;
171 string m_strCommandLineSystemNative;
172
173
174 //::critical_section m_criticalsectionTask;
175 //::critical_section m_criticalsectionTaskOn;
176
177
178 ::block m_blockMatter;
179 ::acme::library_map m_mapLibrary;
180 ::factory::factory_pointer m_pfactory;
181 ::factory::factory_map m_factorymap;
182 ::factory::component_factory_map m_componentfactorymap;
183 ::pointer < ::operating_system::dynamic_library > m_pdynamiclibrary;
184 ::i32 m_iProcessStatus = 0;
185 //::interlocked_i64 m_iNewTaskIndex;
186 //::comparable_array < itask > m_itaska;
187 bool m_bVerboseLog;
188 ::windowing::enum_windowing m_ewindowing;
189 ::windowing::enum_operating_ambient m_edesktop;
190 ::windowing::enum_toolkit m_etoolkit;
191
192
193 ::critical_section m_criticalsectionSystemHeap;
194
195
196 ::critical_section m_criticalsectionChannel;
197 ::critical_section m_criticalsectionSequence;
198 ::critical_section m_criticalsectionMessageDispatch;
199
200
201
202
203 platform();
204 ~platform() override;
205
206 virtual bool is_console() const;
207
208 virtual bool is_desktop_system() const;
209
210 virtual bool is_sandboxed() const;
211
212 virtual ::string command_line() const;
213
214 virtual void calculate_command_line();
215
216
217 ::critical_section * channel_critical_section()
218 {
219
220 return &m_criticalsectionChannel;
221
222 }
223
224
225 ::critical_section * message_dispatch_critical_section()
226 {
227
228 return &m_criticalsectionMessageDispatch;
229
230 }
231
232
233 ::critical_section* sequence_critical_section()
234 {
235
236 return &m_criticalsectionSequence;
237
238 }
239
240
241
242 //using particle::initialize;
243
244#if defined(WINDOWS) && defined(UNICODE)
245
246 void initialize_system(::i32 argc, wchar_t * args[], wchar_t * envp[]) override;
247
248 void initialize_system(hinstance hinstanceThis, hinstance hinstancePrev, wchar_t * pCmdLine, ::i32 nCmdShow) override;
249
250#endif
251
252 void initialize_system(::i32 argc, char_pointer * args, char_pointer * envp) override;
253
254
255 void platform_initialize();
256 void platform_finalize();
257
258
259 void set_args(::i32 argc, char_pointer * args, wchar_t ** wargs);
260
261 string _get_args(::collection::index iArg) const;
262 ::collection::count get_argc();
263 ::i32 * get_pargc();
264 char_pointer ** get_pargs();
265 char_pointer * get_args();
266
267#ifdef WINDOWS
268
269 wchar_t *** get_pwargs();
270 wchar_t ** get_wargs();
271
272#endif
273
274 bool is_verbose_log() const;
275
276 inline ::collection::count _get_argc() const { return m_argc; }
277
278 string get_executable() const;
279
280 string get_argument1(::collection::index iArgument) const;
281
282 string arguments_from1(::collection::index iArgument) const;
283
284 bool has_argument(const ::scoped_string & scopedArgument) const;
285
286 inline ::collection::count get_argument_count1() const { return _get_argc() - 1; }
287
288 string_array_base get_arguments();
289
290 ::string get_argument_begins_eat(const ::scoped_string & scopedstrPrefix);
291
292 ::string_array_base get_argument_options(const ::scoped_string & scopedstrArgument);
293
294 string get_arg(::collection::index i) const;
295 string get_env(const ::scoped_string & scopedstrVariableName) const;
296
297
298 ::i32 get_status();
299 void set_status(::i32 iStatus);
300
301
302
303 virtual void set_resource_block(const_char_pointer pstart, const_char_pointer pend);
304
305 void defer_initialize_platform();
306
307 void factory_initialize();
308 void factory_terminate();
309
310
311 void delete_all_release_on_end();
312
313
314 //::acme::acme * acme() const { return ((platform *)this)->m_pacme; }
315
316
317 ::factory::factory_pointer & factory();
318 ::factory::factory_pointer & factory(const ::scoped_string & scopedstrLibrary);
319 ::factory::factory_pointer & factory(const ::scoped_string & scopedstrComponent, const ::scoped_string & scopedstrImplementation);
320 ::factory::factory* component_factory(const ::scoped_string & scopedstrComponent);
321 virtual ::string component_factory_implementation_name(const ::scoped_string & scopedstrComponent);
322
323
324 //::factory::factory_item_interface* get_factory_item_by_type_index(const ::std::type_index & typeindex);
325 //::factory::factory_item_interface* get_factory_item_by_custom_id(const ::type_custom_id & typecustomid);
326 ::factory::factory_item_interface* find_factory_item(const ::platform::type & type);
327
328
329 //::factory::factory_item_interface * get_factory_item_by_type_index(const ::std::type_index & typeindex, const ::atom & atomFactory);
330 //::factory::factory_item_interface * get_factory_item_by_custom_id(const ::type_custom_id & typecustomid, const ::atom & atomFactory);
331 ::factory::factory_item_interface * find_factory_item(const ::platform::type & type, const ::atom & atomFactory);
332
333
334 //bool has_factory_item_by_type_index(const ::std::type_index & typeindex);
335 //bool has_factory_item_by_custom_id(const ::type_custom_id & typecustomid);
336 bool has_factory_item(const ::platform::type & type);
337
338
339 //void set_factory_item_by_type(const ::platform::type & type, const ::pointer<::factory::factory_item_interface> & pfactoryitem);
340 //void set_factory_item_by_custom_id(const ::type_custom_id & typecustomid, const ::pointer<::factory::factory_item_interface>& pfactoryitem);
341
342
343 //void set_factory_item_by_type_for_factory(const ::platform::type & type, const ::atom & atomFactory, const ::pointer<::factory::factory_item_interface> & pfactoryitem);
344 //void set_factory_item_by_custom_id_for_factory(const ::type_custom_id & typecustomid, const ::atom& atomFactory, const ::pointer<::factory::factory_item_interface>& pfactoryitem);
345
346
347 //template < typename TYPE, typename BASE >
348 //void add_factory_item_by_custom_id(const ::type_custom_id & typecustomid)
349 //{
350
351 // set_factory_item_by_custom_id(typecustomid, allocateø ::factory::factory_item < TYPE, BASE > ());
352
353 //}
354
355
356 ::factory::factory * get_factory(const ::atom & atomFactory);
357
358
359
360 //virtual void set_factory_global(const ::scoped_string & scopedstrComponent, const ::scoped_string & scopedstrImplementation);
361
362 //virtual ::pointer<::acme::library> open_component_library(const ::scoped_string & scopedstrComponent, const ::scoped_string & scopedstrImplementation);
363
364 virtual ::pointer<::acme::library> create_library(const ::scoped_string & scopedstrLibrary);
365 virtual ::pointer<::acme::library> create_library_dynamically(const ::scoped_string & scopedstrLibrary);
366 virtual ::pointer<::acme::library> create_library_statically(const ::scoped_string & scopedstrLibrary);
367
368 virtual ::pointer<::acme::library> & library(const ::scoped_string & scopedstr);
369
370 //virtual ::pointer<::acme::library>& library(const ::scoped_string & scopedstrComponent, const ::scoped_string & scopedstrImplementation);
371
372 virtual ::pointer<::factory::factory> & impact_factory(const ::scoped_string & scopedstrComponent, const ::scoped_string & scopedstrImplementation);
373
374 //void initialize_memory_counter();
375 //void finalize_memory_counter();
376
377 //::memory_counter * get_memory_counter();
378
379
380
381 //virtual ::platform::system * __get_system() = 0;
382 //class ::time start_nanosecond();
383
384
385
386 ::particle * ui_destroyed_synchronization();
387
388
389
390#if defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || defined(__BSD__)
391
392 ::critical_section * tz_critical_section() { return &m_criticalsectionTz; }
393
394 ::critical_section * thread_handle_lock_critical_section() { return &m_criticalsectionThreadHandleLock; }
395
396
397#endif // defined(LINUX) || defined(__APPLE__)
398
399 critical_section * globals_critical_section() { return &m_criticalsectionGlobals; }
400
401
402
403 critical_section * factory_critical_section() { return &m_criticalsectionFactory; }
404
405
406
407
408#if !defined(WINDOWS)
409
410 ::critical_section * demangle_critical_section() { return &m_criticalsectionDemangle; }
411
412
413#endif
414
415 //::critical_section* system_heap_critical_section() { return &m_criticalsectionSystemHeap; }
416
417#ifdef WINDOWS
418
419
420
421 ::critical_section * sym_dbg_help_critical_section() { return &m_criticalsectionSymDbgHelp; }
422
423
424#endif
425
426
427#ifdef __ANDROID__
428
429
430 ::critical_section * output_debum_strinm_a_critical_section() { return &m_criticalsectionOutputDebugStringA; }
431
432#endif
433
434#ifdef __APPLE__
435
436
437 //::critical_section m_criticalsectionCvt;
438
439
440 ::critical_section * cvt_critical_section();
441
442#endif
443
444 //pass_through_function m_passthroughfunction;
445
446
449 //::thread_storage * thread_storage(const ::task_index & taskindex);
450 //::thread_storage * _thread_storage_unlocked(const ::task_index & taskindex);
451
452
453
454 //pass_through_function & __call_allocate_pass_through_function() { return m_passthroughfunction; }
455
456
457 //platform * __call__add_referer2(const ::reference_referer & referer) const;
458 release_time_for_project as_release_time_for_project(const_char_pointer pszStatic);
459
460 //::platform::system* system() { return m_psystem; }
461 ::operating_system::dynamic_library* dynamic_library() { return m_pdynamiclibrary; }
462
463// // [HERE]
464// // __node_library should be here at acme
465// //
466// // -- e.g. cannot lie inside a plugin,
467// // because it is used to load a plugin
468// //
469// virtual void* operating_system_library_open(const ::file::path & path, string& strMessage);
470//
471// #if defined FREEBSD || defined(OPENBSD)
472// virtual string operating_system_library_is_loaded(const ::file::path &path);
473// #endif // FREEBSD
474//
475// virtual void* operating_system_library_touch(const ::file::path & path, string& strMessage);
476// virtual void* operating_system_library_open_ca2(const ::file::path & path, string& strMessage);
477// virtual bool operating_system_library_close(void* plibrary);
478// virtual void* operating_system_library_raw_get(void* plibrary, const ::scoped_string & scopedstrEntryName);
479
480
481 };
482
483
484 //template < typename SYSTEM >
485 //class platform_impl :
486 // virtual public ::platform::platform
487 //{
488 //public:
489
490
491 // SYSTEM m_system;
492
493 // ::platform::system * __get_system() override { return &m_system; }
494
495
496 //};
497
498
499 //namespace platform
500 //{
501
502
503 inline ::platform::platform * get() { return ::platform::platform::s_pplatform; }
504
505
506
507} // namespace platform
508
509
510//inline ::platform::system* system()
511//{
512//
513// auto pplatform = ::platform::get();
514//
515// return pplatform ? pplatform->system() : nullptr;
516//
517//}
518
519
520inline ::operating_system::dynamic_library * dynamic_library()
521{
522
523 auto pplatform = ::platform::get();
524
525 return pplatform ? pplatform->dynamic_library() : nullptr;
526
527}
528
529
530CLASS_DECL_ACME ::string as_string(const ::release_time_for_project& releasetimeforproject);
531
532
533
Definition acme.h:22
Definition critical_section.h:9
Definition factory.h:39
Definition factory.h:201
Definition aaa_acme.h:15
Definition dynamic_library.h:15
Definition type.h:584
include "aura/graphics/image/context.h"
Definition aaaa__defer.h:32
include "thread/AutoLock.h"
Definition _forward_declaration.h:877
Definition block.h:46
Definition release_time_for_project.h:6