1414#include " TypeId.h"
1515#include " Constants.h"
1616
17- namespace rtl
17+ namespace rtl ::detail
1818{
19- namespace detail
19+ class lambda_table ;
20+
21+ /* @class: FunctorId
22+ * 'FunctorId' object is generated for every functor (member/non-member function pointer) registered.
23+ * acts as a hash-key to lookup a particular functor in the functor-table.
24+ * first, using 'm_containerId', the functor-table container is found.
25+ * once table is found, the functor is accessed at index 'm_index', (never fails, noexcept)
26+ * 'FunctorId' generated for a each functor is unique, even for overloaded functions.
27+ * multiple registartion of same functor will generate same duplicate 'FunctorId'.
28+ */ struct FunctorId
2029 {
21- /* @class: FunctorId
22- * 'FunctorId' object is generated for every functor (member/non-member function pointer) registered.
23- * acts as a hash-key to lookup a particular functor in the functor-table.
24- * first, using 'm_containerId', the functor-table container is found.
25- * once table is found, the functor is accessed at index 'm_index', (never fails, noexcept)
26- * 'FunctorId' generated for a each functor is unique, even for overloaded functions.
27- * multiple registartion of same functor will generate same duplicate 'FunctorId'.
28- */ struct FunctorId
29- {
30- // index of the functor in the functor-table.
31- std::size_t m_index;
30+ // index of the functor in the functor-table.
31+ std::size_t m_index;
3232
33- // return type-id of the functor registered.
34- std::size_t m_returnId;
33+ // return type-id of the functor registered.
34+ std::size_t m_returnId;
3535
36- // if functor is a member-function, type id of class/struct it belongs to.
37- std::size_t m_recordId;
36+ // if functor is a member-function, type id of class/struct it belongs to.
37+ std::size_t m_recordId;
3838
39- // containerId of the functor-table.
40- std::size_t m_containerId;
39+ // containerId of the functor-table.
40+ std::size_t m_containerId;
4141
42- // signature of functor as string. platform dependent, may not be very much readable format.
43- std::string m_signature;
42+ // signature of functor as string. platform dependent, may not be very much readable format.
43+ std::string m_signature;
4444
45- GETTER (std::size_t , Index, m_index)
46- GETTER (std::size_t , ReturnId, m_returnId);
47- GETTER (std::size_t , RecordId, m_recordId);
48- GETTER (std::size_t , SignatureId, m_containerId)
49- GETTER (std::string, SignatureStr, m_signature)
45+ lambda_table* m_lambdaTable = nullptr ;
5046
51- /* @method: getHashCode()
52- @return: std::size_t (a unique hash-code for a functor)
53- * 'm_containerId' will be same for functors(non-member) with same signatures.
54- * for member functions, a functor will have three atrributes
55- - signature
56- - whether it is const or non-const
57- - class/struct type
58- 'm_containerId' will be same for functors with same above attributes.
59- * every functor will have a distinct index in the functor-wrapped-lambda-table.
60- * so, combination of m_containerId & m_index is unique for every functor.
61- */ std::size_t getHashCode () const
62- {
63- return std::stoull (std::to_string (m_containerId) +
64- std::to_string (m_index) +
65- std::to_string (m_recordId) +
66- std::to_string (m_returnId));
67- }
47+ GETTER (std::size_t , Index, m_index)
48+ GETTER (std::size_t , ReturnId, m_returnId);
49+ GETTER (std::size_t , RecordId, m_recordId);
50+ GETTER (std::size_t , SignatureId, m_containerId)
51+ GETTER (std::string, SignatureStr, m_signature)
6852
69- const bool operator ==(const FunctorId& pOther) const
70- {
71- return (m_index == pOther.m_index && m_returnId == pOther.m_returnId &&
72- m_recordId == pOther.m_recordId && m_containerId == pOther.m_containerId &&
73- m_signature == pOther.m_signature );
74- }
75- };
76- }
53+ /* @method: getHashCode()
54+ @return: std::size_t (a unique hash-code for a functor)
55+ * 'm_containerId' will be same for functors(non-member) with same signatures.
56+ * for member functions, a functor will have three atrributes
57+ - signature
58+ - whether it is const or non-const
59+ - class/struct type
60+ 'm_containerId' will be same for functors with same above attributes.
61+ * every functor will have a distinct index in the functor-wrapped-lambda-table.
62+ * so, combination of m_containerId & m_index is unique for every functor.
63+ */ std::size_t getHashCode () const
64+ {
65+ return std::stoull (std::to_string (m_containerId) +
66+ std::to_string (m_index) +
67+ std::to_string (m_recordId) +
68+ std::to_string (m_returnId));
69+ }
70+
71+ const bool operator ==(const FunctorId& pOther) const
72+ {
73+ return (m_index == pOther.m_index && m_returnId == pOther.m_returnId &&
74+ m_recordId == pOther.m_recordId && m_containerId == pOther.m_containerId &&
75+ m_signature == pOther.m_signature );
76+ }
77+ };
7778}
0 commit comments