/
EntityScheme.hpp
76 lines (59 loc) · 1.72 KB
/
EntityScheme.hpp
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 ___INANITY_OIL_ENTITY_SCHEME_HPP___
#define ___INANITY_OIL_ENTITY_SCHEME_HPP___
#include "Id.hpp"
#include "../inanity/script/script.hpp"
#include <map>
#include <vector>
BEGIN_INANITY_SCRIPT
class Any;
END_INANITY_SCRIPT
BEGIN_INANITY_OIL
class Entity;
class EntityFieldType;
/// Scheme of fields in entity.
class EntityScheme : public Object
{
public:
struct Field
{
ptr<EntityFieldType> type;
String name;
};
typedef std::map<EntityFieldId, Field> Fields;
/// Interface internal struct.
struct Interface
{
/// Callback for creating interface-specific object.
ptr<Script::Any> callback;
};
typedef std::map<EntityInterfaceId, Interface> Interfaces;
private:
EntitySchemeId id;
String name;
/// Fields of scheme.
Fields fields;
/// Fields of scheme by index.
std::vector<EntityFieldId> fieldIds;
/// Interfaces supported by scheme.
Interfaces interfaces;
/// Interfaces of scheme by index.
std::vector<EntityInterfaceId> interfaceIds;
public:
EntityScheme(const EntitySchemeId& id, const String& name);
EntitySchemeId GetId() const;
String GetName() const;
const Fields& GetFields() const;
const Interfaces& GetInterfaces() const;
//** for scripts
int GetFieldsCount() const;
EntityFieldId GetFieldId(int index) const;
ptr<EntityFieldType> GetFieldType(const EntityFieldId& fieldId) const;
String GetFieldName(const EntityFieldId& fieldId) const;
void AddField(const EntityFieldId& fieldId, ptr<EntityFieldType> type, const String& name);
int GetInterfacesCount() const;
EntityInterfaceId GetInterfaceId(int index) const;
bool HasInterface(const EntityInterfaceId& interfaceId) const;
void AddInterface(const EntityInterfaceId& interfaceId, ptr<Script::Any> callback);
};
END_INANITY_OIL
#endif