acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
bbb_object.h
1// Created on 2021-03-08 by GOD:ThomasBS_-Creature-camilo 09:56 I love you, ThomasBS_!!
2#pragma once
3
4
5enum enum_method : ::i32;
6enum enum_future : ::i32;
7
8
9class CLASS_DECL_APEX object :
10 virtual public ::manager
11{
12protected:
13
14
15 ::pointer<matter_array> m_pcompositea;
16 ::pointer<matter_array> m_preferencea;
17
18
19
20public:
21
22 ::object_meta* m_pmeta;
23 ::i64 m_cRun;
24
25
26 object() : m_pmeta(nullptr) { }
27 //object(::particle * pparticle);
28 object(enum_default_initialization) : ::object() {};
29 virtual ~object();
30
31
32#ifdef _DEBUG
33
34
35 virtual ::i64 increment_reference_count() override;
36 virtual ::i64 decrement_reference_count() override;
37 virtual ::i64 release() override;
38
39
40#else
41
42
43 virtual ::i64 increment_reference_count();
44 virtual ::i64 decrement_reference_count();
45 virtual ::i64 release();
46
47
48#endif
49
50
51
52
53 inline matter_array* _composite_array() { return m_pcompositea; }
54 inline matter_array* _reference_array() { return m_preferencea; }
55
56
57 inline matter_array& composite_array() { ::defer_construct_newø(m_pcompositea); return *m_pcompositea; }
58 inline matter_array& reference_array() { ::defer_construct_newø(m_preferencea); return *m_preferencea; }
59
60
61
62 virtual void process_exit_status(const ::e_status & estatus);
63
64 //inline ::object* this const { return this; }
65 //virtual void set_object(::object* pparticle) override;
66
67 //inline ::application* application() { return m_papplication; }
68
69 //template < typename TYPE, typename TYPE2 >
70 //void __bind(reference < TYPE >& r, TYPE2& t)
71 //{
72
73 // __refr(r, t);
74
75 //}
77
78
79
80 template < typename BASE_TYPE >
81 ::pointer<BASE_TYPE>file_as(const ::payload& payloadFile);
82
83
84 virtual void add_procedure(const ::atom& idRoutine, const ::procedure & procedure);
85
86
87 virtual void add_each_routine_from(const ::atom& idRoutine, ::object* pobjectSource);
88
89
90 virtual array < ::procedure >* routinea(const ::atom& idRoutine);
91
92
93 virtual void call_routine(const ::atom& idRoutine);
94
95
96 inline ::payload context_value(const ::payload& payload);
97
98
99 virtual void task_erase(::task* ptask) override;
100
101
102 virtual void sleep(const class ::time& time);
103
104
105 template < typename BASE_TYPE >
106 void save_to(const ::payload& payloadFile, BASE_TYPE* pparticle);
107
108 virtual void initialize(::particle * pparticle) override;
109 virtual void destroy() override;
110
111 inline const_char_pointer topic_text();
112
113 context& __context(const ::payload& payload);
114
115 ::payload __context_value(const ::payload& payload);
116
117 virtual void set_topic_text(const ::scoped_string & scopedstr);
118
119 void create_object_meta();
120
121 inline void defer_object_meta() { if (::is_null(m_pmeta)) create_object_meta(); }
122
123 inline ::object_meta* get_meta() { defer_object_meta(); return m_pmeta; }
124
125 inline ::handler_context* get_context() const { return m_papplication; }
126
127 inline ::thread* get_thread() const { return m_pthread; }
128
129 inline ::application* get_app() const { return m_papplication; }
130
131 inline ::apex::session* get_session() const { return m_psession; }
132
133 //::apex::system * psystem const { return m_psystemContext; }
134
135 //::object * get_context_user() const { return m_puserContext; }
136
137 //inline ::application * application() const { return m_papplication; }
138
139 virtual string get_text(const ::payload& payload, const ::atom& atom) override;
140
141#ifdef _DEBUG
142 virtual void set_context(::handler_context* pcontext);
143 virtual void set_context_thread(::thread* pthread);
144 virtual void set_context_app(::apex::application* pappContext);
145 virtual void set_context_session(::apex::session* psessionContext);
146 //virtual void set_context_system(::apex::system* psystemContext);
147 //virtual void set_context_user(::object * puserContext);
148#else
149 inline void set_context(::handler_context* pcontext);
150 inline void set_context_thread(::thread* pthread);
151 inline void set_context_app(::apex::application* pappContext);
152 inline void set_context_session(::apex::session* psessionContext);
153 //inline void set_context_system(::apex::system* psystemContext);
154 //inline void set_context_user(::object * puserContext);
155#endif
156
157
158 //virtual void set_object(::particle * pparticle) override;
159
160
161 //inline void defer_set_object(::particle * pparticle);
162
163 virtual void operator()() override;
164
165
166 inline ::i64 get_ref_count()
167 {
168
169 return m_countReference;
170
171 }
172
173
174 //virtual ::user::interaction_base* get_user_interaction_host();
175 //virtual ::user::interaction * get_host_user_interaction();
176
177
178 virtual void dev_log(const ::scoped_string & scopedstr) const;
179
180 ::object& operator = (const ::payload& payload);
181
182
183
184
185 //static ::u32 s_thread_proc(void* p);
186
187
188 virtual void to_string(const string_exchange& str) const override;
189
190 //::image::image_pointer create_image();
191 //::image::image_pointer create_image(const ::i32_size & size, ::eobject eobjectCreate = OK, ::i32 iGoodStride = -1, bool bPreserve = false);
192
193 //::image::image_pointer get_image(const ::payload & payloadFile, bool bCache = true, bool bSync = true);
194 //::image::image_pointer matter_image(const ::scoped_string & scopedstrMatter, bool bCache = true, bool bSync = true);
195
196 //template < typename BASE_TYPE >
197 //inline ::pointer<BASE_TYPE>createø();
198
199 //template < typename BASE_TYPE >
200 //inline ::pointer<BASE_TYPE>øcreate_by_type(const ::atom& atom);
201
202 //template < typename TYPE >
203 //inline ::pointer<TYPE>create_newø();
204
205 //inline void constructø(::pointer<::image::image>& pimage);
206
207 //inline void constructø(::pointer<::image::image>& pimage, ::image::image *pimageSource);
208
209 //inline void defer_constructø(::pointer<::image::image>& pimage) { return !pimage ? constructø(pimage) : void(::success); }
210
211 // for composition (ownership)
212
213 template < typename BASE_TYPE >
214 inline void constructø(::pointer<BASE_TYPE> pusermessage);
215
216 template < typename BASE_TYPE, typename SOURCE >
217 inline void constructø(::pointer<BASE_TYPE> pusermessage, const SOURCE* psource);
218
219 template < typename BASE_TYPE, typename SOURCE >
220 inline void constructø(::pointer<BASE_TYPE> pusermessage, const ::pointer<SOURCE>psource);
221
222 template < typename BASE_TYPE >
223 inline void øconstruct_by_id(::pointer<BASE_TYPE> pusermessage, const ::atom& atom);
224
225 template < typename BASE_TYPE >
226 inline void øraw_construct(::pointer<BASE_TYPE> pusermessage);
227
228 template < typename BASE_TYPE, typename SOURCE >
229 inline void øraw_construct(::pointer<BASE_TYPE> pusermessage, const SOURCE* psource);
230
231 template < typename BASE_TYPE, typename SOURCE >
232 inline void øraw_construct(::pointer<BASE_TYPE> pusermessage, const ::pointer<SOURCE>psource);
233
234 template < typename TYPE >
235 inline void __raw_construct_new(::pointer<TYPE> ptype);
236
237 template < typename TYPE >
238 inline void construct_newø(::pointer<TYPE> ptype);
239
240
241
242
243 template < typename BASE_TYPE >
244 inline void defer_constructø(::pointer<BASE_TYPE> pusermessage) { return !pusermessage ? constructø(pusermessage) : void(::success); }
245
246 template < typename BASE_TYPE >
247 inline void __defer_id_compose(::pointer<BASE_TYPE> pusermessage, const ::atom& atom) { return !pusermessage ? øconstruct_by_id(pusermessage) : void(::success); }
248
249 template < typename TYPE >
250 inline void __defer_raw_compose_new(::pointer<TYPE> ptype) { return !ptype ? __raw_construct_new(ptype) : void(::success); }
251
252 template < typename TYPE >
253 inline void defer_construct_newø(::pointer<TYPE> ptype) { return !ptype ? construct_newø(ptype) : void(::success); }
254
255
256
257 //template < typename BASE_TYPE >
258 //inline void constructø(::pointer<BASE_TYPE> pusermessage);
259
260 //template < typename BASE_TYPE >
261 //inline void øconstruct_by_id(::pointer<BASE_TYPE> pusermessage, const ::atom& atom);
262
263 //template < typename TYPE >
264 //inline void construct_newø(::pointer<TYPE> pusermessage);
265
266 template < typename BASE_TYPE >
267 inline void __release(::pointer<BASE_TYPE> pcomposite);
268
269 template < typename BASE_TYPE >
270 inline void __release(::pointer<BASE_TYPE> preference);
271
272 template < typename SOURCE >
273 inline void __release(::pointer<SOURCE> psource);
274
275
276 virtual void add_composite(::particle * pparticle) override;
277 virtual void add_reference(::particle * pparticle) override;
278
279
280 virtual void release_composite2(::particle * pparticle) override;
281 virtual void finalize_composite(::particle * pparticle) override;
282 virtual void release_reference(::particle * pparticle) override;
283
284
285 template < typename BASE_TYPE >
286 inline void add_composite(::pointer<BASE_TYPE> pcomposite);
287
288 template < typename BASE_TYPE, typename SOURCE >
289 inline void __refer(::pointer<BASE_TYPE> preference, const SOURCE* psource);
290
291 template < typename BASE_TYPE, typename SOURCE >
292 inline void __refer(::pointer<BASE_TYPE> preference, const ::pointer<SOURCE>psource);
293
294 template < typename BASE_TYPE, typename SOURCE >
295 inline void __refer(::pointer<BASE_TYPE> preference, const ::prototype::member < SOURCE >& psource);
296
297 template < typename SOURCE >
298 inline void add_reference(SOURCE* psource);
299
300 template < typename SOURCE >
301 inline void add_reference(::pointer<SOURCE> psource);
302
303 template < typename SOURCE >
304 inline void add_reference(::pointer<SOURCE> psource);
305
306 virtual void delete_this() override;
307
308 virtual void destruct();
309
310 static void system(const ::scoped_string & scopedstrProjectName);
311
312 virtual void enable_application_events(bool bEnable = true);
313
314 virtual void handle_exception(const ::exception& e);
315
316 virtual void top_handle_exception(const ::exception& e);
317
318 virtual void process_exception(const ::exception& e);
319
320
321 ::object* parent_property_set_holder() const override;
322
323 void copy_from(const object& o);
324
325
326 virtual string get_tag() const;
327 virtual bool is_thread() const override;
328 virtual bool task_get_run() const;
329 virtual bool is_running() const;
330 virtual void child_post_quit(const ::scoped_string & scopedstrTag);
331 virtual void child_post_quit_and_wait(const ::scoped_string & scopedstrTag, const time& time);
332 virtual void finish(::property_object* pcontextobjectFinish = nullptr) override;
333 virtual void set_finish(::property_object* pcontextobjectFinish) override;
334 virtual void set_finish_composites(::property_object* pcontextobjectFinish) override;
335 virtual void on_finish() override;
336
337
338 virtual void defer_update_object_id();
339 virtual ::atom calc_default_object_id() const;
340
341
342 virtual void install_message_routing(::channel* pchannel);
343
344 void message_receiver_destruct();
345
346 void _001OnUpdate(::message::message* pmessage);
347
348 virtual void request_file(const ::payload& payloadFile);
349
350 virtual void request_file(const ::payload& payloadFile, ::payload varQuery);
351
352 virtual void request(arguments arguments);
353
354 virtual void do_request(::create* pcreate);
355
356 virtual pointer< ::extended::future < ::conversation > > message_box(const ::scoped_string & scopedstrMessage, const ::scoped_string & scopedstrTitle = nullptr, const ::user::e_message_box& emessagebox = ::user::e_message_box_ok);
357 //{
358 //
359 // return message_box(nullptr, pszMessage, pszTitle, emessagebox, process);
360
361 //}
362
363
364 //virtual void message_box_timeout(const ::scoped_string & scopedstrMessage, const ::scoped_string & scopedstrTitle = nullptr, const class time & timeTimeout = ::time::infinite(), const ::user::e_message_box & emessagebox = ::user::e_message_box_ok, const ::future & future = ::future());
365 //{
366
367 // return message_box_timeout(nullptr, pszMessage, pszTitle, timeTimeout, emessagebox, process);
368
369 //}
370
371 //virtual void message_box(::user::interaction_base* puiOwner, const ::scoped_string & scopedstrMessage, const ::scoped_string & scopedstrTitle = nullptr, const ::user::e_message_box & emessagebox = ::user::e_message_box_ok, const ::future & future = ::future());
372 //virtual void message_box_timeout(::user::interaction_base* puserinteractionOwner, const ::scoped_string & scopedstrMessage, const ::scoped_string & scopedstrTitle = nullptr, const class ::time& timeTimeout = ::time::infinite(), const ::user::e_message_box & emessagebox = ::user::e_message_box_ok, const ::future & future = ::future());
373
374 virtual void release_references();
375
376 virtual ::pointer<::matter>running(const ::scoped_string & scopedstrTag) const;
377
378 virtual bool ___is_reference(::particle * pparticle) const;
379
380 virtual bool __is_composite(::particle * pparticle) const;
381
382 virtual bool __is_child_task(::particle * ptask) const;
383
384 virtual void on_finalize();
385
386 virtual void call_request(::create* pcreate);
387
389 //virtual ::user::document* open_new_document(::apex::application* pappOnBehalfOf);
390 //virtual void on_request(::create* pcreate);
391 //
392 virtual void main();
393 //
394 //virtual ::user::document* open_document_file(::apex::application* pappOnBehalfOf);
395 //virtual ::user::document* open_document_file(::apex::application* pappOnBehalfOf, const ::payload& payloadFile, const ::payload & varOptions, ::user::interaction* puiParent = nullptr, ewindowflag eflag = e_window_flag_none, ::atom atom = ::atom());
396 //virtual ::user::document* open_document_file(::apex::application* pappOnBehalfOf, const ::payload& payloadFile);
397 //virtual ::user::document* create_subdocument(::user::impact_data* pimpactdata);
398
399
400 virtual void run() override;
401
402 virtual string lstr(const ::atom& atom, const ::scoped_string & scopedstrDefault = "");
403
404 virtual string __get_text(const ::scoped_string & scopedstr);
405
406 //template < typename PRED >
407 //::image::image_pointer get_image(const ::payload & payloadFile, ::u64 uTrait, PRED pred);
408
409 //virtual ::image::image_pointer load_image(const ::payload & payloadFile, bool bSync = true, bool bCache = true, bool bCreateHelperMaps = false);
410 //virtual ::image::image_pointer load_matter_image(const ::scoped_string & scopedstrMatter, bool bSync = true, bool bCache = true, bool bCreateHelperMaps = false);
411 //virtual ::image::image_pointer load_matter_icon(string_array_base & straMatter, const ::scoped_string & scopedstrIcon);
412 //virtual ::image::image_pointer load_thumbnail(const ::payload & payloadFile, ::i32 w, ::i32 h);
413 //virtual ::image::image_pointer load_thumbnail(const ::file::path & path);
414 //virtual ::image::image_pointer load_dib(const ::file::path & pathDib);
415
416
417
418 bool IsSerializable() const;
419
420
421 void start();
422
423
424 void single_fork(const ::procedure_array& routinea);
425 void multiple_fork(const ::procedure_array& routinea);
426
427 using topic::manager::defer_fork;
428
429 template < typename THREAD >
430 inline ::pointer<THREAD> defer_fork(::pointer<THREAD>pthread, const ::procedure & procedure)
431 {
432
433 if (pthread && pthread->is_running())
434 {
435
436 return pthread;
437
438 }
439
440 pthread->start(routine);
441
442 return pthread;
443
444 }
445
446
447 template < typename THREAD >
448 inline ::pointer<THREAD> defer_fork(::pointer<THREAD>pthread)
449 {
450
451 if (pthread && pthread->is_running())
452 {
453
454 return pthread;
455
456 }
457
458 pthread->begin_thread();
459
460 return pthread;
461
462 }
463
464
465 inline void defer_fork(::thread_pointer& pthread, const ::procedure & procedure);
466
467
468 //template < typename THREAD >
469 //inline ::pointer<THREAD> start(::pointer<THREAD> pthread)
470 //{
471
472 // pthread->_start(pthread);
473
474 // return pthread;
475
476 //}
477
478
479 //template < typename PRED >
480 //inline ::thread_pointer fork(PRED pred);
481 ::thread_pointer fork(const ::add_procedure & procedure);
482
483
484 //inline ::thread_pointer launch(const ::procedure & procedure);
485
486
487 //template < typename METHOD >
488 inline ::task_pointer opt_fork(const ::procedure & procedure)
489 {
490
491 auto ptask = ::get_task();
492
493 synchronous_lock synchronouslock(ptask->synchronization(), DEFAULT_SYNCHRONOUS_LOCK_SUFFIX);
494
495 if (ptask && ptask->m_bIsPredicate)
496 {
497
498 routine();
499
500 return ptask;
501
502 }
503
504 return launch(routine);
505
506 }
507
508
509 //template < typename METHOD >
510 //inline ::thread_pointer fork(METHOD method);
511
512
513 template < typename PREDICATE >
514 inline auto new_predicate_task(PREDICATE pred);
515 //inline auto new_predicate_task(PRED pred);
516
517 template < typename TYPE >
518 inline auto async(void (TYPE::* pfnMemberProcedure)())
519 {
520
521 return fork([this, pfnMemberProcedure]()
522 {
523
524 TYPE* ptype = dynamic_cast <TYPE*> (this);
525
526 (ptype->*pfnMemberProcedure)();
527
528 });
529
530 }
531
532 //template < typename PRED >
533 inline ::thread_pointer predicate_run(bool bSync, const ::add_procedure & procedure);
534
535 ::thread_pointer begin(
536 ::enum_priority epriority = ::e_priority_normal,
537 ::u32 nStackSize = 0,
538 ::u32 dwCreateFlags = 0 ARG_SEC_ATTRS_DEF);
539
540 //::thread_pointer defer_fork(const ::scoped_string & scopedstrThread = "");
541
542//#ifdef __APPLE__
543// virtual void ns_main_async(dispatch_block_t block);
544//#endif
545
546 //inline ::file_pointer get_reader(const ::payload& payloadFile, ::file::e_open eopen = ::file::e_open());
547 //inline ::file_pointer get_writer(const ::payload& payloadFile, ::file::e_open eopen = ::file::e_open());
548
549
550 //virtual void to_string(string & str) const override;
551
552
553 virtual ::file_pointer get_file(const ::payload& payloadFile, ::file::e_open eopen);
554 inline ::file_pointer get_reader(const ::payload& payloadFile, ::file::e_open eopen = ::file::e_open_binary);
555 inline ::file_pointer get_writer(const ::payload& payloadFile, ::file::e_open eopen = ::file::e_open_binary | ::file::e_open_defer_create_directory | ::file::e_open_create);
556
557
558
559 //void add_update_notification(property * pproperty);
560 //void add_update_notification(const ::atom & atom, bool bCreate = true);
561 //void property_notify(const ::atom & atom, ::matter * pmatter);
562
563
564// inline void format_topic_text(const ::scoped_string & scopedstr, ...)
565// {
566//
567// va_list valist;
568// va_start(valist, psz);
569// format_topic_text_v(scopedstr, valist);
570// va_end(valist);
571//
572// }
573//
574//
575// inline void format_topic_text_v(const ::scoped_string & scopedstr, va_list valist)
576// {
577//
578// string str;
579// str.formatf_arguments(scopedstr, valist);
580// set_topic_text(str);
581//
582// }
583
584
585 //template < typename TYPE >
586 //auto member_fork(void (TYPE:: * pfn)(), ::enum_priority epriority = ::e_priority_normal)
587 //{
588
589 // TYPE * ptype = dynamic_cast <TYPE *>(this);
590
591 // return ptype->fork([ptype, pfn]()
592 // {
593
594 // return (ptype->*pfn)();
595
596 // }, NULL, 0, epriority);
597
598 //}
599
600
601 template < typename TYPE >
602 ::thread_pointer start_below_normal(void (TYPE::* pfn)())
603 {
604
605 return fork(pfn, ::e_priority_below_normal);
606
607 }
608
609
610 //template < typename TYPE >
611 //void constructø(::thread_pointer& p, void (TYPE::* pfn)(), enum_priority epriority);
612
613 template < typename TYPE >
614 void __construct_below_normal(::thread_pointer& p, void (TYPE::* pfn)());
615
616
617 template < typename TYPE >
618 ::thread_pointer __start_thread(const ::atom& atom, void(TYPE::* pfn)(), enum_priority epriority = e_priority_normal);
619
620
621 virtual matter* get_taskpool_container() override;
622
623
624};
625
626
627#define __make_identifier(PART1, PART2) PART1 ## PART2
628
629
630#define __defer_fork(ID) \
631 \
632do \
633{ \
634 \
635 auto & pthread = m_pthread ## ID; \
636 \
637 if(!pthread) \
638 { \
639 \
640 constructø(pthread); \
641 \
642 pthread->m_pmatter = __routine([this]() \
643 { \
644 \
645 ID ## ThreadProcedure(); \
646 \
647 }); \
648 \
649 } \
650 \
651 defer_fork(pthread); \
652 \
653} while(false) \
654 \
655
656
657
658CLASS_DECL_APEXvoid call_sync(const ::procedure_array& routinea);
659
660
661
662
663
Definition object_meta.h:10
virtual void destroy() override
Definition bbb_context_object.cpp:242
::pointer< BASE_TYPE > file_as(const ::payload &payloadFile)
bind(referer, referee, ...) __m_bind(referer, (referer)->referee, __VA_ARGS)
Definition task.h:117
Definition aaa_time.h:13