-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollector.go
executable file
·61 lines (54 loc) · 1.11 KB
/
collector.go
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
package zinc
// C ...
type C interface {
Entities() []EntityID
ClearCollectedEntities()
}
type c struct {
group []G
groupEvent []GroupEvent
entityList *el
}
// NewCollector ...
// TODO: Write TEST
func NewCollector(group []G, groupEvent []GroupEvent) C {
collector := &c{
group: group,
groupEvent: groupEvent,
entityList: newEntityList(),
}
collector.activate()
return collector
}
func (c *c) addEntity(key uint, id EntityID) {
c.entityList.AddEntity(id)
}
// activate ...
func (c *c) activate() {
for i, group := range c.group {
groupEvent := c.groupEvent[i]
switch groupEvent {
case GroupEventAdded:
group.HandleEntityAdded(c.addEntity)
break
case GroupEventUpdated:
group.HandleEntityUpdated(c.addEntity)
break
case GroupEventDeleted:
group.HandleEntityDeleted(c.addEntity)
break
}
}
}
// ClearCollectedEntities ...
// TODO: Write TEST
func (c *c) ClearCollectedEntities() {
for _, id := range c.entityList.Entities() {
c.entityList.DeleteEntity(id)
}
}
// Entities ...
// TODO: Write TEST
func (c *c) Entities() []EntityID {
return c.entityList.Entities()
}