From 63337cf66072124bc28d06cbfd3be2bbcee63133 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 25 Feb 2014 20:09:15 +0100 Subject: [PATCH] Stupid circular dependency fixed. --- Escape-the-Dawn/Component.h | 4 +--- Escape-the-Dawn/ComponentFactory.h | 5 +++-- Escape-the-Dawn/Components/Transform.h | 6 +++++- Escape-the-Dawn/World.h | 10 ++++++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Escape-the-Dawn/Component.h b/Escape-the-Dawn/Component.h index e50d5c6..c3b49f4 100644 --- a/Escape-the-Dawn/Component.h +++ b/Escape-the-Dawn/Component.h @@ -1,10 +1,8 @@ #ifndef Component_h__ #define Component_h__ -#include - -#include "Entity.h" #include "ComponentFactory.h" +#include "Entity.h" struct Component { diff --git a/Escape-the-Dawn/ComponentFactory.h b/Escape-the-Dawn/ComponentFactory.h index cb698a5..7001fd3 100644 --- a/Escape-the-Dawn/ComponentFactory.h +++ b/Escape-the-Dawn/ComponentFactory.h @@ -2,10 +2,11 @@ #define ComponentFactory_h__ #include +#include #include #include -#include "Component.h" +struct Component; #define REGISTER_COMPONENT(NAME, TYPE) \ static ComponentRegistrar registrar(NAME); @@ -16,7 +17,7 @@ class ComponentRegistrar public: ComponentRegistrar(std::string name) { - ComponentFactory::Instance()->Register(name, [](void) -> std::shared_ptr { return new T() }); + ComponentFactory::Instance()->Register(name, [](void) -> std::shared_ptr { return std::shared_ptr(new T()); }); } }; diff --git a/Escape-the-Dawn/Components/Transform.h b/Escape-the-Dawn/Components/Transform.h index 1ef6b9a..a194e85 100644 --- a/Escape-the-Dawn/Components/Transform.h +++ b/Escape-the-Dawn/Components/Transform.h @@ -1,13 +1,17 @@ +#ifndef Transform_h__ +#define Transform_h__ + #include "Component.h" namespace Components { -REGISTER_COMPONENT("Transform", Transform); struct Transform : Component { float Position[3]; }; +REGISTER_COMPONENT("Transform", Transform); } +#endif // Transform_h__ diff --git a/Escape-the-Dawn/World.h b/Escape-the-Dawn/World.h index 419928c..9f00114 100644 --- a/Escape-the-Dawn/World.h +++ b/Escape-the-Dawn/World.h @@ -1,3 +1,6 @@ +#ifndef World_h__ +#define World_h__ + #include #include #include @@ -5,7 +8,8 @@ #include "Entity.h" #include "Component.h" -#include "Components/Transform.h" +#include "ComponentFactory.h" +//#include "Components/Transform.h" class World { @@ -78,4 +82,6 @@ private: { m_RecycledEntityIDs.push(id); } -}; \ No newline at end of file +}; + +#endif // World_h__ \ No newline at end of file