mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Checking that T is in fact derived from Dependency
This commit is contained in:
parent
1db3592d4c
commit
e40961df12
1 changed files with 4 additions and 1 deletions
|
@ -16,6 +16,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
class DependencyManager {
|
class DependencyManager {
|
||||||
public:
|
public:
|
||||||
|
@ -56,7 +57,9 @@ T* DependencyManager::get() {
|
||||||
|
|
||||||
// Found no instance in hash so we create one.
|
// Found no instance in hash so we create one.
|
||||||
T* newInstance = new T();
|
T* newInstance = new T();
|
||||||
getInstanceHash().insert(typeId, dynamic_cast<Dependency*>(newInstance));
|
instance = dynamic_cast<Dependency*>(newInstance);
|
||||||
|
assert(instance != NULL); // If this triggers, check that T is derived from Dependency
|
||||||
|
getInstanceHash().insert(typeId, instance);
|
||||||
return newInstance;
|
return newInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue