blob: 877ec2daeef034a65400982813eb82fa3f364665 (
plain)
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
|
package utils
import "nectar/types"
// GetDefaultPort returns the default port for a given connection type
func GetDefaultPort(connType types.ConnectionType) string {
if port, exists := DefaultPorts[connType]; exists {
return port
}
return ""
}
// GetFieldCount returns the total number of fields for a connection type
func GetFieldCount(connType types.ConnectionType) int {
if count, exists := FieldCounts[connType]; exists {
return count
}
return 0
}
// GetInputIndex returns the input index for a given field based on connection type
func GetInputIndex(connType types.ConnectionType, fieldIndex int) int {
if mapping, exists := FieldMappings[connType]; exists {
if inputIndex, exists := mapping[fieldIndex]; exists {
return inputIndex
}
}
return -1
}
// NextConnectionType cycles to the next connection type
func NextConnectionType(current types.ConnectionType) types.ConnectionType {
for i, connType := range ConnectionTypes {
if connType == current {
return ConnectionTypes[(i+1)%len(ConnectionTypes)]
}
}
return current
}
// PrevConnectionType cycles to the previous connection type
func PrevConnectionType(current types.ConnectionType) types.ConnectionType {
for i, connType := range ConnectionTypes {
if connType == current {
prevIndex := (i - 1 + len(ConnectionTypes)) % len(ConnectionTypes)
return ConnectionTypes[prevIndex]
}
}
return current
}
|