acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
function.h
1// Created by camilo on 2022-03-20 11:35 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5
6//#define __pointer_is_null(p) (((uptr)(void *) p) < 4096)
7//
8//#define __pointer_is_set(p) (!__pointer_is_null(p))
9
10//#include <ios>
11//#include <ratio>
12
13#include "acme/prototype/prototype/transfer.h"
14
15#include "acme/prototype/prototype/pointer.h"
16
17#include "acme/prototype/prototype/subparticle.h"
18
19#include "acme/prototype/time/_time.h"
20
21CLASS_DECL_ACME class ::time default_run_timeout();
22
23// template < typename BASE_TYPE >
24// class add_particle_timeout :
25// virtual public BASE_TYPE
26// {
27// public:
28//
29// class ::time m_timeTimeout;
30//
31// add_particle_timeout() :
32// m_timeTimeout(default_run_timeout())
33// {
34//
35//
36//
37// }
38// add_particle_timeout(const class ::time & timeTimeout)
39// {
40//
41// if (timeTimeout.is_null())
42// {
43//
44// m_timeTimeout = default_run_timeout();
45//
46// }
47// else
48// {
49//
50// m_timeTimeout = timeTimeout;
51//
52// }
53//
54// }
55//
56// void set_timeout(const class ::time & timeTimeout) override
57// {
58//
59// m_timeTimeout = timeTimeout;
60// }
61//
62// [[nodiscard]] class ::time timeout() const override
63// {
64//
65// return m_timeTimeout;
66//
67// }
68// };
69
70
71template < typename ENTITY, typename... ARGUMENTS >
72concept callable = ::std::is_invocable< ENTITY, ARGUMENTS... >::type;
73
74template < typename ENTITY, typename RESULT, typename... ARGUMENTS >
75concept callable_with_result = ::std::is_invocable_r< RESULT, ENTITY, ARGUMENTS... >::type;
76
77template <typename T>
78constexpr bool is_lvalue_helper = std::is_lvalue_reference<T>::value;
79
80template <typename T>
81constexpr bool is_xvalue_helper = std::is_rvalue_reference<T>::value;
82
83template <typename T>
84constexpr bool is_prvalue_helper = !(is_lvalue_helper<T> || is_xvalue_helper<T>);
85
86template <typename T>
87constexpr bool is_rvalue_helper = is_xvalue_helper<T> || is_prvalue_helper<T>;
88
89template <typename T>
90constexpr bool is_glvalue_helper = is_xvalue_helper<T> || is_lvalue_helper<T>;
91
92#define is_left_instance(type_instance) is_lvalue_helper<decltype((type_instance))>
93#define is_xvalue(type_instance) is_xvalue_helper<decltype((type_instance))>
94#define is_prvalue(type_instance)is_prvalue_helper<decltype((type_instance))>
95#define is_right_instance(type_instance) is_rvalue_helper<decltype((type_instance))>
96#define is_glvalue(type_instance)is_glvalue_helper<decltype((type_instance))>
97
98
99enum enum_use
100{
101
102 e_use,
103
104}; // enum enum_use
105
106
107enum enum_as_lparam
108{
109
110 e_as_lparam,
111
112}; // enum enum_as_lparam
113
114
115enum enum_timeout
116{
117
118 e_timeout,
119
120}; // enum enum_timeout
121
122
123
125//
126// template < typename BASE_TYPE >
127// class function_composite_base :
128// //public add_particle_timeout < BASE_TYPE >
129// public BASE_TYPE
130// {
131// public:
132//
133// using base = BASE_TYPE;
134//
135// ::pointer < base > m_pbase;
136//
137// function_composite_base(base * pbase, const class ::time & timeTimeout) :
138// m_pbase(pbase)
139// //, add_particle_timeout < BASE_TYPE >(timeTimeout)
140// {
141//
142// }
143//
144// };
145#define FUNCTION_DEBUGGING 1
146class function_common_base
147{
148public:
149#if FUNCTION_DEBUGGING
150 const_char_pointer m_pszDebug;
151 ::i64 m_iDebug;
152#endif
153 class ::time m_timeTimeout;
154
155
156 function_common_base(const class ::time &timeTimeout = default_run_timeout()) :
157 m_timeTimeout(timeTimeout)
158 {
159
160 }
161
162
163 class ::time timeout() const
164 {
165
166 return m_timeTimeout;
167
168 }
169
170
171 void set_timeout(const class ::time & timeTimeout)
172 {
173 m_timeTimeout = timeTimeout;
174
175 }
176
177
178};
179
180
181// template < typename BASE_TYPE, typename COMPOSITE_TYPE >
182// class function_common :
183// public function_common_base
184// {
185// public:
186//
187// using base = BASE_TYPE;
188// using composite = COMPOSITE_TYPE;
189//
190// //using base_implementation = add_particle_timeout < base >;
191// using base_implementation = base;
192//
193// pointer<base > m_pbase;
194//
195// function_common() { }
196// template < typename T2 >
197// inline function_common(transfer_t, T2 * p) :m_pbase(place_t{}, p) {}
198// template < typename T2 >
199// inline function_common(place_t, T2 * p) : m_pbase(place_t{}, p) {}
200// template < typename T2 >
201// function_common(pointer < T2 > && p) : m_pbase(::transfer(p)) { }
202// function_common(enum_as_lparam, iptr iptr) : m_pbase((::subparticle *)iptr) { }
203// function_common(const function_common & function) : m_pbase(function.m_pbase) { }
204// function_common(function_common && function) : m_pbase(::transfer(function.m_pbase)) {}
205// ~function_common() { }
206//
207//
208// void clear()
209// {
210//
211// m_pbase.release();
212//
213// }
214//
215//
216// function_common & operator = (const function_common & function)
217// {
218//
219// m_pbase = function.m_pbase;
220//
221// return *this;
222//
223// }
224//
225// explicit operator bool() const { return ::is_set(this) && ::is_set(m_pbase); }
226//
227// bool operator !() const { return !this->operator bool(); }
228//
229// bool operator == (const function_common & function) const { return m_pbase == function.m_pbase; }
230//
231// operator ::subparticle * () const { return ::is_null(this) ? nullptr : m_pbase; }
232//
233// const ::subparticle * operator -> () const { return m_pbase; }
234//
235// ::subparticle * operator -> () { return m_pbase; }
236//
237// operator ::hash32() const
238// {
239//
240// return { (::u32)(::uptr)m_pbase.m_p };
241//
242// };
243//
244//
245// void construct(base * p, const class ::time & timeTimeout)
246// {
247//
248// m_pbase = p;
249//
250// m_timeTimeout = timeTimeout;
251//
252// // if (timeTimeout.is_null())
253// // {
254// //
255// // m_pbase = p;
256// //
257// // return;
258// //
259// // }
260// //
261// // auto paddparticletimeout = dynamic_cast <add_particle_timeout < base >*>(p);
262// //
263// // if (is_set(paddparticletimeout))
264// // {
265// //
266// // paddparticletimeout->set_timeout(timeTimeout);
267// //
268// // m_pbase = p;
269// //
270// // return;
271// //
272// // }
273// //
274// // m_pbase = allocateø composite(p, timeTimeout);
275//
276// }
277//
278//
279// void set_timeout(const class time & timeTimeout)
280// {
281//
282// ::pointer<add_particle_timeout<base>> pbase = m_pbase;
283//
284// if (!pbase)
285// {
286//
287// m_pbase = allocateø composite(m_pbase, timeTimeout);
288//
289// }
290// else
291// {
292//
293// pbase->set_timeout(timeTimeout);
294//
295// }
296//
297// }
298//
299// class ::time timeout() const
300// {
301//
302// return ::is_set(m_pbase) ? m_pbase->timeout() : default_run_timeout();
303//
304// }
305//
306//
307//
308// };
309
310//class function_base :
311// virtual public ::subparticle
312//{
313//public:
314//
315//
316// class ::time m_timeTimeout;
317//
318//
319// function_base(const class ::time & timeTimeout = {})
320// {
321//
322// if (timeTimeout.m_iSecond <= 0)
323// {
324//
325// m_timeTimeout = default_run_timeout();
326//
327// }
328// else
329// {
330//
331// m_timeTimeout = timeTimeout;
332//
333// }
334//
335// }
336//
337//
338// void set_run_timeout(const class time & timeTimeout) { m_timeTimeout = timeTimeout; }
339//
340//
341// class ::time get_run_timeout() const {return m_timeTimeout;}
342//
343//
344//};
345//
346
347template < typename PRIMITIVE_FUNCTION >
348concept prototype_function = ::std::is_base_of < ::function_common_base, PRIMITIVE_FUNCTION >::value;
349
350namespace data
351{
352 template < prototype_function FUNCTION >
353 class signal;
354} // namespace data
355
356
357template <typename PROCEDURE >
359 requires(PROCEDURE procedure)
360{
361
362 { procedure() } -> std::same_as<void>;
363
364};
365
366
367template < typename PROCEDURE >
369class pure_procedure :
370 virtual public ::subparticle
371{
372public:
373
374
375 PROCEDURE m_procedure;
376
377 pure_procedure(const PROCEDURE & procedure) :
378 m_procedure(procedure)
379 {
380
381
382 }
383
384
385 void operator()() override
386 {
387
388 this->m_procedure();
389
390 }
391
392
393 void run() override
394 {
395
396 this->m_procedure();
397
398 }
399
400
401};
402
403
404
405template < >
406class function < void() > :
407 public ::function_common_base,
408 public ::pointer < ::subparticle >
409{
410public:
411
412
413 using base = ::subparticle;
414
415 using base_pointer = ::pointer < ::subparticle >;
416
417
418 function() { }
419 // template < typename T2 >
420 // function(transfer_t, T2 * p) :base_function(place_t{}, p) {}
421 // template < typename T2 >
422 // function(place_t, T2 * p) : base_function(place_t{}, p) {}
423 // template < typename T2 >
424 // function(pointer < T2 > && p) : base_function(::transfer(p)) { }
425 // function(enum_as_lparam, iptr iptr) : base_function(e_as_lparam, iptr) { }
426 // function(const function & function) : base_function(function) { }
427 // function(function && function) : base_function(::transfer(function)) {}
428
429 function(::subparticle *psubparticle, const class ::time &timeTimeout = default_run_timeout()) :
430 function_common_base(timeTimeout),
431 base_pointer(psubparticle)
432 {
433
434 }
435
436
437 function(::lparam &lparam, const class ::time &timeTimeout = default_run_timeout()) :
438 function_common_base(timeTimeout), base_pointer(lparam)
439 {
440 }
441
442
443
444 template < typename PROCEDURE >
446 function(const PROCEDURE &procedure, const class time &timeTimeout = default_run_timeout()) :
447 function_common_base(timeTimeout), base_pointer(allocateø pure_procedure(procedure))
448 {
449
450 // if constexpr(::std::is_same_v<PROCEDURE, nullptr_t>)
451 // {
452 //
453 //
454 // }
455 // else if constexpr (::std::is_convertible_v<PROCEDURE, ::uptr>
456 // && ::std::is_convertible_v<PROCEDURE, lparam>)
457 // {
458 //
459 // this->construct((::subparticle*)(::uptr) procedure, timeTimeout);
460 //
461 // }
462 // else if constexpr (::prototype_subparticle_pointer<PROCEDURE> )
463 // {
464 //
465 // this->construct(procedure, timeTimeout);
466 //
467 // }
468 // else if constexpr (::std::is_base_of_v<::subparticle, decay<PROCEDURE> >)
469 // {
470 //
471 // this->construct(as_subparticle(procedure), timeTimeout);
472 //
473 // }
474 // else if constexpr(::std::is_same_v<::std::decay_t<PROCEDURE>, payload >
475 // || ::std::is_same_v<::std::decay_t <PROCEDURE> , property>)
476 // {
477 //
478 // this->construct(as_subparticle(procedure), timeTimeout);
479 //
480 // }
481 // else if constexpr(::std::is_same_v<const PROCEDURE &, const function & >)
482 // {
483 //
484 // this->m_pbase = procedure.m_pbase;
485 //
486 // this->m_pbase->set_timeout(timeTimeout);
487 //
488 // //this->construct(procedure.m_pbase, timeTimeout);
489 //
490 // }
491 // else
492 // {
493 //
494 // this->m_pbase = allocateø implementation (procedure, timeTimeout);
495 //
496 // }
497
498 }
499
500
501 template < typename PROCEDURE >
502 function(enum_timeout, const class time & timeTimeout, const PROCEDURE & procedureParam) :
503 function(procedureParam, timeTimeout)
504 {
505
506 }
507
508
509 ~function()
510 {
511
512 }
513
514
515 void operator()() const
516 {
517
518 this->m_p->operator()();
519
520 }
521
522
523 function & operator = (const function & function)
524 {
525
526 base_pointer::operator=(function);
527
528 return *this;
529
530 }
531
532};
533
534
535template <typename FUNCTION, typename RETURN_TYPE>
537 requires(FUNCTION function)
538{
539
540 { function() } -> std::same_as<RETURN_TYPE>;
541
542};
543
544
545template < typename RETURN_TYPE >
547 virtual public ::subparticle
548{
549public:
550
551
552 virtual RETURN_TYPE function_get() = 0;
553
554
555};
556
557
558
559template < typename FUNCTION, typename RETURN_TYPE >
560class return_function :
561 public return_function_base<RETURN_TYPE>
562{
563public:
564
565
566 FUNCTION m_function;
567
568
569 return_function(const FUNCTION & function) :
570 m_function(function)
571 {
572
573
574 }
575 //
576 //
577 // void get_debug_title(char_pointer sz, character_count c) override
578 // {
579 //
580 // ::string_count_copy(sz, "a procedure", c);
581 //
582 // }
583
584 RETURN_TYPE function_get()
585 {
586
587 return this->m_function();
588
589 }
590
591
592};
593
594
595
596template < typename RETURN_TYPE >
597class function < RETURN_TYPE() > :
598 public function_common_base,
599 public ::pointer<::return_function_base <RETURN_TYPE >>
600{
601public:
602
603 using base = ::return_function_base <RETURN_TYPE >;
604
605 using base_pointer = ::pointer<::return_function_base <RETURN_TYPE >>;
606
607
608
609
610 function() { }
611 function(nullptr_t) {}
612 // template < typename T2 >
613 // function(transfer_t, T2 * p) :base_function(place_t{}, p) {}
614 // template < typename T2 >
615 // function(place_t, T2 * p) : base_function(place_t{}, p) {}
616 // template < typename T2 >
617 // function(pointer < T2 > && p) : base_function(::transfer(p)) { }
618 // function(enum_as_lparam, iptr iptr) : base_function(e_as_lparam, iptr) { }
619 // function(const function & function) : base_function(function) { }
620 // function(function && function) : base_function(::transfer(function)) {}
621
622
623 template < typename FUNCTION >
625 function(const FUNCTION &functionParam, const class ::time & timeTimeout = default_run_timeout()) :
626 function_common_base(timeTimeout),
627 base_pointer(allocateø return_function<FUNCTION, RETURN_TYPE>(functionParam))
628 {
629
630 // if constexpr(::std::is_same_v<FUNCTION, nullptr_t>)
631 // {
632 //
633 //
634 // }
635 // else if constexpr(::std::is_same_v<::std::decay_t<FUNCTION>, payload >
636 // || ::std::is_same_v<::std::decay_t <FUNCTION> , property>)
637 // {
638 //
639 // this->construct(as_subparticle(function), timeTimeout);
640 //
641 // }
642 // else if constexpr(::std::is_same_v<FUNCTION, const function & >)
643 // {
644 //
645 // this->construct(function.m_pbase, timeTimeout);
646 //
647 // }
648 // else
649 // {
650 //
651 // this->m_pbase = allocateø implementation<FUNCTION >(function, timeTimeout);
652 //
653 // }
654
655 }
656
657
658 template < typename FUNCTION >
659 function(enum_timeout, const class time & timeTimeout, const FUNCTION & functionParam) :
660 function(functionParam, timeTimeout)
661 {
662
663 }
664
665
666 ~function()
667 {
668
669 }
670
671
672 RETURN_TYPE operator()() const
673 {
674
675 return this->m_p->function_get();
676
677 }
678
679
680 //void clear() { m_pbase.release(); }
681
682 //function & operator = (const function & function)
683 //{
684
685 // m_pbase = function.m_pbase;
686
687 // return *this;
688
689 //}
690
691
692 /*explicit operator bool() const { return ::is_set(m_pbase); }
693
694 bool operator !() const { return ::is_null(m_pbase); }*/
695
696
697 //operator ::hash32() const
698 //{
699
700 // return { (::u32)(::uptr)m_pbase.m_p };
701
702 //};
703
704 //void set_run_timeout(const class time & timeTimeout)
705 //{
706
707 // m_pbase->set_run_timeout(timeTimeout);
708 //}
709
710 //class ::time get_run_timeout() const { return ::is_set(m_pbase) ? m_pbase->get_run_timeout() : default_run_timeout(); }
711
712 function & operator = (const function & function)
713 {
714
715 base_pointer::operator=(function);
716
717 return *this;
718
719 }
720
721
722};
723
724//
725//template < typename RETURN_TYPE >
726//class function_receptor < RETURN_TYPE() > :
727// public function < RETURN_TYPE() >
728//{
729//public:
730//
731// template < typename PAYLOAD >
732// function_receptor(PAYLOAD function) :
733// function < RETURN_TYPE() >(transfer_t{}, function)
734// {
735// }
736//
737//
738//};
739
740
741template <typename FUNCTION, typename RETURN_TYPE, typename... ARGUMENTS>
743 requires(FUNCTION function, ARGUMENTS... arguments)
744{
745
746 { function(arguments...) } -> std::same_as<RETURN_TYPE>;
747
748};
749
750
751template < typename RETURN_TYPE, typename... ARGUMENTS >
753 virtual public ::subparticle
754{
755public:
756
757
758 virtual RETURN_TYPE operator()(ARGUMENTS... arguments) = 0;
759
760
761};
762
763
764
765template < typename FUNCTION, typename RETURN_TYPE, typename... ARGUMENTS >
766 requires(prototype_arguments_function<FUNCTION, RETURN_TYPE, ARGUMENTS...>)
767class arguments_function :
768 virtual public ::arguments_function_base < RETURN_TYPE, ARGUMENTS... >
769{
770public:
771
772
773 FUNCTION m_function;
774
775
776 //using base = ::function_base_3 < RETURN_TYPE, ARGUMENTS... >;
777
778
779 arguments_function(const FUNCTION & function) :
780 m_function(function)
781 {
782
783 }
784
785
786 RETURN_TYPE operator()(ARGUMENTS... arguments) override
787 {
788
789 return m_function(arguments...);
790
791 }
792
793};
794
795
796template < typename RETURN_TYPE, typename... ARGUMENTS >
797class function < RETURN_TYPE(ARGUMENTS...) > :
798 public function_common_base,
799 public ::pointer <arguments_function_base< RETURN_TYPE, ARGUMENTS...>>
800{
801public:
802
803
804 using base = arguments_function_base< RETURN_TYPE, ARGUMENTS...>;
805
806 using base_pointer = ::pointer < arguments_function_base< RETURN_TYPE, ARGUMENTS...> >;
807
808 // template < typename FUNCTION >
809 // class implementation :
810 // public base_implementation
811 // {
812 // public:
813 //
814 // FUNCTION m_function;
815 //
816 //
817 // implementation(FUNCTION implementation, const class ::time & timeTimeout = 0_s) :
818 // m_function(implementation),
819 // base_implementation(timeTimeout)
820 // {
821 //
822 //
823 // }
824 //
825 //
826 // void get_debug_title(char_pointer sz, character_count c) const override
827 // {
828 //
829 // ::string_count_copy(sz, "function with argument(s) and return type", c);
830 //
831 // }
832 //
833 //
834 // RETURN_TYPE operator()(ARGUMENTS... arguments) override
835 // {
836 //
837 // return m_function(arguments...);
838 //
839 // }
840 //
841 //
842 // };
843
844
845 //pointer < base > m_pbase;
846
847 function() { }
848 function(nullptr_t) {}
849 // template < typename T2 >
850 // function(transfer_t, T2 * p) :base_function(place_t{}, p) {}
851 // template < typename T2 >
852 // function(place_t, T2 * p) : base_function(place_t{}, p) {}
853 // template < typename T2 >
854 // function(pointer < T2 > && p) : base_function(::transfer(p)) { }
855 // function(enum_as_lparam, iptr iptr) : base_function(e_as_lparam, iptr) { }
856 // function(const function & function) : base_function(function) { }
857 // function(function && function) : base_function(::transfer(function)) {}
858
859
860
861 template < typename FUNCTION >
862 requires(prototype_arguments_function<FUNCTION, RETURN_TYPE, ARGUMENTS...>)
863 function(const FUNCTION &functionParam, const class ::time &timeTimeout = default_run_timeout()) :
864 function_common_base(timeTimeout),
865 base_pointer(allocateø arguments_function<FUNCTION, RETURN_TYPE, ARGUMENTS...>(functionParam))
866 {
867
868 // if constexpr(::std::is_same_v<FUNCTION, nullptr_t>)
869 // {
870 //
871 //
872 // }
873 // else if constexpr(::std::is_same_v<::std::decay_t<FUNCTION>, payload >
874 // || ::std::is_same_v<::std::decay_t <FUNCTION> , property>)
875 // {
876 //
877 // this->construct(as_subparticle(function), timeTimeout);
878 //
879 // }
880 // else if constexpr(::std::is_same_v<FUNCTION, const function & >)
881 // {
882 //
883 // this->construct(function.m_pbase, timeTimeout);
884 //
885 // }
886 // else
887 // {
888 //
889 // this->m_pbase = allocateø implementation <FUNCTION > (function, timeTimeout);
890 //
891 // }
892
893 }
894
895 template < typename FUNCTION >
896 requires(prototype_arguments_function<FUNCTION, RETURN_TYPE, ARGUMENTS...>)
897 function(enum_timeout, const class time & timeTimeout, const FUNCTION & functionParam) :
898 function(functionParam, timeTimeout)
899 {
900
901 }
902
903 function(base *pbase, const class ::time &timeTimeout = default_run_timeout()) :
904 function_common_base(timeTimeout),
905 base_pointer(pbase)
906 {
907
908
909
910 }
911
912
913 ~function()
914 {
915
916 }
917
918
919 RETURN_TYPE operator()(ARGUMENTS... arguments) const
920 {
921
922 //ASSERT(m_pbase);
923
924 return this->m_p->operator()(arguments...);
925
926 }
927
928
929 //void clear() { m_pbase.release(); }
930
931
932 //function & operator = (const function & function)
933 //{
934
935 // m_pbase = function.m_pbase;
936
937 // return *this;
938
939 //}
940
941
942 //explicit operator bool() const { return ::is_set(m_pbase); }
943
944 //bool operator !() const { return ::is_null(m_pbase); }
945
946 //bool operator == (const function & function) const { return m_pbase == function.m_pbase; }
947
948 //operator ::hash32() const
949 //{
950
951 // return { (::u32)(::uptr)m_pbase.m_p };
952
953 //}
954
955 //void set_run_timeout(const class time & timeTimeout)
956 //{
957
958 // m_pbase->set_run_timeout(timeTimeout);
959 //}
960
961 //class ::time get_run_timeout() const { return ::is_set(m_pbase) ? m_pbase->get_run_timeout() : default_run_timeout(); }
962
963 function & operator = (const function & function)
964 {
965
966 base_pointer::operator=(function);
967
968 return *this;
969
970 }
971
972
973};
974
975//
976//template < typename RETURN_TYPE, typename... ARGUMENTS >
977//class function_receptor < RETURN_TYPE(ARGUMENTS...) > :
978// public function < RETURN_TYPE(ARGUMENTS...) >
979//{
980//public:
981//
982// template < typename PAYLOAD >
983// function_receptor(PAYLOAD function) :
984// function < RETURN_TYPE(ARGUMENTS...) >(transfer_t{}, function)
985// {
986// }
987//
988//
989//};
990
991
992template <typename PROCEDURE, typename... ARGUMENTS>
994 requires(PROCEDURE procedure, ARGUMENTS... arguments)
995{
996
997 { procedure(arguments...) } -> std::same_as<void>;
998
999};
1000
1001
1002template < typename ... ARGUMENTS>
1004 virtual public ::subparticle
1005{
1006public:
1007
1008 virtual void operator()(ARGUMENTS... arguments)= 0;
1009
1010};
1011
1012
1013template < typename PROCEDURE, typename ... ARGUMENTS >
1014class arguments_procedure :
1015 virtual public ::arguments_procedure_base<ARGUMENTS...>
1016{
1017public:
1018
1019 PROCEDURE m_procedure;
1020
1021 arguments_procedure(const PROCEDURE & procedure) :
1022 m_procedure(procedure)
1023 {
1024
1025
1026 }
1027
1028 //function_base_4(const ::e_flag & eflag, const ::e_status & estatus = undefined) :
1029 // ::quantum(eflag, estatus),
1030 // ::subparticle(eflag, estatus)
1031 //{
1032
1033
1034 //}
1035 //
1036 //
1037 // function_base_4(const function_base_4 & functionbase4) :
1038 // ::quantum(functionbase4),
1039 // ::subparticle(functionbase4)
1040 // {
1041 //
1042 //
1043 // }
1044 //
1045 // function_base_4(function_base_4&& functionbase4) :
1046 // ::quantum(::transfer(functionbase4)),
1047 // ::subparticle(::transfer(functionbase4))
1048 // {
1049 //
1050 //
1051 // }
1052 //
1053 //
1054 // ~function_base_4() override
1055 // {
1056 //
1057 //
1058 // }
1059 //
1060 //
1061 // virtual void operator()(ARGUMENTS... arguments)
1062 // {
1063 //
1064 //
1065 // }
1066
1067 virtual void operator()(ARGUMENTS... arguments)
1068 {
1069
1070 this->m_procedure(arguments...);
1071
1072 }
1073
1074
1075};
1076
1077
1078//
1079// template < typename... ARGUMENTS >
1080// class function_composite_4 :
1081// virtual public ::function_composite_base < function_base_4 < ARGUMENTS... > >
1082// {
1083// public:
1084//
1085// using base_composite = ::function_composite_base < function_base_4 < ARGUMENTS... > >;
1086//
1087// using base = base_composite::base;
1088//
1089// function_composite_4(base * pbase, const class ::time & timeTimeout) :
1090// function_composite_base < ::function_base_4 < ARGUMENTS... > >(pbase, timeTimeout)
1091// {
1092//
1093// }
1094//
1095// void operator()(ARGUMENTS... arguments) override
1096// {
1097//
1098// this->m_pbase->operator()(arguments...);
1099//
1100// }
1101//
1102// };
1103//
1104//
1105// template < typename... ARGUMENTS >
1106// using base_function_4 = function_common <
1107// function_base_4 < ARGUMENTS... >,
1108// function_composite_4 < ARGUMENTS... >
1109// >;
1110//
1111//
1112// template < typename PROCEDURE, typename... ARGUMENTS >
1113// class function_4_implementation :
1114// //virtual public add_particle_timeout < function_base_4 < ARGUMENTS... > >
1115// public function_base_4 < ARGUMENTS...>
1116// {
1117// public:
1118//
1119//
1120// PROCEDURE m_function;
1121//
1122//
1123// function_4_implementation(PROCEDURE implementation, const class ::time & timeTimeout = 0_s) :
1124// m_function(implementation),
1125// //add_particle_timeout < function_base_4 < ARGUMENTS... > >(timeTimeout)
1126// function_base_4 < ARGUMENTS... >(timeTimeout)
1127// //function_common_base
1128// {
1129//
1130//
1131// }
1132//
1133//
1134// ~function_4_implementation() override
1135// {
1136//
1137//
1138// }
1139//
1140//
1141// void get_debug_title(char_pointer sz, character_count c) const override
1142// {
1143//
1144// ::string_count_copy(sz, "function with argument(s) and no return type", c);
1145//
1146// }
1147//
1148//
1149// void operator()(ARGUMENTS... arguments) override
1150// {
1151//
1152// m_function(arguments...);
1153//
1154// }
1155//
1156//
1157// };
1158
1159
1160
1161template < typename... ARGUMENTS >
1162class function < void(ARGUMENTS...) > :
1163 public function_common_base,
1164 public ::pointer < arguments_procedure_base <ARGUMENTS...> >
1165{
1166public:
1167
1168
1169 using base = arguments_procedure_base <ARGUMENTS...>;
1170 using base_pointer = ::pointer < arguments_procedure_base <ARGUMENTS...> >;
1171
1172 //using base_implementation = base_function::base_implementation;
1173
1174 //using base = base_function_4 < ARGUMENTS... > ::base;
1175
1176
1177
1178
1179 //pointer < base > m_pbase;
1180
1181 function() { }
1182 function(nullptr_t) {}
1183 //template < typename T2 >
1184 //function(transfer_t, T2 * p) :base_function_4 < ARGUMENTS... > (place_t{}, p) {}
1185 //template < typename T2 >
1186 //function(place_t, T2 * p) : base_function_4 < ARGUMENTS... > (place_t{}, p) {}
1187 //template < typename T2 >
1188 //function(pointer < T2 > && p) : base_function_4 < ARGUMENTS... > (::transfer(p)) { }
1189 //function(enum_as_lparam, iptr iptr) : base_function_4 < ARGUMENTS... > (e_as_lparam, iptr) { }
1190 //function(const function & function) : base_function_4 < ARGUMENTS... > (function) { }
1191 //function(function && function) : base_function_4 < ARGUMENTS... > (::transfer(function)) {}
1192
1193
1194 template < typename PROCEDURE >
1195 requires(prototype_arguments_procedure<PROCEDURE, ARGUMENTS ...>)
1196 function(const PROCEDURE &procedure, const class ::time &timeTimeout = default_run_timeout()) :
1197 function_common_base(timeTimeout),
1198 base_pointer(allocateø arguments_procedure<PROCEDURE, ARGUMENTS...>(procedure))
1199 //
1200 // requires (::std::is_convertible_v<PROCEDURE, :: >)
1201 {
1202
1203 //this->construct(procedure, timeTimeout);
1204
1205 }
1206
1207
1208 function(base *pbase, const class ::time &timeTimeout = default_run_timeout()) :
1209 function_common_base(timeTimeout),
1210 base_pointer(pbase)
1211 {
1212
1213 //this->construct(procedure, timeTimeout);
1214
1215 }
1216
1217
1218 template < typename PAYLOAD_WITH_PROCEDURE >
1219 requires (::is_same<::std::decay_t<PAYLOAD_WITH_PROCEDURE>, payload >
1220|| ::is_same<::std::decay_t <PAYLOAD_WITH_PROCEDURE>, property>)
1221 function(PAYLOAD_WITH_PROCEDURE payloadWithProcedure, const class ::time &timeTimeout = default_run_timeout()) :
1222 function_common_base(timeTimeout),
1223 base_pointer(dynamic_cast <base*>(as_subparticle(payloadWithProcedure)))
1224 {
1225
1226 //this->construct(dynamic_cast <base*>(as_subparticle(payloadWithProcedure)), timeTimeout);
1227
1228 }
1229
1230
1231 // template < typename PROCEDURE >
1232 // function(PROCEDURE procedure, const class ::time& timeTimeout = 0_s)
1233 // requires (LambdaWithVoidAndarguments< PROCEDURE, ARGUMENTS... >)
1234 // {
1235 //
1236 // this->m_pbase = allocateø function_4_implementation< PROCEDURE, ARGUMENTS... >(procedure, timeTimeout);
1237 //
1238 // }
1239
1240
1241 template < typename PROCEDURE >
1242 requires(prototype_arguments_procedure<PROCEDURE, ARGUMENTS ...>)
1243 function(enum_timeout, const class time & timeTimeout, const PROCEDURE & procedure) :
1244 function(procedure, timeTimeout)
1245 {
1246
1247 }
1248
1249
1250
1251 ~function()
1252 {
1253
1254 }
1255
1256
1257 void operator()(ARGUMENTS... arguments) const
1258 {
1259
1260 this->m_p->operator()(arguments...);
1261
1262 }
1263
1264
1265 //void clear() { m_pbase.release(); }
1266
1267
1268 //function & operator = (const function & function)
1269 //{
1270
1271 // m_pbase = function.m_pbase;
1272
1273 // return *this;
1274
1275 //}
1276
1277
1278 //explicit operator bool() const { return ::is_set(m_pbase.m_p); }
1279
1280 //bool operator !() const { return ::is_null(m_pbase.m_p); }
1281
1282 //bool operator == (const function & function) const { return m_pbase == function.m_pbase; }
1283
1284 //operator ::hash32() const { return { (::u32)(::uptr)m_pbase.m_p }; }
1285 //
1286 //void set_run_timeout(const class time & timeTimeout)
1287 //{
1288
1289 // m_pbase->set_run_timeout(timeTimeout);
1290 //}
1291
1292 //class ::time get_run_timeout() const { return ::is_set(m_pbase) ? m_pbase->get_run_timeout() : default_run_timeout(); }
1293
1294 function & operator = (const function & function)
1295 {
1296
1297 base_pointer::operator=(function);
1298
1299 return *this;
1300
1301 }
1302
1303
1304
1305};
1306
1307
1308class topic;
1309
1310class handler_context;
1311
1312using signal_handler = ::function < void(::topic *, ::handler_context *) >;
1313
1314
1315
1316
1317
Definition function.h:754
Definition function.h:769
Definition function.h:1005
Definition function.h:1016
Definition _template_forward_declaration.h:297
Definition handler_context.h:9
Definition lparam.h:9
Definition payload.h:54
Definition function.h:371
Definition function.h:548
Definition function.h:562
Definition subparticle.h:78
Definition aaa_time.h:13
Definition topic.h:17
Definition function.h:75
Definition function.h:72
Definition function.h:742
Definition function.h:993
Definition function.h:348
Definition function.h:358
Definition function.h:536