type.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "meta/common.hpp"
5
6namespace by {
7
12 class _nout type {
13 BY_ME(type)
14
15 public:
16 virtual ~type() {}
17
18 public:
19 virtual nbool operator==(const me& rhs) const;
20 nbool operator!=(const me& rhs) const;
21
22 public:
23 virtual nbool isTemplate() const = 0;
24 virtual nbool isAbstract() const = 0;
25 virtual const std::string& getName() const;
26
31 virtual void* make() const = 0;
32
33 template <typename T> T* makeAs() const {
34 // c++ is not allow for covariant against void*.
35 // that's is why I make another variant func of already made make().
36 return (T*) make();
37 }
38
39 virtual ncnt size() const = 0;
40 virtual nbool init();
41 virtual nbool rel();
42 virtual const type& getSuper() const = 0;
43 virtual const nbool& isInit() const = 0;
44
46 const types& getLeafs() const;
47 const types& getSubs() const;
48 const types& getSupers() const;
49
50 virtual nbool isSuper(const type& it) const;
51 nbool isSuper(const type* it) const BY_SIDE_FUNC(isSuper);
52 template <typename T> nbool isSuper() const;
53 nbool isSub(const type& it) const;
54 nbool isSub(const type* it) const BY_SIDE_FUNC(isSub);
55 template <typename T> nbool isSub() const;
56 const type& getStatic() const BY_CONST_FUNC(_getStatic())
57
86 virtual const nchar* getMetaTypeName() const;
87
88 protected:
89 // type:
90 virtual types& _getSubs() = 0;
91 virtual types& _getSupers() = 0;
92 virtual type& _getStatic() const = 0;
93 void _setInit(nbool newState);
94 virtual void _onAddSubClass(const me& subClass);
95 virtual types** _onGetLeafs() const = 0;
96 void _setLeafs(types* newLeafs) const;
97 virtual const std::string& _getNativeName() const;
98
99 private:
100 nbool _logInitOk(nbool res);
101 void _findLeafs(const type& cls, types& tray) const;
102 };
103} // namespace by
Base class for runtime type information in byeol language.
Definition: type.hpp:12
const type & getStatic() const BY_CONST_FUNC(_getStatic()) virtual const nchar *getMetaTypeName() const
Get meta type name for efficient type checking.
virtual void * make() const =0
create an instance to be refered this type.
const types & getLeafs() const
returns all most derived class from this class.