Add convenience functions

This commit is contained in:
Adrian Zankich 2014-07-07 21:45:36 -07:00
parent 3f3444f7e7
commit ba63c57a0b
2 changed files with 12 additions and 0 deletions

View File

@ -58,6 +58,10 @@ func (g *Gobot) Robots() *robots {
return g.robots return g.robots
} }
func (g *Gobot) AddRobot(r *Robot) *Robot {
return g.Robots().Add(r)
}
func (g *Gobot) Robot(name string) *Robot { func (g *Gobot) Robot(name string) *Robot {
for _, robot := range g.Robots().robots { for _, robot := range g.Robots().robots {
if robot.Name == name { if robot.Name == name {

View File

@ -113,6 +113,10 @@ func (r *Robot) Devices() *devices {
return r.devices return r.devices
} }
func (r *Robot) AddDevice(d Device) Device {
return r.Devices().Add(d)
}
func (r *Robot) Device(name string) Device { func (r *Robot) Device(name string) Device {
if r == nil { if r == nil {
return nil return nil
@ -129,6 +133,10 @@ func (r *Robot) Connections() *connections {
return r.connections return r.connections
} }
func (r *Robot) AddConnection(c Connection) Connection {
return r.Connections().Add(c)
}
func (r *Robot) Connection(name string) Connection { func (r *Robot) Connection(name string) Connection {
if r == nil { if r == nil {
return nil return nil