Newer
Older
#ifndef BEHAVIOUR_h
#define BEHAVIOUR_h
class Behaviour {
protected:
boolean _interruptable = true;
boolean _temp = false;
boolean _priority = false;
boolean _running = false;
boolean _background = false;
String _name = "name";
public:
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
//Can this behaviour be interruped
virtual boolean is_interruptable();
//Can this behaviour be run quickly without stopping what's going on (e.g. comms, debug)
virtual boolean is_temp();
//Should this behaviour override others
virtual boolean is_priority();
//Is the behaviour running
virtual boolean is_running();
//What's the name of this behaviour
virtual boolean is_background();
//What's the name of this behaviour
virtual String name();
//What arguments does the behaviour take? Override this to document your behaviour
virtual char* args();
//Start the behaviour, with arguments (don't know why this can't be virtual?)
virtual String start(String args);
//Update the behaviour periodically
virtual void update();
//Start the behaviour, with arguments (don't know why this can't be virtual?)
virtual void stop();
};
/*
* Example way to make a simple behaviour
*/
class TestBehaviour : public Behaviour {
public:
TestBehaviour(String n);
String start(String args);
};
class BehaviourTable
{
Behaviour* behaviours[40];
public:
int num = 0;
BehaviourTable();
void add(Behaviour *b) ;
Behaviour* get(String n);
Behaviour* get_by_num(int n);
int get_num_behaviours();
};
#endif