-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathScriptable.h
54 lines (37 loc) · 1.52 KB
/
Scriptable.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
#pragma once
struct IListContainer;
struct IEngineBinder;
struct IEngineBinding;
class Scriptable {
public: // Construction and destruction
Scriptable() { }
Scriptable(Scriptable && other);
~Scriptable();
private: // Non-copyable
Scriptable(const Scriptable & other) = delete;
Scriptable & operator = (const Scriptable & other) = delete;
public: // Component accessors
const ScopedPropertyBag & GetScopes() const { return m_scopes; }
ScopedPropertyBag & GetScopes() { return m_scopes; }
EventHandlerSet * GetEvents() { if(!m_eventHandlers) { m_eventHandlers = new EventHandlerSet; } return m_eventHandlers; }
public: // Archetype support
void AddBinding(unsigned bindingToken);
IEngineBinding * GetBinding(unsigned bindingToken);
const IEngineBinding * GetBinding(unsigned bindingToken) const;
Result ResolveBinding(const IFormulaContext & context, unsigned scope, unsigned token) const;
void BindAll(IEngineBinder * binder, ScriptWorld * world);
Scriptable * Instantiate() const;
public: // Membership notification interface
void OnListMembershipAdded(unsigned listToken, IListContainer * owner) const;
void OnListMembershipRemoved(unsigned listToken, IListContainer * owner) const;
private: // Internal helper structures
struct Membership {
IListContainer * owner;
unsigned token;
};
private: // Internal state
ScopedPropertyBag m_scopes;
EventHandlerSet * m_eventHandlers = nullptr;
std::map<unsigned, IEngineBinding *> m_bindings;
mutable std::vector<Membership> m_listMemberships;
};