-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.go
More file actions
58 lines (50 loc) · 1.31 KB
/
node.go
File metadata and controls
58 lines (50 loc) · 1.31 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
56
57
58
package skud
type Checks struct {
HealthCheck bool
HealthAccess bool
// SanitaryCheck shows whether sanitary check is needed to pass this node.
SanitaryCheck bool
// SanitaryAccess show whether a specific person has successfully passed sanitary check.
SanitaryAccess bool
}
type AccessNode struct {
ID int64
ParentID int64
Name string
Checks Checks
TransitiveTo int64
EntranceReaderID int64
ExitReaderID int64
Children []*AccessNode
}
// CanReach compares readerId to physically reachable readers.
// Reachable readers are either ExitReaderID or any of Children's EntranceReaderID.
//
// i.e. CanReach returns true if readerID is equal to
// ExitReaderID or any of Children's EntranceReaderID, and respective node ID.
func (n AccessNode) CanReach(readerID int64) (int64, bool) {
if readerID == n.ExitReaderID {
return n.ID, true
}
for _, child := range n.Children {
if child.EntranceReaderID == readerID {
return child.ID, true
}
}
return 0, false
}
// GetChild returns pointer to a child with ID equal to nodeID.
func (n AccessNode) GetChild(nodeID int64) *AccessNode {
for _, child := range n.Children {
if child.ID == nodeID {
return child
}
}
return nil
}
type TransitionNode struct {
ID int64
FromNode int64
ToNode int64
ParentNode int64
}