-
Notifications
You must be signed in to change notification settings - Fork 2
/
PatternList.h
75 lines (64 loc) · 1.58 KB
/
PatternList.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
#pragma once
#include "Namespace.h"
#include "Color.h"
#include "Pattern.h"
LED_CONTROLLER_NAMESPACE_ENTER
/**
* Provide a linked list to hold, update, and apply Patterns.
*
* The list also takes care of removing expired patterns.
*/
class PatternList {
private:
Pattern* pattern;
PatternList* next;
/**
* Remove and delete the 'next'. Take over
* any subsequent PatternLists.
*/
void removeNext();
public:
/**
* Create a new unconnected list node. The node holds and
* takes ownership of the given pattern.
*/
PatternList(Pattern* pattern);
/**
* Create a new list node with no Pattern (to use as a root).
*/
PatternList();
/**
* Create a new PatternList to hold the given Pattern,
* and insert it (taking ownership).
*/
void insert(Pattern* pattern);
/**
* Insert the given node after this one. (This is preferable to
* append because it is constant time / stack space.)
*
* If the given node has any subsequent nodes, they are
* removed and deleted.
*
* Takes ownership.
*/
void insert(PatternList* next);
/**
* Update this node's Pattern, and recurr.
*
* After the 'next' updates (if present), if its Pattern
* isExpired, remove and delete the 'next' (and consequently
* its pattern).
*
* @return whether this or any subsequent pattern updated.
*/
bool update();
/**
* Call apply on this node's Pattern, and recurr on 'next'.
*/
void apply(Color* stripColors);
/**
* Delete any 'next' nodes, as well as any Pattern.
*/
~PatternList();
};
LED_CONTROLLER_NAMESPACE_EXIT