typeProvidable.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "meta/common.hpp"
5#include "meta/type/ttype.hpp"
6
7namespace by {
12 class _nout typeProvidable {
13 BY_ME(typeProvidable)
14
15 public:
16 nbool operator==(const me& rhs) const;
17 nbool operator!=(const me& rhs) const;
18
19 public:
20 virtual const type& getType() const = 0;
21
22 nbool isSub(const type& it) const;
23 nbool isSub(const type* it) const BY_SIDE_FUNC(isSub);
24 nbool isSub(const me& it) const;
25 nbool isSub(const me* it) const BY_SIDE_FUNC(isSub);
26
27 nbool isSuper(const type& it) const;
28 nbool isSuper(const type* it) const BY_SIDE_FUNC(isSuper);
29 nbool isSuper(const me& it) const;
30
31 nbool isSuper(const me* it) const BY_SIDE_FUNC(isSuper);
32
33 template <typename T> nint isSub() const { return getType().isSub<T>(); }
34
35 template <typename T> nint isSuper() const { return getType().isSuper<T>(); }
36
37 template <typename T> T* cast() { return (T*) cast(ttype<T>::get()); }
38
39 template <typename T> const T* cast() const BY_CONST_FUNC(cast<T>())
40
41 virtual void* cast(const type& to);
42 const void* cast(const type& to) const BY_CONST_FUNC(cast(to))
43 void* cast(const type* it) BY_SIDE_FUNC(cast);
44 const void* cast(const type* to) const BY_CONST_FUNC(cast(to))
45
46 protected:
47 virtual nbool _onSame(const me& rhs) const;
48 };
49} // namespace by
Template type wrapper for type metadata management.
Definition: ttype.hpp:16
Base class for runtime type information in byeol language.
Definition: type.hpp:12
Interface for objects that can provide their type information.
Definition: typeProvidable.hpp:12