rework getters, setters in higher classes

This commit is contained in:
onyx 2023-08-12 03:09:23 +01:00
parent bee52b6541
commit 4e9ff66640
6 changed files with 34 additions and 28 deletions

View File

@ -75,7 +75,7 @@ class RemoteBasic : Remote {
$this.bus = Make_Buses($this) $this.bus = Make_Buses($this)
$this.button = Make_Buttons $this.button = Make_Buttons
$this.vban = Make_Vban($this) $this.vban = Make_Vban($this)
$this.command = Make_Command $this.command = Make_Command($this)
} }
} }
@ -92,7 +92,7 @@ class RemoteBanana : Remote {
$this.bus = Make_Buses($this) $this.bus = Make_Buses($this)
$this.button = Make_Buttons $this.button = Make_Buttons
$this.vban = Make_Vban($this) $this.vban = Make_Vban($this)
$this.command = Make_Command $this.command = Make_Command($this)
$this.recorder = Make_Recorder($this) $this.recorder = Make_Recorder($this)
} }
} }
@ -110,7 +110,7 @@ class RemotePotato : Remote {
$this.bus = Make_Buses($this) $this.bus = Make_Buses($this)
$this.button = Make_Buttons $this.button = Make_Buttons
$this.vban = Make_Vban($this) $this.vban = Make_Vban($this)
$this.command = Make_Command $this.command = Make_Command($this)
$this.recorder = Make_Recorder($this) $this.recorder = Make_Recorder($this)
} }
} }

View File

@ -18,15 +18,15 @@ class IBus {
} }
[single] Getter ($param) { [single] Getter ($param) {
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false return $this.remote.Getter("$($this.identifier()).$param")
} }
[string] Getter_String ($param) { [string] Getter_String ($param) {
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $true return $this.remote.Getter_String("$($this.identifier()).$param")
} }
[void] Setter ($param, $set) { [void] Setter ($param, $val) {
Param_Set -PARAM "$($this.identifier()).$param" -Value $set $this.remote.Setter("$($this.identifier()).$param", $val)
} }
} }

View File

@ -2,8 +2,12 @@
. $PSScriptRoot\inst.ps1 . $PSScriptRoot\inst.ps1
class Special { class Special {
Special () { [Object]$remote
Special ([Object]$remote) {
AddActionMembers -PARAMS @('restart', 'shutdown', 'show') AddActionMembers -PARAMS @('restart', 'shutdown', 'show')
$this.remote = $remote
} }
[string] identifier () { [string] identifier () {
@ -15,15 +19,15 @@ class Special {
} }
[single] Getter ($param) { [single] Getter ($param) {
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false return $this.remote.Getter("$($this.identifier()).$param")
} }
[void] Setter ($param, $val) { [void] Setter ($param, $val) {
if ($val -is [Boolean]) { if ($val -is [Boolean]) {
Param_Set -PARAM "$($this.identifier()).$param" -Value $(if ($val) { 1 } else { 0 }) $this.remote.Setter("$($this.identifier()).$param", $(if ($val) { 1 } else { 0 }))
} }
else { else {
Param_Set -PARAM "$($this.identifier()).$param" -Value $val $this.remote.Setter("$($this.identifier()).$param", $val)
} }
} }
@ -67,6 +71,6 @@ class Special {
} }
} }
function Make_Command { function Make_Command([Object]$remote) {
return [Special]::new() return [Special]::new($remote)
} }

View File

@ -8,15 +8,15 @@ class IRecorder {
} }
[single] Getter ($param) { [single] Getter ($param) {
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false return $this.remote.Getter("$($this.identifier()).$param")
} }
[void] Setter ($param, $val) { [void] Setter ($param, $val) {
if ($val -is [Boolean]) { if ($val -is [Boolean]) {
Param_Set -PARAM "$($this.identifier()).$param" -Value $(if ($val) { 1 } else { 0 }) $this.remote.Setter("$($this.identifier()).$param", $(if ($val) { 1 } else { 0 }))
} }
else { else {
Param_Set -PARAM "$($this.identifier()).$param" -Value $val $this.remote.Setter("$($this.identifier()).$param", $val)
} }
} }
} }

View File

@ -14,15 +14,15 @@ class IStrip {
} }
[single] Getter ($param) { [single] Getter ($param) {
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false return $this.remote.Getter("$($this.identifier()).$param")
} }
[string] Getter_String ($param) { [string] Getter_String ($param) {
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $true return $this.remote.Getter_String("$($this.identifier()).$param")
} }
[void] Setter ($param, $val) { [void] Setter ($param, $val) {
Param_Set -PARAM "$($this.identifier()).$param" -Value $val $this.remote.Setter("$($this.identifier()).$param", $val)
} }
} }

View File

@ -1,9 +1,11 @@
class IVban { class IVban {
[int32]$index [int32]$index
[Object]$remote
[string]$direction [string]$direction
IVban ([int]$index, [string]$direction) { IVban ([int]$index, [Object]$remote, [string]$direction) {
$this.index = $index $this.index = $index
$this.remote = $remote
$this.direction = $direction $this.direction = $direction
} }
@ -16,20 +18,20 @@ class IVban {
} }
[single] Getter ($param) { [single] Getter ($param) {
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false return $this.remote.Getter("$($this.identifier()).$param")
} }
[string] Getter_String ($param) { [string] Getter_String ($param) {
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $true return $this.remote.Getter_String("$($this.identifier()).$param")
} }
[void] Setter ($param, $val) { [void] Setter ($param, $val) {
Param_Set -PARAM "$($this.identifier()).$param" -Value $val $this.remote.Setter("$($this.identifier()).$param", $val)
} }
} }
class Vban : IVban { class Vban : IVban {
Vban ([int]$index, [string]$direction) : base ($index, $direction) { Vban ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
} }
hidden $_on = $($this | Add-Member ScriptProperty 'on' ` hidden $_on = $($this | Add-Member ScriptProperty 'on' `
@ -173,13 +175,13 @@ class Vban : IVban {
class VbanInstream : Vban { class VbanInstream : Vban {
VbanInstream ([int]$index, [string]$direction) : base ($index, $direction) { VbanInstream ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
} }
} }
class VbanOutstream : Vban { class VbanOutstream : Vban {
VbanOutstream ([int]$index, [string]$direction) : base ($index, $direction) { VbanOutstream ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
} }
} }
@ -189,10 +191,10 @@ function Make_Vban ([Object]$remote) {
[System.Collections.ArrayList]$outstream = @() [System.Collections.ArrayList]$outstream = @()
0..$($remote.kind.vban_in - 1) | ForEach-Object { 0..$($remote.kind.vban_in - 1) | ForEach-Object {
[void]$instream.Add([VbanInstream]::new($_, "in")) [void]$instream.Add([VbanInstream]::new($_, $remote, "in"))
} }
0..$($remote.kind.vban_out - 1) | ForEach-Object { 0..$($remote.kind.vban_out - 1) | ForEach-Object {
[void]$outstream.Add([VbanOutstream]::new($_, "out")) [void]$outstream.Add([VbanOutstream]::new($_, $remote, "out"))
} }
$CustomObject = [pscustomobject]@{ $CustomObject = [pscustomobject]@{