-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEngineBind.h
More file actions
57 lines (46 loc) · 1.83 KB
/
EngineBind.h
File metadata and controls
57 lines (46 loc) · 1.83 KB
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
//
// FormulaEngine Project
// By Mike Lewis - 2016
//
// Interfaces for binding between script and engine layers
//
// This is not the best example of how to bind a scripting language
// to an engine. It is meant solely to demonstrate a minimalist yet
// fully functional "glue layer" between the formula-driven bits of
// the system and the more "engine-like" areas.
//
// A better system would probably use macro markup to automatically
// create bindings instead of relying on pumping everything through
// one interface keyed off of tokens.
//
#pragma once
// Forward declarations
class Scriptable;
class ScriptWorld;
//
// Interface representing one instance of a script object bound
// onto an engine object. There should be one of these per pair
// of objects. It is the engine side's responsibility to derive
// from this interface and provide the actual linkage between a
// script call and the backing engine data.
//
// Note that engine classes need not derive directly from this,
// which allows for better decoupling of engine and script code
// overall, since only a thin "shim" layer needs to be aware of
// both script and engine concerns.
//
struct IEngineBinding {
virtual ~IEngineBinding () { }
virtual void SetGoalState (unsigned token, unsigned tokenValue) = 0;
virtual void SetGoalState (unsigned token, ValueT state) = 0;
virtual void SetGoalState (unsigned token, ValueT statex, ValueT statey) = 0;
virtual bool HasPropertyBinding (unsigned token) const = 0;
virtual unsigned GetPropertyBinding (unsigned token, unsigned * out) const = 0;
virtual unsigned GetPropertyBinding (unsigned token, ValueT * out1, ValueT * out2) const = 0;
};
//
// Factory interface for generating binding records
//
struct IEngineBinder {
virtual IEngineBinding * CreateBinding (Scriptable * scriptable, ScriptWorld * world, unsigned token) = 0;
};