forked from clandry94/agraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnop_filter.go
49 lines (42 loc) · 823 Bytes
/
nop_filter.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
package agraph
/*
Null operation filter. Does nothing.
*/
type Nop struct {
source chan []uint16
sink chan []uint16
Name string
}
func newNop(name string) (Node, error) {
return &Nop{
source: make(chan []uint16, SOURCE_SIZE),
sink: nil,
Name: name,
}, nil
}
func (n *Nop) SetSink(c chan []uint16) {
n.sink = c
}
func (n *Nop) Source() chan []uint16 {
return n.source
}
func (n *Nop) Sink() chan []uint16 {
return n.sink
}
func (n *Nop) Process() error {
for {
select {
case data := <-n.source:
var filteredData, err = n.do(data)
//fmt.Printf("Data processed from %v, here it is: %v\n", n.Name, filteredData)
if err != nil {
panic("Could not filter!")
}
n.sink <- filteredData
}
}
return nil
}
func (n *Nop) do(data []uint16) ([]uint16, error) {
return data, nil
}