acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
_impl.h
1#pragma once
2
3
4#include "acme/prototype/comparison/equals.h"
5//#include "particle_factory.h"
6#include "acme/exception/no_memory.h"
7
8
9#include "acme/prototype/prototype/_impl_pointer.h"
10#include "acme/prototype/prototype/_impl_ptr.h"
11
12
13#include "acme/prototype/prototype/_impl_factory.h"
14
15
16
17//inline bool __enum_is_failed(const ::e_status & e)
18//{
19//
20// return ::failed(e);
21//
22//}
23
24
25#include "acme/prototype/prototype/_impl_atom.h"
26#include "acme/prototype/prototype/_impl_prototype.h"
27#include "acme/prototype/prototype/_impl_type.h"
28
29//inline bool succeeded(const ::property & property)
30//{
31//
32// return ::succeeded((const ::payload &) property);
33//
34//}
35
36
37template < typename BASE_TYPE >
38inline ::pointer<BASE_TYPE>particle::__call__create(::factory::factory* pfactory)
39{
40
41 if (::is_null(pfactory))
42 {
43
44 pfactory = this->factory();
45
46 }
47
48 auto pfactoryitem = pfactory->get_factory_item<BASE_TYPE>();
49
50 if (!pfactoryitem)
51 {
52
53 throw ::exception(error_no_factory);
54
55 }
56
57 auto p = pfactoryitem->__call__create_particle();
58
59 if (!p)
60 {
61
62 throw ::exception(error_wrong_type);
63
64 }
65
66 p->initialize(this);
67
68 return p;
69
70}
71
72
73//template < typename BASE_TYPE >
74//inline ::pointer<BASE_TYPE>particle::øcreate_by_type(const ::atom & atom, ::factory::factory* pfactory)
75//{
76//
77// auto pfactoryitem = pfactory->get_factory_item(atom);
78//
79// if (!pfactoryitem)
80// {
81//
82// throw ::exception(error_no_factory);
83//
84// }
85//
86// auto p = pfactoryitem->__call__create_particle();
87//
88// if (!p)
89// {
90//
91// throw ::no_memory();
92//
93// }
94//
95// p->initialize(this);
96//
97// return p;
98//
99//}
100
101
102template < typename TYPE >
103inline ::pointer<TYPE>particle::__call__create_new()
104{
105
106 //ASSERT(::is_set(this));
107
108 //return __call__create_new<TYPE>(this);
109
110 //if (::is_null(pparticle))
111 //{
112
113 // throw_exception(error_wrong_state);
114
115 //}
116
117 ::pointer < TYPE > p = { transfer_t{}, __new_refdbg_continuation TYPE() };
118
119 if (p)
120 {
121
122 p->initialize(this);
123
124 }
125
126 return ::transfer(p);
127
128
129 //return p;
130
131}
132
133
134template < typename TYPE >
135inline ::pointer<TYPE>particle::__call__create_new_clone(TYPE * psrc)
136{
137
138 //ASSERT(::is_set(this));
139
140 //return __call__create_new<TYPE>(this);
141
142 //if (::is_null(pparticle))
143 //{
144
145 // throw_exception(error_wrong_state);
146
147 //}
148
149 ::pointer < TYPE > ptypeNew = { transfer_t{}, __new_refdbg_continuation TYPE() };
150
151 if (ptypeNew)
152 {
153
154 ptypeNew->initialize(this);
155
156 }
157
158 *ptypeNew = *psrc;
159
160 return ::transfer(ptypeNew);
161
162
163 //return p;
164
165}
166
167//template < class T >
168//template < typename TEMPLATER >
169//inline pointer < T > & pointer < T >::create(TEMPLATER)
170//{
171//
172// constructø(*this);
173//
174// return *this;
175//
176//}
177
178
179
180template < typename BASE_TYPE >
181inline void particle::__call__construct(::pointer<BASE_TYPE>& p, ::factory::factory * pfactory)
182{
183
184 if (::is_null(pfactory))
185 {
186
187 pfactory = this->factory();
188
189 }
190
191 if (!pfactory)
192 {
193
194 throw ::exception(::error_no_factory);
195
196 }
197
198 auto pfactoryitem = pfactory->get_factory_item < BASE_TYPE >();
199
200 if (!pfactoryitem)
201 {
202
203 ::string strError;
204
205 strError.format("No factory for type : '{}'", ::type<BASE_TYPE>().name());
206
207 error() << strError;
208
209 throw ::exception(::error_no_factory, strError);
210
211 }
212
213 auto ptypeNew = pfactoryitem->__call__create_particle();
214
215 p = ::transfer(ptypeNew);
216
217 if (!p)
218 {
219
220 throw ::exception(error_wrong_type);
221
222 }
223
224 p->initialize(this);
225
226
227}
228
229
230//
231//
232//template < typename BASE_TYPE >
233//inline void matter::øraw_construct(::pointer<BASE_TYPE>& p)
234//{
235//
236// if (!p)
237// {
238//
239// auto & pfactory = factory_item < BASE_TYPE >();
240//
241// if (!pfactory)
242// {
243//
244// return ::error_no_factory;
245//
246// }
247//
248// auto ptypeNew = pfactory->call_new();
249//
250// if (!ptypeNew)
251// {
252//
253// return ::error_no_memory;
254//
255// }
256//
257// p = ptypeNew;
258//
259// if (!p)
260// {
261//
262// return error_wrong_type;
263//
264// }
265//
266// auto estatus = add_composite(p);
267//
268// if (!estatus)
269// {
270//
271// return estatus;
272//
273// }
274//
275// }
276//
277// return ::success;
278//
279//}
280//
281//
282//template < typename BASE_TYPE, typename SOURCE >
283//inline void matter::constructø(::pointer<BASE_TYPE>& p, const SOURCE * psource)
284//{
285//
286// p = psource;
287//
288// if (!p)
289// {
290//
291// return error_wrong_type;
292//
293// }
294//
295// auto estatus = p->initialize(this);
296//
297// if (!estatus)
298// {
299//
300// return estatus;
301//
302// }
303//
304// m_estatus = add_composite(p);
305//
306// return m_estatus;
307//
308//}
309//
310//template < typename BASE_TYPE, typename SOURCE >
311//inline void matter::øraw_construct(::pointer<BASE_TYPE>& p, const SOURCE * psource)
312//{
313//
314// p = psource;
315//
316// if (!p)
317// {
318//
319// return error_wrong_type;
320//
321// }
322//
323// m_estatus = add_composite(p);
324//
325// return m_estatus;
326//
327//}
328//
329//template < typename BASE_TYPE, typename SOURCE >
330//inline void matter::constructø(::pointer<BASE_TYPE>& p, const ::pointer<SOURCE> psource)
331//{
332//
333// return constructø(p, psource.get());
334//
335//}
336//
337//
338//template < typename BASE_TYPE, typename SOURCE >
339//inline void matter::øraw_construct(::pointer<BASE_TYPE>& p, const ::pointer<SOURCE> psource)
340//{
341//
342// return øraw_construct(p, psource.get());
343//
344//}
345//
346//
347//
348//template < typename BASE_TYPE >
349//inline void matter::øconstruct_by_id(::pointer<BASE_TYPE>& p, const ::atom & atom)
350//{
351//
352// auto & pfactory = factory_item(atom);
353//
354// if (!pfactory)
355// {
356//
357// return ::error_no_factory;
358//
359// }
360//
361// auto ptypeNew = pfactory->call_new();
362//
363// if (!ptypeNew)
364// {
365//
366// return ::error_no_memory;
367//
368// }
369//
370// p = ptypeNew;
371//
372// if (!p)
373// {
374//
375// return ::error_wrong_type;
376//
377// }
378//
379// auto estatus = p->initialize(this);
380//
381// if (!estatus)
382// {
383//
384// return estatus;
385//
386// }
387//
388// estatus = add_composite(p);
389//
390// if (!estatus)
391// {
392//
393// return estatus;
394//
395// }
396//
397// return estatus;
398//
399//}
400//
401//
402//template < typename TYPE >
403//inline void matter::__raw_construct_new(::pointer<TYPE>& p)
404//{
405//
406// auto ptypeNew = allocateø TYPE();
407//
408// if (!ptypeNew)
409// {
410//
411// return ::error_no_memory;
412//
413// }
414//
415// p = ptypeNew;
416//
417// auto estatus = add_composite(p);
418//
419// if (!estatus)
420// {
421//
422// p.clear_member();
423//
424// return estatus;
425//
426// }
427//
428// return estatus;
429//
430//}
431
432
433template < typename TYPE >
434inline void particle::__call__construct_new(::pointer<TYPE>& p)
435{
436
437//#if REFERENCING_DEBUGGING
438//
439// ::allocator::add_referer(REFERENCING_DEBUGGING_ARGUMENTS);
440//
441//#endif
442//
443 ::pointer < TYPE > ptypeNew = { transfer_t{}, __new_refdbg_continuation TYPE() };
444
445 if (!ptypeNew)
446 {
447
448 throw ::no_memory();
449
450 }
451
452 p = ::transfer(ptypeNew);
453
454 //ptypeNew.set_referer();
455
456 //p.reset(ptypeNew);
457
458 p->initialize(this);
459
460}
461
462
463//template < typename TYPE >
464//inline void particle::__call__raw_construct( ::pointer<TYPE> & p)
465//{
466//
467//#if REFERENCING_DEBUGGING
468//
469// ::allocator::add_referer(REFERENCING_DEBUGGING_ARGUMENTS);
470//
471//#endif
472//
473// auto ptypeNew = allocateø TYPE();
474//
475// if (!ptypeNew)
476// {
477//
478// throw ::no_memory();
479//
480// }
481//
482// p = ::transfer(ptypeNew);
483//
484// //ptypeNew.set_referer();
485//
486// //p.reset(ptypeNew);
487//
488// p->initialize(this);
489//
490//}
491
492//
493//template < typename TYPE >
494//inline void matter::constructø(::pointer<TYPE>& p)
495//{
496//
497// auto estatus = ::constructø(p);
498//
499// if (estatus && p)
500// {
501//
502// estatus = p->initialize(this);
503//
504// }
505//
506// return estatus;
507//
508//}
509//
510//
511//template < typename TYPE >
512//inline void matter::øconstruct_by_id(::pointer<TYPE>& p, const ::atom & atom)
513//{
514//
515// auto estatus = ::øconstruct_by_id(p, atom);
516//
517// if (estatus && p)
518// {
519//
520// estatus = p->initialize(this);
521//
522// }
523//
524// return estatus;
525//
526//}
527//
528//
529//template < typename TYPE >
530//inline void matter::construct_newø(::pointer<TYPE>& p)
531//{
532//
533// auto estatus = ::construct_newø(p);
534//
535// if(estatus.succeeded())
536// {
537//
538// estatus = p->initialize(this);
539//
540// }
541//
542// return estatus;
543//
544//}
545//
546//
547//template < typename BASE_TYPE >
548//inline void matter::__release(::pointer<BASE_TYPE>& pcomposite)
549//{
550//
551// if (pcomposite)
552// {
553//
554// synchronous_lock synchronouslock(this->synchronization(), DEFAULT_SYNCHRONOUS_LOCK_SUFFIX);
555//
556// if (m_pcompositea)
557// {
558//
559// if (m_pcompositea->erase(pcomposite) >= 0)
560// {
561//
562// pcomposite->release();
563//
564// pcomposite.clear_member();
565//
566// }
567//
568// }
569//
570// }
571//
572// return ::success;
573//
574//}
575//
576//
577//template < typename BASE_TYPE >
578//inline void matter::__release(::pointer<BASE_TYPE>& preference)
579//{
580//
581// if (preference)
582// {
583//
584// synchronous_lock synchronouslock(this->synchronization(), DEFAULT_SYNCHRONOUS_LOCK_SUFFIX);
585//
586// if (m_preferencea)
587// {
588//
589// if (m_preferencea->erase(preference.get()) >= 0)
590// {
591//
592// preference->release();
593//
594// preference.clear_member();
595//
596// }
597// else
598// {
599//
600// return ::error_failed;
601//
602// }
603//
604// }
605//
606// }
607//
608// return ::success;
609//
610//}
611//
612//
613//template < typename SOURCE >
614//inline void matter::release_reference(::pointer<SOURCE>& psource)
615//{
616//
617// return release_reference(psource.m_p);
618//
619//}
620//
621//
622//CLASS_DECL_ACME void object_on_add_composite(const matter * p);
623//
624//
625//template < typename BASE_TYPE >
626//inline void matter::add_composite(::pointer<BASE_TYPE>& pcomposite)
627//{
628//
629// return add_composite(pcomposite.get());
630//
631//}
632//
633//
634//template < typename BASE_TYPE, typename SOURCE >
635//inline void matter::__refer(::pointer<BASE_TYPE>& preference, const ::pointer<SOURCE> psource, const ::scoped_string & scopedstrObjRefDbg)
636//{
637//
638// return __refer(preference, psource.get(), pszObjRefDbg);
639//
640//}
641//
642//
643//template < typename BASE_TYPE, typename SOURCE >
644//inline void matter::__refer(::pointer<BASE_TYPE>& preference, const ::prototype::member < SOURCE > & pmember, const ::scoped_string & scopedstrObjRefDbg)
645//{
646//
647// return __refer(preference, pmember.get(), pszObjRefDbg);
648//
649//}
650//
651//
652//template < typename BASE_TYPE, typename SOURCE >
653//inline void matter::__refer(::pointer<BASE_TYPE>& preference, const SOURCE * psource, const ::scoped_string & scopedstrObjRefDbg)
654//{
655//
656// preference = psource;
657//
658// if (!preference)
659// {
660//
661// return error_wrong_type;
662//
663// }
664//
665// return add_reference(preference);
666//
667//}
668//
669//
670//template < typename SOURCE >
671//inline void matter::add_reference(::pointer<SOURCE>& psource)
672//{
673//
674// return add_reference(psource.get());
675//
676//}
677//
678//
679//template < typename SOURCE >
680//inline void matter::add_reference(::pointer<SOURCE>& preference)
681//{
682//
683// return add_reference(preference.get());
684//
685//}
686//
687//
688//template < typename SOURCE >
689//inline void matter::add_reference(SOURCE * psource)
690//{
691//
692// ::pointer<::matter>pparticle;
693//
694// pparticle = (SOURCE *) psource;
695//
696// if (!pparticle)
697// {
698//
699// return error_wrong_type;
700//
701// }
702//
703// return add_reference((::matter *) pparticle.m_p);
704//
705//}
706//
707//
708
709
710template < typename T >
711inline ::pointer < T > pointer_transfer(T* p) { return { transfer_t{}, p}; }
712
713
714//template < typename TYPE >
715//TYPE & operator |=(TYPE & o, eobject)
716//{
717//
718// o.set(eobject);
719//
720// return o;
721//
722//}
723//
724//
725//template < typename TYPE >
726//TYPE & operator +=(TYPE & o, eobject)
727//{
728//
729// o.set(eobject);
730//
731// return o;
732//
733//}
734//
735//
736//template < typename TYPE >
737//TYPE & operator -=(TYPE & o, eobject)
738//{
739//
740// o.clear(eobject);
741//
742// return o;
743//
744//}
745
746
747//template < typename T >
748//template < typename TEMPLATER >
749//inline pointer < T > & pointer<T> ::defer_create(TEMPLATER)
750//{
751//
752// if (is_null())
753// {
754//
755// operator=(createø < TYPE >());
756//
757// }
758//
759// return *this;
760//
761//}
762//
763
764
765
766//template < class T >
767//inline stream & operator << (stream & os, const pointer < T > & sp)
768//{
769//
770// os << *sp.m_p;
771//
772// return os;
773//
774//}
775//
776//
777//template < class T >
778//inline stream & operator >> (stream & is, pointer < T > & sp)
779//{
780//
781// is >> *sp.m_p;
782//
783// return is;
784//
785//}
786//
787
788//inline void context::load_from_file(::particle * pparticle, const ::payload& payloadFile, const ::payload* pvarOptions)
789//{
790//
791// if (pvarOptions)
792// {
793//
794// return _load_from_file(pparticle, payloadFile, *pvarOptions);
795//
796// }
797// else
798// {
799//
800// return _load_from_file(pparticle, payloadFile, e_type_empty_argument);
801//
802// }
803//
804//}
805//
806//
807//inline void context::load_from_file(::particle * pparticle, const ::payload& payloadFile)
808//{
809//
810// return _load_from_file(pparticle, payloadFile, e_type_empty_argument);
811//
812//}
813//
814//
815//inline void context::save_to_file(const ::payload& payloadFile, const ::payload* pvarOptions, const ::particle * pparticle)
816//{
817//
818// if (pvarOptions)
819// {
820//
821// return _save_to_file(payloadFile, *pvarOptions, pparticle);
822//
823// }
824// else
825// {
826//
827// return _save_to_file(payloadFile, e_type_empty_argument, pparticle);
828//
829// }
830//
831//}
832//
833//
834//inline void context::save_to_file(const ::payload& payloadFile, const ::particle * pparticle)
835//{
836//
837// return _save_to_file(payloadFile, e_type_empty_argument, pparticle);
838//
839//}
840//
841//
842
843//
844//inline ::file_pointer matter::get_reader(const ::payload & payloadFile, ::file::e_open eopen)
845//{
846//
847// return get_file(payloadFile, eopen | ::file::e_open_read) ;
848//
849//}
850//
851//
852//inline ::file_pointer matter::get_writer(const ::payload & payloadFile, ::file::e_open eopen)
853//{
854//
855// return get_file(payloadFile, eopen | ::file::e_open_write);
856//
857//}
858
859
860
861
862
863
864//
865//template < typename TYPE >
866//inline void matter::set(const ::atom & atom, const TYPE & t)
867//{
868//
869// ::assign(value(atom), t);
870//
871// set(e_object_property_set_modified);
872//
873//}
874//
875//
876//template < typename TYPE >
877//inline void matter::get(const ::atom & atom, TYPE & t)
878//{
879//
880// ::assign(t, value(atom));
881//
882//}
883//
884
885//inline string & payload::as_string ()
886//{
887//
888// if (m_etype == ::e_type_payload_pointer)
889// {
890//
891// return m_ppayload->as_string();
892//
893// }
894// else if (m_etype == ::e_type_property)
895// {
896//
897// return m_pproperty->as_string();
898//
899// }
900// else if (m_etype == ::e_type_pstring)
901// {
902//
903// return *m_pstr;
904//
905// }
906// else if (m_etype != ::e_type_string)
907// {
908//
909// m_str = this->string();
910//
911// set_type(e_type_string, false);
912//
913// }
914//
915// return m_str;
916//
917//}
918
919
920//inline payload::operator string() const
921//{
922//
923// return get_string();
924//
925//}
926
927#define IMPL_VAR_REF(TYPE, VAR, NAME) \
928 inline TYPE & payload::as_ ## NAME() \
929 { \
930 \
931 if(m_etype == ::e_type_payload_pointer) \
932 { \
933 \
934 return m_ppayload->as_ ## NAME(); \
935 \
936 } \
937 else if(m_etype == ::e_type_property) \
938 { \
939 \
940 return m_pproperty->as_ ## NAME(); \
941 \
942 } \
943 else if(m_etype == ::e_type_p ## NAME) \
944 { \
945 \
946 return *m_p ## VAR; \
947 \
948 } \
949 else if(m_etype == ::e_type_ ## NAME) \
950 { \
951 \
952 return m_ ## VAR; \
953 \
954 } \
955 else \
956 { \
957 \
958 set_type(::e_type_ ## NAME, true); \
959 \
960 return m_ ## VAR; \
961 \
962 } \
963 \
964 }
965
966//
968//IMPL_VAR_REF(bool, b, bool);
971//
972//#define IMPL_VAR_REF2(TYPE, VAR) IMPL_VAR_REF(TYPE, VAR, VAR)
973//IMPL_VAR_REF2(::i8, ::i8);
974//IMPL_VAR_REF2(::u8, ::u8);
975//IMPL_VAR_REF2(::i16, ::i16);
976//IMPL_VAR_REF2(::u16, ::u16);
977//IMPL_VAR_REF2(::i32, ::i32);
978//IMPL_VAR_REF2(::u32, ::u32);
979//IMPL_VAR_REF2(::i64, ::i64);
980//IMPL_VAR_REF2(::u64, ::u64);
981//#undef IMPL_VAR_REF2
982
983
984//#define IMPL_VAR_REF3(TYPE, VAR) IMPL_VAR_REF(TYPE, VAR, TYPE)
985//IMPL_VAR_REF3(::f32, ::f32);
986//IMPL_VAR_REF3(::f64, ::f64);
987//#undef IMPL_VAR_REF3
988
989
990#undef IMPL_VAR_REF
991
992//
993//inline ::memory & payload::as_memory()
994//{
995//
996// return this->mem();
997//
998//}
999//
1000
1001//inline payload::memory() const
1002//{
1003//
1004// return this->memory();
1005//
1006//}
1007
1008
1009//inline void & payload::as_estatus()
1010//{
1011//
1012// if(m_etype == ::e_type_payload_pointer)
1013// {
1014//
1015// return m_ppayload->as_estatus();
1016//
1017// }
1018// else if(m_etype == ::e_type_property)
1019// {
1020//
1021// return m_pproperty->as_estatus();
1022//
1023// }
1024// else if(m_etype == ::e_type_enum_status)
1025// {
1026//
1027// return m_estatus;
1028//
1029// }
1030// else
1031// {
1032//
1033// set_type(::e_type_enum_status, true);
1034//
1035// return m_estatus;
1036//
1037// }
1038//
1039//}
1040
1041
1042//inline bool type::operator == (const ::atom& atom) const
1043//{
1044//
1045// return ::atom::operator ==(atom);
1046//
1047//}
1048
1049
1050//template < typename TYPE_CHAR >
1051//inline string_base < TYPE_CHAR >::string_base(const ::payload & payload) :
1052// string_base(payload.to_string())
1053//{
1054//
1055//
1056//}
1057
1058
1059//template < typename TYPE_CHAR >
1060//string_base < TYPE_CHAR >::string_base(const property& property) :
1061// string_base(property.to_string())
1062//{
1063//
1064//
1065//}
1066
1067
1068//template < typename TYPE_CHAR >
1069//string_base < TYPE_CHAR >::string_base(const atom& atom) :
1070// string_base(atom.to_string())
1071//{
1072//
1073//
1074//}
1075
1076
1077
1078
1079
1080//template < typename PRED >
1081//void method::pred(PRED pred)
1082//{
1083//
1084// m_pparticle = method(pred);
1085//
1086//}
1087//
1088
1089//template < typename PRED >
1090//inline void future::pred(PRED pred)
1091//{
1092//
1093// m_pparticle = allocateø predicate_future < PRED > (pred);
1094//
1095//}
1096//
1097//
1098//
1099
1100//template < typename TYPE >
1101//inline ::pointer<TYPE>element::cast(const ::atom & atom)
1102//{
1103//
1104// return value(atom).cast < TYPE>();
1105//
1106//}
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116//
1117//template < typename PRED >
1118//inline ::collection::count fork_count_end(::particle * pparticle, ::collection::count iCount, PRED pred, ::collection::index iStart, ::enum_priority epriority)
1119//{
1120//
1121// if (iCount <= 0)
1122// {
1123//
1124// return -1;
1125//
1126// }
1127//
1128// auto pgroup = system()->task_group(epriority);
1129//
1130// synchronous_lock slGroup(pgroup->synchronization(), DEFAULT_SYNCHRONOUS_LOCK_SUFFIX);
1131//
1132// /// auto ptool = system()->task_tool(op_fork_count);
1133//
1134// if (pgroup == nullptr || pgroup->get_count() <= 1)
1135// {
1136//
1137// for (::collection::index i = iStart; i < iCount; i++)
1138// {
1139//
1140// pred(i);
1141//
1142// }
1143//
1144// return 1;
1145//
1146// }
1147//
1148// if (!pgroup->prepare(::e_thread_op_fork_count, iCount - iStart))
1149// {
1150//
1151// return -1;
1152//
1153// }
1154//
1155// synchronization_array ptra;
1156//
1157// ::collection::count iScan = maximum(1, minimum(iCount - iStart, pgroup->thread_count()));
1158//
1159// for (::collection::index iOrder = 0; iOrder < iScan; iOrder++)
1160// {
1161//
1162// ::pointer<predicate_holder_base>p = allocateø forking_count_predicate < PRED > (iOrder, iOrder + iStart, iScan, iCount, pred);
1163//
1164// if (!pgroup->add_predicate(p))
1165// {
1166//
1167// return -1;
1168//
1169// }
1170//
1171// }
1172//
1173// if (!(*pgroup)())
1174// {
1175//
1176// return -1;
1177//
1178// }
1179//
1180// return iScan;
1181//
1182//}
1183//
1184
1185//inline void future::operator()(const ::payload & payload) const
1186//{
1187//
1188// if (!m_pparticle)
1189// {
1190//
1191// return;
1192//
1193// }
1194//
1195// return m_pparticle->receive_response(payload);
1196//
1197//}
1198//
1199
1200
1201//template < typename PRED >
1202//method::method(PRED pred) : function(allocateø< predicate_method < PRED > >(pred)) { }
1203//
1204//
1205//template < typename PRED >
1206//future::future(PRED pred) : function(allocateø< predicate_future < PRED > >(pred)) { }
1207
1208
1209
1210
1211//inline void method::operator()() const
1212//{
1213//
1214// return ::is_set(m_pparticle) ? m_pparticle->call() : (void) ::success_none;
1215//
1216//}
1217
1218
1219
1220#if REFERENCING_DEBUGGING
1221
1222
1223template < typename TYPE, typename T >
1224void reference_count_debug_assign(::pointer<TYPE>& ptr, T * p)
1225{
1226
1227 auto pold = ptr.m_p;
1228
1229 ptr.m_p = p;
1230
1231 p->increment_reference_count();
1232
1233 reference_count_debug_release(pold);
1234
1235}
1236
1237
1238template < typename TYPE >
1239void reference_count_debug_release(::pointer<TYPE>& ptr)
1240{
1241
1242 reference_count_debug_release(ptr.m_p);
1243
1244}
1245
1246
1247template < typename TYPE >
1248void reference_count_debug_release(TYPE * & p)
1249{
1250
1251 release(p);
1252
1253}
1254
1255
1256#endif
1257
1258
1259//inline bool class ::time::done(const class time & time) const { return elapsed(class ::time).m_i32 >= 0; }
1260//inline bool class ::time::done() const { return elapsed().m_i32 >= 0; }
1261
1262
1263
1264
1265
1266
1267//template < typename BASE_TYPE >
1268//inline void object::constructø(::pointer<BASE_TYPE> pcomposite)
1269//{
1270//
1271// if (!pcomposite)
1272// {
1273//
1274// auto& pfactory = factory_item < BASE_TYPE >();
1275//
1276// if (!pfactory)
1277// {
1278//
1279// throw ::exception(error_no_factory);
1280//
1281// }
1282//
1283// auto pelement = ::transfer(pfactory->create_element());
1284//
1285// if (!pelement)
1286// {
1287//
1288// throw ::exception(error_no_memory);
1289//
1290// }
1291//
1292// pcomposite = pelement;
1293//
1294// if (!pcomposite)
1295// {
1296//
1297// throw ::exception(error_wrong_type);
1298//
1299// }
1300//
1301// /*auto estatus = */ pcomposite->initialize(this);
1302//
1303// //if (!estatus)
1304// //{
1305//
1306// // return estatus;
1307//
1308// //}
1309//
1310// /*estatus = */ add_composite(pcomposite);
1311//
1312// //if (!estatus)
1313// //{
1314//
1315// // return estatus;
1316//
1317// //}
1318//
1319// }
1320//
1321// //return ::success;
1322//
1323//}
1324//
1325
1326//
1327//template < typename BASE_TYPE, typename SOURCE >
1328//inline void object::constructø(::pointer<BASE_TYPE> pcomposite, const SOURCE* psource)
1329//{
1330//
1331// pcomposite = psource;
1332//
1333// if (!pcomposite)
1334// {
1335//
1336// throw ::exception(error_wrong_type);
1337//
1338// }
1339//
1340// //auto estatus = pcomposite->initialize(this);
1341// pcomposite->initialize(this);
1342//
1343// //if (!estatus)
1344// //{
1345//
1346// // return estatus;
1347//
1348// //}
1349//
1350// add_composite(pcomposite);
1351//
1352// //return m_estatus;
1353//
1354//}
1355//
1356//template < typename BASE_TYPE, typename SOURCE >
1357//inline void object::øraw_construct(::pointer<BASE_TYPE> p, const SOURCE* psource)
1358//{
1359//
1360// p = psource;
1361//
1362// if (!p)
1363// {
1364//
1365// throw ::exception(error_wrong_type);
1366//
1367// }
1368//
1369// /*m_estatus = */ add_composite(p);
1370//
1371// //return m_estatus;
1372//
1373//}
1374//
1375//
1376//template < typename BASE_TYPE, typename SOURCE >
1377//inline void object::constructø(::pointer<BASE_TYPE> p, const ::pointer<SOURCE>psource)
1378//{
1379//
1380// /* return */ constructø(p, psource.get());
1381//
1382//}
1383//
1384//
1385//template < typename BASE_TYPE, typename SOURCE >
1386//inline void object::constructø(::pointer<BASE_TYPE> p, const ptr < SOURCE > & psource)
1387//{
1388//
1389// /* return */ constructø(p, psource.get());
1390//
1391//}
1392//
1393//
1394//template < typename BASE_TYPE, typename SOURCE >
1395//inline void object::øraw_construct(::pointer<BASE_TYPE> p, const ::pointer<SOURCE>psource)
1396//{
1397//
1398// /*return*/ øraw_construct(p, psource.get());
1399//
1400//}
1401//
1402//
1403//template < typename BASE_TYPE >
1404//inline void object::øconstruct_by_id(::pointer<BASE_TYPE> p, const ::atom& atom)
1405//{
1406//
1407// auto& pfactory = factory_item(atom);
1408//
1409// if (!pfactory)
1410// {
1411//
1412// throw ::exception(::error_no_factory);
1413//
1414// }
1415//
1416// auto ptypeNew = pfactory->create_element();
1417//
1418// if (!ptypeNew)
1419// {
1420//
1421// throw ::exception(::error_no_memory);
1422//
1423// }
1424//
1425// p = ptypeNew;
1426//
1427// if (!p)
1428// {
1429//
1430// throw ::exception(::error_wrong_type);
1431//
1432// }
1433//
1434// /*auto estatus =*/ p->initialize(this);
1435//
1436// //if (!estatus)
1437// //{
1438//
1439// // return estatus;
1440//
1441// //}
1442//
1443// /* estatus = */ add_composite(p);
1444//
1445// //if (!estatus)
1446// //{
1447//
1448// // return estatus;
1449//
1450// //}
1451//
1452// //return estatus;
1453//
1454//}
1455//
1456//
1457//template < typename TYPE >
1458//inline void object::__raw_construct_new(::pointer<TYPE> p)
1459//{
1460//
1461// auto ptypeNew = allocateø TYPE();
1462//
1463// if (!ptypeNew)
1464// {
1465//
1466// throw ::exception(::error_no_memory);
1467//
1468// }
1469//
1470// p = ptypeNew;
1471//
1472// /*auto estatus = */ add_composite(p);
1473//
1474// //if (!estatus)
1475// //{
1476//
1477// // p.clear_member();
1478//
1479// // return estatus;
1480//
1481// //}
1482//
1483// //return estatus;
1484//
1485//}
1486//
1487//
1488//template < typename TYPE >
1489//inline void object::construct_newø(::pointer<TYPE> p)
1490//{
1491//
1492// auto ptypeNew = allocateø TYPE();
1493//
1494// if (!ptypeNew)
1495// {
1496//
1497// throw ::exception(::error_no_memory);
1498//
1499// }
1500//
1501// /*auto estatus = */ ptypeNew->initialize(this);
1502//
1503// //if (!estatus)
1504// //{
1505//
1506// // return estatus;
1507//
1508// //}
1509//
1510// p = ptypeNew;
1511//
1512// /*estatus = */ add_composite(p REFERENCING_DEBUGGING_COMMA_P_FUNCTION_LINE(this));
1513//
1514// //if (!estatus)
1515// //{
1516//
1517// //p.clear_member();
1518//
1520//
1522//
1524//
1525//}
1526//
1527//
1528
1529
1530#define IMPL_VAR_REF(TYPE, VAR, ENUM) \
1531 inline payload::operator TYPE &() \
1532 { \
1533 \
1534 if(m_etype == ::type_pvar) \
1535 { \
1536 \
1537 return m_ppayload->operator TYPE &(); \
1538 \
1539 } \
1540 else if(m_etype == ::type_prop) \
1541 { \
1542 \
1543 return m_pproperty->operator TYPE &(); \
1544 \
1545 } \
1546 else if(m_etype == ::type_p ## ENUM) \
1547 { \
1548 \
1549 return *m_p ## VAR; \
1550 \
1551 } \
1552 else if(m_etype == ::type_ ## ENUM) \
1553 { \
1554 \
1555 return m_ ## VAR; \
1556 \
1557 } \
1558 else \
1559 { \
1560 \
1561 set_type(::type_ ## ENUM, true); \
1562 \
1563 return m_ ## VAR; \
1564 \
1565 } \
1566 \
1567 }
1568
1569
1570//template < typename TYPE >
1571//inline void object::constructø(::task_pointer& p, void (TYPE::* pfn)(), enum_priority epriority)
1572//{
1573//
1574// p = fork(pfn, epriority);
1575//
1576// if (!p)
1577// {
1578//
1579// throw ::exception(error_failed);
1580//
1581// }
1582//
1583//}
1584
1585
1586//template < typename TYPE >
1587//inline void object::__construct_below_normal(::task_pointer& p, void (TYPE::* pfn)())
1588//{
1589//
1590// return constructø(p, pfn, e_priority_below_normal);
1591//
1592//}
1593//
1594
1595//template < typename TYPE >
1596//inline ::task_pointer object::defer_branch(const ::atom& atom, void(TYPE::* pfn)(), enum_priority epriority)
1597//{
1598//
1599// auto pfork = fork(pfn, epriority);
1600//
1601// get_property_set()["thread"][atom] = pfork;
1602//
1603// return pfork;
1604//
1605//}
1606
1607
1608//template < typename PRED >
1609//inline void add_procedure(::procedure_array& routinea, PRED pred)
1610//{
1611//
1612// routinea.add(__routine(pred));
1613//
1614//}
1615
1616
1617
1618//template < typename POSTING_OBJECT, typename POSTING_METHOD, typename OBJECT_POINTER, typename OBJECT_METHOD >
1619//bool material_object::__get_posted_payload_synchronously(POSTING_OBJECT pposting, POSTING_METHOD posting_method, OBJECT_POINTER preturning, OBJECT_METHOD returning_method, ::payload & payload, const class time & timeWait)
1620//{
1621//
1622// if(pposting->is_branch_current())
1623// {
1624//
1625// payload = (preturning->*returning_method)();
1626//
1627// return true;
1628//
1629// }
1630//
1631// auto posting = [pposting, posting_method](const ::procedure & procedure)
1632// {
1633//
1634// (pposting->*posting_method)(procedure);
1635//
1636// };
1637//
1638// ::function < void(const ::procedure &) > functionPost(posting);
1639//
1640// ::function < ::payload() > functionReturn([preturning, returning_method]()
1641// {
1642//
1643// return (preturning->*returning_method)();
1644//
1645// });
1646//
1647// functionReturn.m_timeTimeout = wait;
1648//
1649// return __get_posted_payload_synchronously(functionPost, functionReturn, payload);
1650//
1651//}
1652//
1653//
1654//template < typename POSTING_OBJECT, typename POSTING_METHOD >
1655//void material_object::__send_procedure(POSTING_OBJECT pposting, POSTING_METHOD posting_method, const ::procedure & procedure)
1656//{
1657//
1658// if(pposting->is_branch_current())
1659// {
1660//
1661// return procedure();
1662//
1663// }
1664//
1665// auto posting = [pposting, posting_method](const ::procedure & procedure)
1666// {
1667//
1668// (pposting->*posting_method)(procedure);
1669//
1670// };
1671//
1672// __send_procedure(posting, procedure);
1673//
1674//}
1675//
1676
1677
1678
1679
1680
1681
1682//template < class T >
1683//inline pointer < T > & __move(pointer < T > & p, lparam & lparam)
1684//{
1685//
1686// pointer < T > pelement(lparam);
1687//
1688// if (::is_null(pelement))
1689// {
1690//
1691// ::release(pelement REFERENCING_DEBUGGING_COMMA_P_NOTE(nullptr, "pointer::pointer(LPARAM)"));
1692//
1693// }
1694//
1695// return pelement;
1696//
1697//}
1698
1699
1700//template < class T >
1701//template < typename PARTICLE >
1702//inline pointer < T > ::pointer(enum_create, PARTICLE * p) :
1703// m_p(nullptr),
1704// m_pparticle(nullptr)
1705//{
1706//
1707// operator=(p->createø < T >());
1708//
1709//}
1710
1711
1712
1713//inline e_check::e_check(const ::logic::boolean & triestate)
1714//{
1715//
1716// if (triestate == e_boolean_undefined)
1717// {
1718//
1719// m_echeck = e_check_undefined;
1720//
1721// }
1722// else if (triestate == e_boolean_yes)
1723// {
1724//
1725// m_echeck = e_check_checked;
1726//
1727// }
1728// else if (triestate == e_boolean_no)
1729// {
1730//
1731// m_echeck = e_check_unchecked;
1732//
1733// }
1734// else
1735// {
1736//
1737// m_echeck = e_check_tristate;
1738//
1739// }
1740//
1741//}
1742//
1743
1744//template < typename TYPE >
1745//inline bool particle::defer_constructø(::pointer<TYPE> & p, ::factory::factory * pfactory)
1746//{
1747//
1748// if (::is_set(p))
1749// {
1750//
1751// return false;
1752//
1753// }
1754//
1755// constructø(p, pfactory);
1756//
1757// return true;
1758//
1759//}
1760
1761
1762template < typename TYPE >
1763inline bool particle::__calldefer_construct_newø(::pointer<TYPE> & p)
1764{
1765
1766 if (::is_set(p))
1767 {
1768#if REFERENCING_DEBUGGING
1769
1770 ::allocator::defer_erase_referer();
1771#endif
1772 return false;
1773
1774 }
1775
1776 // in REFERENCING_DEBUGGING Mode set referer should
1777 // already be called when this function was called.
1778 __call__construct_new(p);
1779
1780 return true;
1781
1782}
1783
1784
1785template < typename TYPE >
1786inline bool particle::__call__defer_raw_construct_new(::pointer<TYPE>& p)
1787{
1788
1789 if (::is_set(p))
1790 {
1791#if REFERENCING_DEBUGGING
1792
1793 ::allocator::defer_erase_referer();
1794#endif
1795 return false;
1796
1797 }
1798
1799 // in REFERENCING_DEBUGGING Mode set referer should
1800 // already be called when this function was called.
1801 __call__raw_construct_new(p);
1802
1803 return true;
1804
1805}
1806
1807
1808constexpr ::e_status e_status::worst(const ::e_status & e) const
1809{
1810
1811 return (::e_status)(::enum_status)minimum((::i64)m_eenum, (::i64)e.m_eenum);
1812
1813}
1814
1815
1816constexpr ::i64 posix_time::minutes() const { return m_iSecond / 60; }
1817constexpr ::i64 posix_time::hours() const { return m_iSecond / (60 * 60); }
1818constexpr ::i64 posix_time::days() const { return m_iSecond / (24 * 60 * 60); }
1819
1820
1821
1822//template < typename T, typename ...Args >
1823//inline ::pointer < T > particle::__call_allocate(Args &&... args)
1824//{
1825//
1826// auto p = ::transfer(
1827// ::platform::allocator::__call_allocate< T >(
1828// ::std::forward<Args>(args)...));
1829//
1830// return ::transfer(p);
1831//
1832//}
1833//
1834
1835//inline ::particle * particle::__call__add_referer(const ::reference_referer & referer) const
1836//{
1837//
1838// ::allocator::add_referer(referer);
1839//
1840// return (::particle *)this;
1841//
1842//}
1843
1844
1845
Definition factory.h:201
Definition ptr.h:17
Definition _structures.h:6