From ba63c57a0bb8e80eb3b30f977926fabdd1c09fe1 Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Mon, 7 Jul 2014 21:45:36 -0700 Subject: [PATCH] Add convenience functions --- gobot.go | 4 ++++ robot.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/gobot.go b/gobot.go index 58a0d7b8..93f49c53 100644 --- a/gobot.go +++ b/gobot.go @@ -58,6 +58,10 @@ func (g *Gobot) Robots() *robots { return g.robots } +func (g *Gobot) AddRobot(r *Robot) *Robot { + return g.Robots().Add(r) +} + func (g *Gobot) Robot(name string) *Robot { for _, robot := range g.Robots().robots { if robot.Name == name { diff --git a/robot.go b/robot.go index 7934fd55..3728a542 100644 --- a/robot.go +++ b/robot.go @@ -113,6 +113,10 @@ func (r *Robot) Devices() *devices { return r.devices } +func (r *Robot) AddDevice(d Device) Device { + return r.Devices().Add(d) +} + func (r *Robot) Device(name string) Device { if r == nil { return nil @@ -129,6 +133,10 @@ func (r *Robot) Connections() *connections { return r.connections } +func (r *Robot) AddConnection(c Connection) Connection { + return r.Connections().Add(c) +} + func (r *Robot) Connection(name string) Connection { if r == nil { return nil