Loading...
Searching...
No Matches
type.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "meta/common.hpp"
5
6namespace by {
7
100 class _nout type {
101 BY_ME(type)
102
103 public:
104 virtual ~type() {}
105
106 public:
114 virtual nbool operator==(const me& rhs) const;
115 nbool operator!=(const me& rhs) const;
116
117 public:
118 virtual nbool isTemplate() const = 0;
119 virtual nbool isAbstract() const = 0;
120 virtual const std::string& getName() const;
121
128 virtual void* make() const = 0;
129
130 template <typename T> T* makeAs() const {
131 // c++ is not allow for covariant against void*.
132 // that's is why I make another variant func of already made make().
133 return (T*) make();
134 }
135
136 virtual ncnt size() const = 0;
137
144 virtual nbool init();
145
146 virtual nbool rel();
147 virtual const type& getSuper() const = 0;
148 virtual const nbool& isInit() const = 0;
149
154 const types& getLeafs() const;
155
156 const types& getSubs() const;
157 const types& getSupers() const;
158
165 virtual nbool isSuper(const type& it) const;
166 nbool isSuper(const type* it) const BY_SIDE_FUNC(isSuper);
167 template <typename T> nbool isSuper() const;
168
174 nbool isSub(const type& it) const;
175 nbool isSub(const type* it) const BY_SIDE_FUNC(isSub);
176 template <typename T> nbool isSub() const;
177 const type& getStatic() const BY_CONST_FUNC(_getStatic())
178
209
210 protected:
211 // type:
212 virtual types& _getSubs() = 0;
213 virtual types& _getSupers() = 0;
214 virtual type& _getStatic() const = 0;
215 void _setInit(nbool newState);
223 virtual void _onAddSubClass(const me& subClass);
224 virtual types** _onGetLeafs() const = 0;
225 void _setLeafs(types* newLeafs) const;
226 virtual const std::string& _getNativeName() const;
227
228 private:
229 nbool _logInitOk(nbool res);
230 void _findLeafs(const type& cls, types& tray) const;
231 };
232} // namespace by
Core class for runtime type information in byeol language.
Definition type.hpp:100
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 classes (leaf nodes) from this class.
virtual nbool init()
Initializes type metadata and constructs class hierarchy.
nbool isSub(const type &it) const
Checks if this type is a sub class of the given type.
virtual nbool operator==(const me &rhs) const
Checks if two type objects represent the same type.
virtual nbool isSuper(const type &it) const
Checks if this type is a super class of the given type.
Rich logging support with polymorphic type conversion.
Definition richLog.hpp:34