26 lines
511 B
Go
26 lines
511 B
Go
package models
|
|
|
|
// driver model
|
|
type Driver struct {
|
|
Type string `json:"type"` // driver type name of driver in collection
|
|
Buses map[string]*Bus `json:"buses"` // name of driver bus
|
|
}
|
|
|
|
func (d *Driver) AddBus(name string) *Bus {
|
|
if d.Buses == nil {
|
|
d.Buses = make(map[string]*Bus)
|
|
}
|
|
if b, ok := d.Buses[name]; ok {
|
|
return b
|
|
}
|
|
d.Buses[name] = &Bus{Name: name}
|
|
return d.Buses[name]
|
|
}
|
|
|
|
func (d *Driver) GetBus(name string) *Bus {
|
|
if b, ok := d.Buses[name]; ok {
|
|
return b
|
|
}
|
|
return nil
|
|
}
|