Skip to content

Commit

Permalink
Tags on edge types
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed May 1, 2023
1 parent 56a4ed5 commit c31d0c1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion modules/engine/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ type edgeInfo struct {
probability ProbabilityCalculatorFunction
Name string
Description string
tags []string
tags map[string]struct{}
multi bool // If true, this attribute can have multiple values
nonunique bool // Doing a Find on this attribute will return multiple results
merge bool // If true, objects can be merged on this attribute
Expand Down Expand Up @@ -277,6 +277,21 @@ func (p Edge) IsHidden() bool {
return edgeInfos[p].hidden
}

func (p Edge) Tag(t string) Edge {
tags := edgeInfos[p].tags
if tags == nil {
tags = make(map[string]struct{})
edgeInfos[p].tags = tags
}
tags[t] = struct{}{}
return p
}

func (p Edge) HasTag(t string) bool {
_, found := edgeInfos[p].tags[t]
return found
}

func LookupEdge(name string) Edge {
edgeMutex.RLock()
defer edgeMutex.RUnlock()
Expand Down

0 comments on commit c31d0c1

Please sign in to comment.