acme
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages Concepts
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 < ::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 < factory_pointer >;
42 using component_factory_map = ::string_map < 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 int m_argc = 0;
70 char ** m_args = nullptr;
71 char ** m_envp = nullptr;
72 ::platform::system * m_psystem;
73 //int 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 int 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 string m_strCommandLine;
169
170
171 //::critical_section m_criticalsectionTask;
172 //::critical_section m_criticalsectionTaskOn;
173
174
175 ::block m_blockMatter;
176 ::acme::library_map m_mapLibrary;
177 ::factory::factory_pointer m_pfactory;
178 ::factory::factory_map m_factorymap;
179 ::factory::component_factory_map m_componentfactorymap;
180 ::pointer < ::operating_system::dynamic_library > m_pdynamiclibrary;
181 int m_iProcessStatus = 0;
182 //::interlocked_long_long m_iNewTaskIndex;
183 //::comparable_array < itask > m_itaska;
184 bool m_bVerboseLog;
185 ::windowing::enum_windowing m_ewindowing;
186 ::windowing::enum_operating_ambient m_edesktop;
187 ::windowing::enum_toolkit m_etoolkit;
188
189
190 ::critical_section m_criticalsectionSystemHeap;
191
192
193 ::critical_section m_criticalsectionChannel;
194 ::critical_section m_criticalsectionSequence;
195 ::critical_section m_criticalsectionMessageDispatch;
196
197
198
199
200 platform();
201 virtual ~platform();
202
203 virtual bool is_console() const;
204
205 virtual bool is_desktop_system() const;
206
207 virtual bool is_sandboxed() const;
208
209
210 ::critical_section * channel_critical_section()
211 {
212
213 return &m_criticalsectionChannel;
214
215 }
216
217
218 ::critical_section * message_dispatch_critical_section()
219 {
220
221 return &m_criticalsectionMessageDispatch;
222
223 }
224
225
226 ::critical_section* sequence_critical_section()
227 {
228
229 return &m_criticalsectionSequence;
230
231 }
232
233
234
235 //using particle::initialize;
236
237#if defined(WINDOWS) && defined(UNICODE)
238
239 void initialize_system(int argc, wchar_t * args[], wchar_t * envp[]);
240
241 void initialize_system(hinstance hinstanceThis, hinstance hinstancePrev, wchar_t * pCmdLine, int nCmdShow);
242
243#else
244
245 void initialize_system(int argc, platform_char ** args, platform_char ** envp) override;
246
247#endif
248
249
250 void platform_initialize();
251 void platform_finalize();
252
253
254 void set_args(int argc, char ** args, wchar_t ** wargs);
255
256 string _get_args(::collection::index iArg) const;
257 ::collection::count get_argc();
258 int * get_pargc();
259 char *** get_pargs();
260 char ** get_args();
261
262#ifdef WINDOWS
263
264 wchar_t *** get_pwargs();
265 wchar_t ** get_wargs();
266
267#endif
268
269 bool is_verbose_log() const;
270
271 inline ::collection::count _get_argc() const { return m_argc; }
272
273 string get_executable() const;
274
275 string get_argument1(::collection::index iArgument) const;
276
277 bool has_argument(const ::scoped_string & scopedArgument) const;
278
279 inline ::collection::count get_argument_count1() const { return _get_argc() - 1; }
280
281 string_array get_arguments();
282
283 ::string get_argument_begins_eat(const ::scoped_string & scopedstrPrefix);
284
285 ::string_array get_argument_options(const ::scoped_string & scopedstrArgument);
286
287 string get_arg(::collection::index i) const;
288 string get_env(const ::scoped_string & scopedstrVariableName) const;
289
290
291 int get_status();
292 void set_status(int iStatus);
293
294
295
296 virtual void set_resource_block(const char * pstart, const char * pend);
297
298 void defer_initialize_platform();
299
300 void factory_initialize();
301 void factory_terminate();
302
303
304 void delete_all_release_on_end();
305
306
307 //::acme::acme * acme() const { return ((platform *)this)->m_pacme; }
308
309
310 ::factory::factory_pointer & factory();
311 ::factory::factory_pointer & factory(const ::string & strLibrary);
312 ::factory::factory_pointer & factory(const ::string & strComponent, const ::string & strImplementation);
313
314
315 ::pointer<::factory::factory_item_interface> & get_factory_item(const ::atom & atom, const ::atom & atomSource);
316
317
318 bool has_factory_item(const ::atom & atom);
319
320
321 void set_factory(const ::atom & atom, const ::pointer<::factory::factory_item_interface> & pfactory);
322
323
324 void set_factory_from(const ::atom & atom, const ::atom & atomSource, const ::pointer<::factory::factory_item_interface> & pfactory);
325
326
327 template < typename TYPE, typename BASE >
328 void add_factory_item(const ::atom & atom)
329 {
330
331 set_factory(atom, __allocate ::factory::factory_item < TYPE, BASE > ());
332
333 }
334
335
336 ::factory::factory * get_factory(const ::atom & atomSource);
337
338
339
340 //virtual void set_factory_global(const ::string &pszComponent, const ::string &pszImplementation);
341
342 //virtual ::pointer<::acme::library> open_component_library(const ::string &pszComponent, const ::string &pszImplementation);
343
344 virtual ::pointer<::acme::library> create_library(const ::string & strLibrary);
345 virtual ::pointer<::acme::library> create_library_dynamically(const ::string & strLibrary);
346 virtual ::pointer<::acme::library> create_library_statically(const ::string & strLibrary);
347
348 virtual ::pointer<::acme::library> & library(const ::string & str);
349
350 //virtual ::pointer<::acme::library>& library(const ::string& strComponent, const ::string& strImplementation);
351
352 virtual ::pointer<::factory::factory> & impact_factory(const ::string & strComponent, const ::string & strImplementation);
353
354 //void initialize_memory_counter();
355 //void finalize_memory_counter();
356
357 //::memory_counter * get_memory_counter();
358
359
360
361 //virtual ::platform::system * __get_system() = 0;
362 //class ::time start_nanosecond();
363
364
365
366 ::particle * ui_destroyed_synchronization();
367
368
369
370#if defined(LINUX) || defined(__APPLE__) || defined(ANDROID) || defined(__BSD__)
371
372 ::critical_section * tz_critical_section() { return &m_criticalsectionTz; }
373
374 ::critical_section * thread_handle_lock_critical_section() { return &m_criticalsectionThreadHandleLock; }
375
376
377#endif // defined(LINUX) || defined(__APPLE__)
378
379 critical_section * globals_critical_section() { return &m_criticalsectionGlobals; }
380
381
382
383 critical_section * factory_critical_section() { return &m_criticalsectionFactory; }
384
385
386
387
388#if !defined(WINDOWS)
389
390 ::critical_section * demangle_critical_section() { return &m_criticalsectionDemangle; }
391
392
393#endif
394
395 //::critical_section* system_heap_critical_section() { return &m_criticalsectionSystemHeap; }
396
397#ifdef WINDOWS
398
399
400
401 ::critical_section * sym_dbg_help_critical_section() { return &m_criticalsectionSymDbgHelp; }
402
403
404#endif
405
406
407#ifdef ANDROID
408
409
410 ::critical_section * output_debum_strinm_a_critical_section() { return &m_criticalsectionOutputDebugStringA; }
411
412#endif
413
414#ifdef __APPLE__
415
416
417 //::critical_section m_criticalsectionCvt;
418
419
420 ::critical_section * cvt_critical_section();
421
422#endif
423
424 //pass_through_function m_passthroughfunction;
425
426
429 //::thread_storage * thread_storage(const ::task_index & taskindex);
430 //::thread_storage * _thread_storage_unlocked(const ::task_index & taskindex);
431
432
433
434 //pass_through_function & __call__allocate_pass_through_function() { return m_passthroughfunction; }
435
436
437 //platform * __call__add_referer2(const ::reference_referer & referer) const;
438 release_time_for_project as_release_time_for_project(const char* pszStatic);
439
440 //::platform::system* system() { return m_psystem; }
441 ::operating_system::dynamic_library* dynamic_library() { return m_pdynamiclibrary; }
442
443// // [HERE]
444// // __node_library should be here at acme
445// //
446// // -- e.g. cannot lie inside a plugin,
447// // because it is used to load a plugin
448// //
449// virtual void* operating_system_library_open(const ::file::path & path, string& strMessage);
450//
451// #if defined FREEBSD || defined(OPENBSD)
452// virtual string operating_system_library_is_loaded(const ::file::path &path);
453// #endif // FREEBSD
454//
455// virtual void* operating_system_library_touch(const ::file::path & path, string& strMessage);
456// virtual void* operating_system_library_open_ca2(const ::file::path & path, string& strMessage);
457// virtual bool operating_system_library_close(void* plibrary);
458// virtual void* operating_system_library_raw_get(void* plibrary, const ::scoped_string & scopedstrEntryName);
459
460
461 };
462
463
464 //template < typename SYSTEM >
465 //class platform_impl :
466 // virtual public ::platform::platform
467 //{
468 //public:
469
470
471 // SYSTEM m_system;
472
473 // ::platform::system * __get_system() override { return &m_system; }
474
475
476 //};
477
478
479 //namespace platform
480 //{
481
482
483 inline ::platform::platform * get() { return ::platform::platform::s_pplatform; }
484
485
486
487} // namespace platform
488
489
490//inline ::platform::system* system()
491//{
492//
493// auto pplatform = ::platform::get();
494//
495// return pplatform ? pplatform->system() : nullptr;
496//
497//}
498
499
500inline ::operating_system::dynamic_library * dynamic_library()
501{
502
503 auto pplatform = ::platform::get();
504
505 return pplatform ? pplatform->dynamic_library() : nullptr;
506
507}
508
509
510CLASS_DECL_ACME ::string as_string(const ::release_time_for_project& releasetimeforproject);
511
512
513
Definition acme.h:22
Definition atom.h:233
Definition critical_section.h:9
Definition factory.h:182
Definition aaa_acme.h:15
Definition dynamic_library.h:15
Definition pointer.h:46
#include "aura/graphics/image/context.h"
Definition aaaa__defer.h:32
Definition block.h:49
Definition release_time_for_project.h:6