Skip to content

Commit

Permalink
typeids: reverted 😢
Browse files Browse the repository at this point in the history
  • Loading branch information
inanevin committed Jan 24, 2025
1 parent f31deb7 commit 73317c6
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 66 deletions.
19 changes: 1 addition & 18 deletions LinaCommon/include/Common/StringID.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,26 +111,9 @@ namespace Lina
}
};

template <typename T>
concept HasSharedTID = requires { T::SHARED_TID; };

template <typename T>
concept HasSharedTIDBase = requires { T::SHARED_TID_BASE; };

class Widget;

template <typename T> constexpr TypeID GetTypeID()
{
if constexpr (std::is_same_v<T, Widget>)
{
return 500;
}
if constexpr (HasSharedTID<T>)
return T::SHARED_TID; // Highest priority
else if constexpr (HasSharedTIDBase<T>)
return T::SHARED_TID_BASE; // Fallback
else
return FnvHash(typeid(T).name()); // Default
return FnvHash(typeid(T).name()); // Default
}

constexpr StringID operator"" _hs(const char* str, std::size_t) noexcept
Expand Down
5 changes: 2 additions & 3 deletions LinaCore/include/Core/Audio/Audio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ namespace Lina
void LoadFromStream(IStream& in);
};

Audio(ResourceID id, const String& name) : Resource(id, GetTypeID<Audio>(), name) {};
Audio(ResourceID id, const String& name) : Resource(id, GetTypeID<Audio>(), name){};
virtual ~Audio();

static constexpr uint32 VERSION = 0;
static constexpr TypeID SHARED_TID = 101;
static constexpr uint32 VERSION = 0;

virtual bool LoadFromFile(const String& path) override;
virtual void LoadFromStream(IStream& stream) override;
Expand Down
4 changes: 1 addition & 3 deletions LinaCore/include/Core/GUI/Widgets/Primitives/Button.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ namespace Lina
class Button : public Widget
{
public:
static constexpr TypeID SHARED_TID = 203;

struct Properties
{
Delegate<void()> onClicked;
Expand All @@ -55,7 +53,7 @@ namespace Lina
}
};

Button() : Widget(WF_CONTROLLABLE) {};
Button() : Widget(WF_CONTROLLABLE){};
virtual ~Button() = default;

virtual void Construct() override;
Expand Down
3 changes: 1 addition & 2 deletions LinaCore/include/Core/GUI/Widgets/Primitives/Icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ namespace Lina
Icon() : Widget()
{
}
virtual ~Icon() = default;
static constexpr TypeID SHARED_TID = 202;
virtual ~Icon() = default;

struct Properties
{
Expand Down
5 changes: 2 additions & 3 deletions LinaCore/include/Core/GUI/Widgets/Primitives/Text.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ namespace Lina
class Text : public Widget
{
public:
Text() : Widget() {};
virtual ~Text() = default;
static constexpr TypeID SHARED_TID = 201;
Text() : Widget(){};
virtual ~Text() = default;

struct Properties
{
Expand Down
4 changes: 2 additions & 2 deletions LinaCore/include/Core/Graphics/Resource/Font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ namespace Lina
void LoadFromStream(IStream& in);
};

static constexpr uint32 VERSION = 0;
static constexpr uint32 VERSION = 0;

Font(ResourceID id, const String& name) : Resource(id, GetTypeID<Font>(), name) {};
Font(ResourceID id, const String& name) : Resource(id, GetTypeID<Font>(), name){};
virtual ~Font();

LinaVG::Font* GetFont(float scaleFactor);
Expand Down
7 changes: 3 additions & 4 deletions LinaCore/include/Core/Graphics/Resource/Material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Lina
ShaderPropertyDefinition propDef;
Span<uint8> data;

MaterialProperty() {};
MaterialProperty(){};
MaterialProperty(const MaterialProperty& other) = delete;
MaterialProperty& operator=(MaterialProperty const&) = delete;

Expand Down Expand Up @@ -85,10 +85,9 @@ namespace Lina
{

public:
static constexpr uint32 VERSION = 0;
static constexpr TypeID SHARED_TID = 104;
static constexpr uint32 VERSION = 0;

Material(ResourceID id, const String& name) : Resource(id, GetTypeID<Material>(), name) {};
Material(ResourceID id, const String& name) : Resource(id, GetTypeID<Material>(), name){};
virtual ~Material();
virtual bool LoadFromFile(const String& path) override;
virtual void SaveToStream(OStream& stream) const override;
Expand Down
5 changes: 2 additions & 3 deletions LinaCore/include/Core/Graphics/Resource/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ namespace Lina
Vector<ResourceID> materials;
};

static constexpr uint32 VERSION = 0;
static constexpr TypeID SHARED_TID = 105;
static constexpr uint32 VERSION = 0;

Model(ResourceID id, const String& name) : Resource(id, GetTypeID<Model>(), name) {};
Model(ResourceID id, const String& name) : Resource(id, GetTypeID<Model>(), name){};
virtual ~Model();

virtual bool LoadFromFile(const String& path) override;
Expand Down
5 changes: 2 additions & 3 deletions LinaCore/include/Core/Graphics/Resource/Shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ namespace Lina
};

public:
static constexpr uint32 VERSION = 0;
static constexpr TypeID SHARED_TID = 106;
static constexpr uint32 VERSION = 0;

Shader(ResourceID id, const String& name) : Resource(id, GetTypeID<Shader>(), name) {};
Shader(ResourceID id, const String& name) : Resource(id, GetTypeID<Shader>(), name){};
virtual ~Shader();

virtual bool LoadFromFile(const String& path) override;
Expand Down
5 changes: 2 additions & 3 deletions LinaCore/include/Core/Graphics/Resource/Texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ namespace Lina
void LoadFromStream(IStream& in);
};

