-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathComponentTypeManager.h
executable file
·76 lines (56 loc) · 1.73 KB
/
ComponentTypeManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef COMPTYPE_MANAGER_H
#define COMPTYPE_MANAGER_H
#include <assert.h>
#include <bitset>
#include "TypeInfoComparator.h"
#include "ComponentType.h"
#include "Component.h"
#include <map>
namespace artemis {
/**
* Manages the id and bitset for every component based on their type.
*/
class ComponentTypeManager {
private:
ComponentTypeManager();
static std::map<const std::type_info*,ComponentType*,
type_info_comparator> componentTypes;
public:
static void deleteComponentTypes();
/**
*
**/
static ComponentType & getTypeFor(const std::type_info &t);
/**
* Gets the component type object
**/
template<typename c>
static ComponentType & getTypeFor() {
//Check if we are being legal with components and shizzle
//Component * c = (component*)0;
//assert((std::is_base_of<Component, c >::value == true));
return getTypeFor(typeid(c));
}
/**
* Gets the bit set of a component
**/
template<typename c>
static std::bitset<BITSIZE> getBit() {
//Check if we are being legal with components and shizzle
//Component * c = (component*)0;
//assert((std::is_base_of< Component, c >::value == true));
return getTypeFor(typeid(c)).getBit();
}
/**
* Gets the component id
**/
template<typename c>
static int getId() {
//Check if we are being legal with components and shizzle
//assert((std::is_base_of< Component, c >::value == true));
return getTypeFor(typeid(c)).getId();
};
//typedef getCompBit bitset<BITSIZE>(*getBit<Component>)();
};
}
#endif // $(Guard token)