import unittest
include dio
suite "param tests":
test "creation":
var
boolParam = newParam("toggle", false)
intParam = newParam("count", 0, 0, -1)
floatParam = newParam("freq", 440.0, 0.0, -1.0)
stringParam = newParam("name", "test")
type # ports
PortKind = enum
Bool, Int, Float, String
PortType = concept c
(c is bool or
c is int or
c is float or
c is string)
NumericPort = concept c
c is int or c is float
type # parameters
Parameter[T] = object
name: string
value: T
when T is NumericPort:
minVal, maxVal: T
BoolParam = Parameter[bool]
IntParam = Parameter[int]
FloatParam = Parameter[float]
StringParam = Parameter[string]
proc newParam[T:PortType](name: string, value: T): Parameter[T] =
result = Parameter[T](name:name, value:value)
proc newParam[T:PortType](name: string, value, min, max: T): Parameter[T] =
result = Parameter[T](name:name, value:value, minVal:min, maxVal:max)