libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_class.hpp
1#ifndef GIMBAL_CLASS_HPP
2#define GIMBAL_CLASS_HPP
3
4#include "gimbal_class.h"
5
6#include <type_traits.h>
7
8namespace gimbal {
9
10template<typename CRTP,
11 typename SelfType,
12 typename CClassType=GblClass,
13 typename Base=std::false_type>
14 class Class: public Base<CRTP, SelfType, CClassType, Base> {
15private:
16 CClassType* pClass = nullptr;
17public:
18 Class(void) = default;
19 Class(const Class& other);
20 Class(Class&& other);
21 ~Class(void);
22
23 Class& operator=(const Class& other);
24 Class& operator=(const Class&& other);
25
26 operator bool() const;
27
28 bool isValid() const;
29 bool isDefault() const;
30 bool isOverridden() const;
31 bool isInterface() const;
32 bool isInterfaceImpl() const;
33 bool isOwned() const;
34 bool isInPlace() const;
35
36 Type typeOf();
37
38 size_t refCount(void) const;
39
40 template<typename T>
41 Class<T> super() const;
42
43 template<typename T>
44 Class<T> defaulted() const;
45
46 template<typename T, typename C>
47 T* privateData();
48
49 friend bool operator==(const Class& other);
50 friend bool operator!=(const Class& other);
51
52};
53
54template<typename SelfType,
55 typename CClassType=GblInterface>
56class Interface: public Class<Interface, GblInterface> {
57public:
58
59 bool isValid() { return /* TRY INTERFACE */ && Class::isValid() }
60
61 template<typename T>
62 T* outerClass();
63
64 template<typename T>
65 T* outerMostClass();
66
67};
68
69
70#endif // GIMBAL_CLASS_HPP