Minor code changes.

Moved template function definitions out of class definitions.
Moved Instances to util/.
This commit is contained in:
Felix Ableitner 2012-10-13 13:11:43 +02:00
parent 99da2acd01
commit 11da25ce69
8 changed files with 33 additions and 27 deletions

View file

@ -9,7 +9,7 @@
#include <Thor/Graphics.hpp>
#include "Instances.h"
#include "util/Instances.h"
#include "abstract/Character.h"
#include "sprite/Cover.h"
#include "sprite/Enemy.h"

View file

@ -11,7 +11,7 @@
#include <vector>
#include "Sprite.h"
#include "../Instances.h"
#include "../util/Instances.h"
#include "../util/String.h"
#include "../util/Yaml.h"

View file

@ -10,7 +10,7 @@
#include <Thor/Particles.hpp>
#include "../Instances.h"
#include "../util/Instances.h"
#include "../abstract/Physical.h"
#include "../particle/Emitter.h"
#include "../util/Yaml.h"

View file

@ -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"

View file

@ -11,7 +11,7 @@
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include "../Instances.h"
#include "../util/Instances.h"
#include "../Pathfinder.h"
#include "../abstract/Character.h"
#include "../items/Weapon.h"

View file

@ -10,9 +10,9 @@
#include <Box2D/Box2D.h>
#include "Pathfinder.h"
#include "TileManager.h"
#include "util/Collection.h"
#include "../Pathfinder.h"
#include "../TileManager.h"
#include "Collection.h"
class Pathfinder;
class TileManager;

View file

@ -29,13 +29,16 @@ template <class T>
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 <class T>
T& Singleton<T>::i() {
static T s;
return s;
};
#endif /* DG_SINGLETON_H_ */

View file

@ -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 <typename T>
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 <typename T>
T Yaml::get(const String& key) const {
T tmp;
mNode[key] >> tmp;
return tmp;
};
#endif /* DG_YAML_H_ */