95 lines
1.9 KiB
C
95 lines
1.9 KiB
C
|
#pragma once
|
||
|
|
||
|
#include "EHS.h"
|
||
|
#include "Type.h"
|
||
|
#include "Array.h"
|
||
|
#include "Log.h"
|
||
|
|
||
|
namespace lwe
|
||
|
{
|
||
|
class BaseObj
|
||
|
{
|
||
|
private:
|
||
|
Array<Type> hierarchy;
|
||
|
BaseObj* parent;
|
||
|
|
||
|
public:
|
||
|
virtual ~BaseObj();
|
||
|
|
||
|
BaseObj();
|
||
|
|
||
|
BaseObj(const BaseObj& base);
|
||
|
|
||
|
BaseObj(BaseObj&& base) noexcept;
|
||
|
|
||
|
BaseObj& operator=(const BaseObj& base);
|
||
|
|
||
|
BaseObj& operator=(BaseObj&& base) noexcept;
|
||
|
|
||
|
bool operator!() const;
|
||
|
|
||
|
bool operator==(const BaseObj& base) const;
|
||
|
|
||
|
bool operator!=(const BaseObj& base) const;
|
||
|
|
||
|
bool HasType(const UInt_64 hashType) const;
|
||
|
|
||
|
bool HasType(const Str_8& type) const;
|
||
|
|
||
|
protected:
|
||
|
bool AddType(Str_8 type);
|
||
|
|
||
|
public:
|
||
|
Type GetType() const;
|
||
|
|
||
|
Type GetType(const UInt_64 hashType) const;
|
||
|
|
||
|
Type GetType(const Str_8& type) const;
|
||
|
|
||
|
const Char_8* GetTypeId() const;
|
||
|
|
||
|
UInt_64 GetTypeHashId() const;
|
||
|
|
||
|
const Array<Type>& GetHierarchy() const;
|
||
|
|
||
|
void SetParent(BaseObj* newParent);
|
||
|
|
||
|
BaseObj* GetParent();
|
||
|
|
||
|
BaseObj* GetParent(const UInt_64 hashType);
|
||
|
|
||
|
BaseObj* GetParent(const Str_8& type);
|
||
|
|
||
|
virtual BaseObj* Clone() const;
|
||
|
|
||
|
virtual bool IsValid() const;
|
||
|
};
|
||
|
|
||
|
inline bool BaseObj::HasType(const UInt_64 hashType) const
|
||
|
{
|
||
|
for (UInt_64 i = 0; i < hierarchy.Size(); ++i)
|
||
|
if (hashType == hierarchy[i].GetHashId())
|
||
|
return true;
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
inline Type BaseObj::GetType(const UInt_64 hashType) const
|
||
|
{
|
||
|
for (UInt_64 i = 0; i < hierarchy.Size(); ++i)
|
||
|
if (hashType == hierarchy[i].GetHashId())
|
||
|
return hierarchy[i];
|
||
|
|
||
|
return {};
|
||
|
}
|
||
|
|
||
|
inline BaseObj* BaseObj::GetParent(const UInt_64 hashType)
|
||
|
{
|
||
|
BaseObj* result = GetParent();
|
||
|
|
||
|
while (result && !result->HasType(hashType))
|
||
|
result = result->GetParent();
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
}
|