acme
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages Concepts
system_setup.h
1//
2// apex_app.h
3// apex
4//
5// Created by Camilo Sasuke Thomas Borregaard Soerensen on 18/08/19.
6// Moved from Apex to Acme on 2021-03-20 18:39 <3ThomasBS_
7//
8#pragma once
9
10
11
12//#include "acme/prototype/prototype/pointer.h"
13
14
15//#define DECLARE_FACTORY(library) \
16//__FACTORY_EXPORT void IDENTIFIER_CONCATENATE(library, _factory)(::factory::factory* pfactory);
17
18//#define MAKE_STRING(a) #a
19#define SETUP_FACTORY(library) \
20::system_setup IDENTIFIER_CONCATENATE(m_setup_, library){ &IDENTIFIER_CONCATENATE(library, _factory), MAKE_STRING(library)}
21
22
23//class node_data_exchange;
24
25
26//void apex_set_get_new_application(PFN_NEW_APEX_APPLICATION pnewapplication);
27
28
29class CLASS_DECL_ACME system_setup
30{
31public:
32
33
34 enum enum_flag
35 {
36
37 e_flag_none,
38 flag_system = 1,
39 flag_session = 2,
40 flag_application = 4,
41 flag_multimedia = 8,
42 flag_library = 16,
43 flag_object_user = 32,
44 flag_factory = 64,
45 flag_do_not_install = 4096,
46
47 };
48
49
50 const char * m_pszName;
51 enum_flag m_eflag;
52 system_setup* m_ppropertysetupNext;
53 PFN_factory m_pfnFactory;
54
55
56 static system_setup * s_psetupList;
57
58
59 system_setup(::system_setup::enum_flag eflag, const char * pszName);
60 system_setup(PFN_factory pfnFactory, const char * pszName);
61
62
63 void construct();
64
65
66 inline bool should_install() { return !has_flag(flag_do_not_install); }
67 [[nodiscard]] bool has_flag(::system_setup::enum_flag eflag) { return ((int)m_eflag & (int)eflag) == (int)eflag; }
68
69
70 static system_setup* get_last(::system_setup::enum_flag eflag, const ::scoped_string & scopedstrName = nullptr);
71 static system_setup* get_first(::system_setup::enum_flag eflag, const ::scoped_string & scopedstrName = nullptr);
72 static PFN_factory get_factory_function(const ::scoped_string & scopedstrName = nullptr);
73
74
75 virtual ::pointer<::acme::library>create_library();
76 virtual ::particle_pointer create_particle();
77 virtual ::particle_pointer create_application_as_particle();
78
79
80 virtual ::pointer<::acme::library>_create_library();
81 virtual ::particle_pointer _create_particle();
82 virtual ::particle_pointer _create_application_as_particle();
83
84
85};
86
87
88template < typename LIBRARY >
89class static_library_factory :
90 public system_setup
91{
92public:
93
94
95 ::pointer<::acme::library>_create_library() override { return __allocate LIBRARY(); }
96
97
98 explicit static_library_factory(const ::scoped_string & scopedstrName = "") :
99 system_setup(flag_library, scopedstrName)
100 {
101
102
103 }
104
105
106};
107
108
109template < typename OBJECT >
110class static_object_factory :
111 public system_setup
112{
113public:
114
115
116 ::particle_pointer _create_particle() override { return __allocate OBJECT(); }
117
118
119 explicit static_object_factory(::system_setup::enum_flag eflag, const ::scoped_string & scopedstrName = "") :
120 system_setup(eflag, scopedstrName)
121 {
122
123 }
124
125
126};
127
128
129#define __namespace_library_factory(LIBRARY) \
130::static_library_factory < library > COUNTER_TOKEN(g_library_factory)(LIBRARY);
131
132
133#define __namespace_object_factory(OBJECT, EOBJECT) \
134::static_object_factory < OBJECT > COUNTER_TOKEN(g_library_factory)(EOBJECT);
135
136
137// #define __namespace_system_factory(SYSTEM) \
138// __namespace_object_factory(SYSTEM,:: system_setup::flag_system)
139
140
141// #define __namespace_session_factory(SESSION) \
142// __namespace_object_factory(SESSION,:: system_setup::flag_session)
143
144
145
146
147
148
149template < typename APPLICATION_TYPE >
150class static_application_factory :
151 public system_setup
152{
153public:
154
155
156 ::particle_pointer _create_application_as_particle() override
157 {
158
159 auto papp = __allocate APPLICATION_TYPE();
160
161 return papp;
162
163 }
164
165
166 static_application_factory(const ::scoped_string & scopedstrName = "") :
167 system_setup(flag_application, scopedstrName)
168 {
169
170
171 }
172
173
174};
175
176
177#define __namespace_application_factory(APPID) \
178::static_application_factory < application > g_applicationfactory(APPID);
179
180
181
182class CLASS_DECL_ACME app_factory
183{
184public:
185
186
187 app_factory(PFN_factory pfnFactory);
188
189
190 static ::pointer<::platform::application>new_app(::particle * pparticle);
191
192
193};
194
195
196
Definition particle.h:89
Definition pointer.h:46