diff --git a/source/Game.cpp b/source/Game.cpp index 684d80c..1ef888a 100644 --- a/source/Game.cpp +++ b/source/Game.cpp @@ -9,7 +9,7 @@ #include -#include "Instances.h" +#include "util/Instances.h" #include "abstract/Character.h" #include "sprite/Cover.h" #include "sprite/Enemy.h" diff --git a/source/abstract/Character.h b/source/abstract/Character.h index 58c9e6c..fa52873 100644 --- a/source/abstract/Character.h +++ b/source/abstract/Character.h @@ -11,7 +11,7 @@ #include #include "Sprite.h" -#include "../Instances.h" +#include "../util/Instances.h" #include "../util/String.h" #include "../util/Yaml.h" diff --git a/source/items/Weapon.h b/source/items/Weapon.h index 9220311..2e39241 100755 --- a/source/items/Weapon.h +++ b/source/items/Weapon.h @@ -10,7 +10,7 @@ #include -#include "../Instances.h" +#include "../util/Instances.h" #include "../abstract/Physical.h" #include "../particle/Emitter.h" #include "../util/Yaml.h" diff --git a/source/sprite/Enemy.h b/source/sprite/Enemy.h index c253e9c..afe6b6e 100644 --- a/source/sprite/Enemy.h +++ b/source/sprite/Enemy.h @@ -8,7 +8,7 @@ #ifndef DG_ENEMY_H_ #define DG_ENEMY_H -#include "../Instances.h" +#include "../util/Instances.h" #include "../abstract/Character.h" #include "../util/Collection.h" #include "../util/Vector.h" diff --git a/source/sprite/Player.h b/source/sprite/Player.h index ffad388..2cf15b8 100644 --- a/source/sprite/Player.h +++ b/source/sprite/Player.h @@ -11,7 +11,7 @@ #include #include -#include "../Instances.h" +#include "../util/Instances.h" #include "../Pathfinder.h" #include "../abstract/Character.h" #include "../items/Weapon.h" diff --git a/source/Instances.h b/source/util/Instances.h similarity index 88% rename from source/Instances.h rename to source/util/Instances.h index df5ff0b..ee3b262 100644 --- a/source/Instances.h +++ b/source/util/Instances.h @@ -10,9 +10,9 @@ #include -#include "Pathfinder.h" -#include "TileManager.h" -#include "util/Collection.h" +#include "../Pathfinder.h" +#include "../TileManager.h" +#include "Collection.h" class Pathfinder; class TileManager; diff --git a/source/util/Singleton.h b/source/util/Singleton.h index 5859096..4659729 100644 --- a/source/util/Singleton.h +++ b/source/util/Singleton.h @@ -29,13 +29,16 @@ template class Singleton : public sf::NonCopyable { // Public functions. public: - /** - * Returns the instance of T. - */ - static T& i() { - static T s; - return s; - }; + static T& i(); +}; + +/** +* Returns the instance of T. +*/ +template +T& Singleton::i() { + static T s; + return s; }; #endif /* DG_SINGLETON_H_ */ diff --git a/source/util/Yaml.h b/source/util/Yaml.h index 0b44fc8..02e5240 100644 --- a/source/util/Yaml.h +++ b/source/util/Yaml.h @@ -27,19 +27,8 @@ public: static void setFolder(const String& folder); - /** - * Gets a value of a specified type by key. Throws exception if key not found. - * - * @param key The string by which to select the return value. - * @tparam T The type of the return value. - * @return The value of the specified key. - */ template - T get(const String& key) const { - T tmp; - mNode[key] >> tmp; - return tmp; - }; + T get(const String& key) const; // Private variables. private: @@ -62,4 +51,18 @@ namespace { } }; +/** + * Gets a value of a specified type by key. Throws exception if key not found. + * + * @param key The string by which to select the return value. + * @tparam T The type of the return value. + * @return The value of the specified key. + */ +template +T Yaml::get(const String& key) const { + T tmp; + mNode[key] >> tmp; + return tmp; +}; + #endif /* DG_YAML_H_ */