Fix bugs and refactor
This commit is contained in:
@@ -51,6 +51,12 @@ bool IRTTI::FastContainer::find(const Classes& Type) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IRTTI::FastContainer::~FastContainer()
|
||||||
|
{
|
||||||
|
_size = 0;
|
||||||
|
delete[] array;
|
||||||
|
}
|
||||||
|
|
||||||
void IRTTI::SetType(const Classes Type)
|
void IRTTI::SetType(const Classes Type)
|
||||||
{
|
{
|
||||||
this->type = Type;
|
this->type = Type;
|
||||||
|
|||||||
+4
-9
@@ -15,6 +15,8 @@ class IRTTI
|
|||||||
long long constexpr size() const { return _size; }
|
long long constexpr size() const { return _size; }
|
||||||
void push_back(const Classes object);
|
void push_back(const Classes object);
|
||||||
bool find(const Classes& Type) const;
|
bool find(const Classes& Type) const;
|
||||||
|
|
||||||
|
~FastContainer();
|
||||||
};
|
};
|
||||||
FastContainer Tree;
|
FastContainer Tree;
|
||||||
Classes type;
|
Classes type;
|
||||||
@@ -33,18 +35,11 @@ class RTTI final
|
|||||||
{
|
{
|
||||||
RTTI() = default;
|
RTTI() = default;
|
||||||
|
|
||||||
|
|
||||||
// That method allow compare given type with real type object
|
|
||||||
template<class Kind>
|
|
||||||
static bool IsA(const Classes type)
|
|
||||||
{
|
|
||||||
return Meta<Kind>::Type == type;
|
|
||||||
}
|
|
||||||
public:
|
public:
|
||||||
template<class Kind>
|
template<class Kind>
|
||||||
static bool IsA(const IRTTI* object)
|
static bool IsA(const IRTTI* object)
|
||||||
{
|
{
|
||||||
return IsA<Kind>(object->type);
|
return Meta<Kind>::Type == object->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// That method realized dynamic_cast
|
// That method realized dynamic_cast
|
||||||
@@ -52,7 +47,7 @@ public:
|
|||||||
static To* dyn_cast(From* object)
|
static To* dyn_cast(From* object)
|
||||||
{
|
{
|
||||||
IRTTI* InterfaceOfObject = static_cast<IRTTI*>(object);
|
IRTTI* InterfaceOfObject = static_cast<IRTTI*>(object);
|
||||||
if (IsA<To>(InterfaceOfObject->type))
|
if (IsA<To>(object))
|
||||||
return reinterpret_cast<To*>(object);
|
return reinterpret_cast<To*>(object);
|
||||||
|
|
||||||
if (InterfaceOfObject->Tree.find(Meta<To>::Type))
|
if (InterfaceOfObject->Tree.find(Meta<To>::Type))
|
||||||
|
|||||||
Reference in New Issue
Block a user