add remove driver function
This commit is contained in:
@@ -38,7 +38,8 @@ next:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) RemoveBus(bus *Bus) {
|
func (d *Driver) RemoveBuses(buses []*Bus) {
|
||||||
|
for _, bus := range buses {
|
||||||
for _, currentBus := range d.Buses {
|
for _, currentBus := range d.Buses {
|
||||||
if currentBus.Name != bus.Name {
|
if currentBus.Name != bus.Name {
|
||||||
continue
|
continue
|
||||||
@@ -69,6 +70,7 @@ func (d *Driver) RemoveBus(bus *Bus) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Driver) GetBus(name string) *Bus {
|
func (d *Driver) GetBus(name string) *Bus {
|
||||||
for _, b := range d.Buses {
|
for _, b := range d.Buses {
|
||||||
|
@@ -19,3 +19,11 @@ func (d *Drivers) AddDriver(drv *Driver) {
|
|||||||
}
|
}
|
||||||
(*d)[drv.Type] = drv
|
(*d)[drv.Type] = drv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Drivers) RemoveDriver(drv *Driver) {
|
||||||
|
if driver, ok := (*d)[drv.Type]; ok {
|
||||||
|
driver.RemoveBuses(drv.Buses)
|
||||||
|
(*d)[drv.Type] = driver
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user