static constexpr uint32 VERSION = 0;
static constexpr TypeID SHARED_TID = 100;
static constexpr uint32 VERSION = 0;

Texture(ResourceID id, const String& name) : Resource(id, GetTypeID<Texture>(), name) {};
Texture(ResourceID id, const String& name) : Resource(id, GetTypeID<Texture>(), name){};
virtual ~Texture();

virtual void SaveToStream(OStream& stream) const override;
Expand Down
5 changes: 2 additions & 3 deletions LinaCore/include/Core/Graphics/Resource/TextureSampler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ namespace Lina
class TextureSampler : public Resource
{
public:
static constexpr uint32 VERSION = 0;
static constexpr TypeID SHARED_TID = 107;
static constexpr uint32 VERSION = 0;

TextureSampler(ResourceID id, const String& name) : Resource(id, GetTypeID<TextureSampler>(), name) {};
TextureSampler(ResourceID id, const String& name) : Resource(id, GetTypeID<TextureSampler>(), name){};
virtual ~TextureSampler();

virtual void SaveToStream(OStream& stream) const override;
Expand Down
5 changes: 2 additions & 3 deletions LinaCore/include/Core/Physics/PhysicsMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ namespace Lina
class PhysicsMaterial : public Resource
{
public:
static constexpr uint32 VERSION = 0;
static constexpr TypeID SHARED_TID = 108;
static constexpr uint32 VERSION = 0;

PhysicsMaterial(ResourceID id, const String& name) : Resource(id, GetTypeID<PhysicsMaterial>(), name) {};
PhysicsMaterial(ResourceID id, const String& name) : Resource(id, GetTypeID<PhysicsMaterial>(), name){};
~PhysicsMaterial() = default;

virtual bool LoadFromFile(const String& path) override;
Expand Down
2 changes: 0 additions & 2 deletions LinaCore/include/Core/World/Components/CompAudio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ namespace Lina
class CompAudio : public Component
{
public:

static constexpr TypeID SHARED_TID = 300;
CompAudio() : Component(GetTypeID<CompAudio>(), 0){};
virtual ~CompAudio();

Expand Down
4 changes: 1 addition & 3 deletions LinaCore/include/Core/World/Components/CompLight.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ namespace Lina
class CompLight : public Component
{
public:
static constexpr TypeID SHARED_TID = 301;

CompLight() : Component(GetTypeID<CompLight>(), 0) {};
CompLight() : Component(GetTypeID<CompLight>(), 0){};

inline void SetType(LightType type)
{
Expand Down
3 changes: 0 additions & 3 deletions LinaCore/include/Core/World/Components/CompModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ namespace Lina
class CompModel : public Component
{
public:

static constexpr TypeID SHARED_TID = 302;

CompModel() : Component(GetTypeID<CompModel>(), 0), m_animationController(this){};

void SetModel(Model* model);
Expand Down
4 changes: 1 addition & 3 deletions LinaCore/include/Core/World/Components/CompWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ namespace Lina
class CompWidget : public Component
{
public:
static constexpr TypeID SHARED_TID = 303;

CompWidget() : Component(GetTypeID<CompWidget>(), 0) {};
CompWidget() : Component(GetTypeID<CompWidget>(), 0){};
virtual ~CompWidget();

virtual void CollectReferences(HashSet<ResourceID>& refs) override;
Expand Down
5 changes: 2 additions & 3 deletions LinaCore/include/Core/World/EntityTemplate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ namespace Lina
class EntityTemplate : public Resource
{
public:
static constexpr uint32 VERSION = 0;
static constexpr TypeID SHARED_TID = 109;
static constexpr uint32 VERSION = 0;

EntityTemplate(ResourceID id, const String& name) : Resource(id, GetTypeID<EntityTemplate>(), name) {};
EntityTemplate(ResourceID id, const String& name) : Resource(id, GetTypeID<EntityTemplate>(), name){};
~EntityTemplate() = default;

virtual bool LoadFromFile(const String& path) override;
Expand Down
3 changes: 1 addition & 2 deletions LinaCore/include/Core/World/EntityWorld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ namespace Lina
uint32 targetUpdateTicks = 60;
};

static constexpr uint32 VERSION = 0;
static constexpr TypeID SHARED_TID = 110;
static constexpr uint32 VERSION = 0;

EntityWorld(const EntityWorld& other) = delete;
EntityWorld(ResourceID id, const String& name);
Expand Down

0 comments on commit 73317c6

Please sign in to comment.