getter/setter method forwarders added to Remote

EventAdd() and EventRemote() added to Remote

method chaining in builder types split across lines.
This commit is contained in:
onyx-and-iris 2022-08-22 22:33:22 +01:00
parent 3ea4aee863
commit 87a05d81e4

View File

@ -15,6 +15,7 @@ type Remote struct {
Vban *vban Vban *vban
Device *device Device *device
Recorder *recorder Recorder *recorder
Midi *midi_t
pooler *pooler pooler *pooler
} }
@ -58,6 +59,26 @@ func (r *Remote) Mdirty() bool {
return mdirty() return mdirty()
} }
// Gets a float parameter value
func (r *Remote) GetFloat(name string) float64 {
return getParameterFloat(name)
}
// Sets a float paramter value
func (r *Remote) SetFloat(name string, value float32) {
setParameterFloat(name, value)
}
// Gets a string parameter value
func (r *Remote) GetString(name string) string {
return getParameterString(name)
}
// Sets a string paramter value
func (r *Remote) SetString(name, value string) {
setParameterString(name, value)
}
// SendText sets multiple parameters by script // SendText sets multiple parameters by script
func (r *Remote) SendText(script string) { func (r *Remote) SendText(script string) {
setParametersMulti(script) setParametersMulti(script)
@ -73,6 +94,16 @@ func (r *Remote) Deregister(o observer) {
r.pooler.Deregister(o) r.pooler.Deregister(o)
} }
// EventAdd adds an event to the Pooler
func (r *Remote) EventAdd(event string) {
r.pooler.event.Add(event)
}
// EventRemove removes an event from the Pooler
func (r *Remote) EventRemove(event string) {
r.pooler.event.Remove(event)
}
// remoteBuilder defines the interface builder types must satisfy // remoteBuilder defines the interface builder types must satisfy
type remoteBuilder interface { type remoteBuilder interface {
setKind() remoteBuilder setKind() remoteBuilder
@ -83,6 +114,7 @@ type remoteBuilder interface {
makeVban() remoteBuilder makeVban() remoteBuilder
makeDevice() remoteBuilder makeDevice() remoteBuilder
makeRecorder() remoteBuilder makeRecorder() remoteBuilder
makeMidi() remoteBuilder
Build() remoteBuilder Build() remoteBuilder
Get() *Remote Get() *Remote
} }
@ -190,6 +222,13 @@ func (b *genericBuilder) makeRecorder() remoteBuilder {
return b return b
} }
// makeMidi makes a midi type and assigns it to remote.Midi
func (b *genericBuilder) makeMidi() remoteBuilder {
fmt.Println("building midi")
b.r.Midi = newMidi()
return b
}
// Get returns a fully constructed remote type for a kind // Get returns a fully constructed remote type for a kind
func (b *genericBuilder) Get() *Remote { func (b *genericBuilder) Get() *Remote {
return &b.r return &b.r
@ -202,7 +241,14 @@ type basicBuilder struct {
// Build defines the steps required to build a basic type // Build defines the steps required to build a basic type
func (basb *genericBuilder) Build() remoteBuilder { func (basb *genericBuilder) Build() remoteBuilder {
return basb.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban().makeDevice() return basb.setKind().
makeStrip().
makeBus().
makeButton().
makeCommand().
makeVban().
makeDevice().
makeMidi()
} }
// bananaBuilder represents a builder specific to banana type // bananaBuilder represents a builder specific to banana type
@ -212,7 +258,15 @@ type bananaBuilder struct {
// Build defines the steps required to build a banana type // Build defines the steps required to build a banana type
func (banb *bananaBuilder) Build() remoteBuilder { func (banb *bananaBuilder) Build() remoteBuilder {
return banb.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban().makeDevice().makeRecorder() return banb.setKind().
makeStrip().
makeBus().
makeButton().
makeCommand().
makeVban().
makeDevice().
makeRecorder().
makeMidi()
} }
// potatoBuilder represents a builder specific to potato type // potatoBuilder represents a builder specific to potato type
@ -222,7 +276,15 @@ type potatoBuilder struct {
// Build defines the steps required to build a potato type // Build defines the steps required to build a potato type
func (potb *potatoBuilder) Build() remoteBuilder { func (potb *potatoBuilder) Build() remoteBuilder {
return potb.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban().makeDevice().makeRecorder() return potb.setKind().
makeStrip().
makeBus().
makeButton().
makeCommand().
makeVban().
makeDevice().
makeRecorder().
makeMidi()
} }
// NewRemote returns a Remote type for a kind // NewRemote returns a Remote type for a kind