Minor code changes.
Moved template function definitions out of class definitions. Moved Instances to util/.
This commit is contained in:
parent
99da2acd01
commit
11da25ce69
8 changed files with 33 additions and 27 deletions
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <Thor/Graphics.hpp>
|
#include <Thor/Graphics.hpp>
|
||||||
|
|
||||||
#include "Instances.h"
|
#include "util/Instances.h"
|
||||||
#include "abstract/Character.h"
|
#include "abstract/Character.h"
|
||||||
#include "sprite/Cover.h"
|
#include "sprite/Cover.h"
|
||||||
#include "sprite/Enemy.h"
|
#include "sprite/Enemy.h"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "../Instances.h"
|
#include "../util/Instances.h"
|
||||||
#include "../util/String.h"
|
#include "../util/String.h"
|
||||||
#include "../util/Yaml.h"
|
#include "../util/Yaml.h"
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
#include <Thor/Particles.hpp>
|
#include <Thor/Particles.hpp>
|
||||||
|
|
||||||
#include "../Instances.h"
|
#include "../util/Instances.h"
|
||||||
#include "../abstract/Physical.h"
|
#include "../abstract/Physical.h"
|
||||||
#include "../particle/Emitter.h"
|
#include "../particle/Emitter.h"
|
||||||
#include "../util/Yaml.h"
|
#include "../util/Yaml.h"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#ifndef DG_ENEMY_H_
|
#ifndef DG_ENEMY_H_
|
||||||
#define DG_ENEMY_H
|
#define DG_ENEMY_H
|
||||||
|
|
||||||
#include "../Instances.h"
|
#include "../util/Instances.h"
|
||||||
#include "../abstract/Character.h"
|
#include "../abstract/Character.h"
|
||||||
#include "../util/Collection.h"
|
#include "../util/Collection.h"
|
||||||
#include "../util/Vector.h"
|
#include "../util/Vector.h"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <SFML/System.hpp>
|
#include <SFML/System.hpp>
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
#include "../Instances.h"
|
#include "../util/Instances.h"
|
||||||
#include "../Pathfinder.h"
|
#include "../Pathfinder.h"
|
||||||
#include "../abstract/Character.h"
|
#include "../abstract/Character.h"
|
||||||
#include "../items/Weapon.h"
|
#include "../items/Weapon.h"
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
#include <Box2D/Box2D.h>
|
#include <Box2D/Box2D.h>
|
||||||
|
|
||||||
#include "Pathfinder.h"
|
#include "../Pathfinder.h"
|
||||||
#include "TileManager.h"
|
#include "../TileManager.h"
|
||||||
#include "util/Collection.h"
|
#include "Collection.h"
|
||||||
|
|
||||||
class Pathfinder;
|
class Pathfinder;
|
||||||
class TileManager;
|
class TileManager;
|
|
@ -29,13 +29,16 @@ template <class T>
|
||||||
class Singleton : public sf::NonCopyable {
|
class Singleton : public sf::NonCopyable {
|
||||||
// Public functions.
|
// Public functions.
|
||||||
public:
|
public:
|
||||||
/**
|
static T& i();
|
||||||
* Returns the instance of T.
|
};
|
||||||
*/
|
|
||||||
static T& i() {
|
/**
|
||||||
|
* Returns the instance of T.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
T& Singleton<T>::i() {
|
||||||
static T s;
|
static T s;
|
||||||
return s;
|
return s;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DG_SINGLETON_H_ */
|
#endif /* DG_SINGLETON_H_ */
|
||||||
|
|
|
@ -27,19 +27,8 @@ public:
|
||||||
|
|
||||||
static void setFolder(const String& folder);
|
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 <typename T>
|
template <typename T>
|
||||||
T get(const String& key) const {
|
T get(const String& key) const;
|
||||||
T tmp;
|
|
||||||
mNode[key] >> tmp;
|
|
||||||
return tmp;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Private variables.
|
// Private variables.
|
||||||
private:
|
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 <typename T>
|
||||||
|
T Yaml::get(const String& key) const {
|
||||||
|
T tmp;
|
||||||
|
mNode[key] >> tmp;
|
||||||
|
return tmp;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* DG_YAML_H_ */
|
#endif /* DG_YAML_H_ */
|
||||||
|
|
Reference in a new issue