parameter

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

parameter package provides a way to define and manage the parameters of lab devices and their simulated behavior

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValNotFound      = errors.New("value is not found")
	ErrValNotAllowed    = errors.New("value outside opts - ignoring set")
	ErrWrongStringVal   = errors.New("could not convert paramTypeString to string")
	ErrUnknownParamType = errors.New("unknown parameter type")
	ErrWrongIntVal      = errors.New("received param type that cannot be converted to int")
	ErrWrongFloatVal    = errors.New("received param type that cannot be converted to float")
	ErrWrongBoolVal     = errors.New("received param type that cannot be converted to bool")
	ErrWrongTypeVal     = errors.New("received value with invalid type")
	ErrUnhandledTypeVal = errors.New("unhandled type")
)

Functions

This section is empty.

Types

type ConcreteParameter

type ConcreteParameter[T paramType] struct {
	Parameter
	// contains filtered or unexported fields
}

ConcreteParameter[T paramType] hold the actual concrete value for each parameter created with New constructor.

func (*ConcreteParameter[T]) Opts

func (p *ConcreteParameter[T]) Opts() []string

Return allowed values if available

func (*ConcreteParameter[T]) SetValue

func (p *ConcreteParameter[T]) SetValue(val any) error

Value setter

func (*ConcreteParameter[T]) String

func (p *ConcreteParameter[T]) String() string

To String representation

func (*ConcreteParameter[T]) Type

func (p *ConcreteParameter[T]) Type() reflect.Kind

Type getter

func (*ConcreteParameter[T]) Value

func (p *ConcreteParameter[T]) Value() any

Value getter

type Parameter

type Parameter interface {
	SetValue(any) error
	Value() any
	String() string
	Opts() []string
}

Parameter interface is responsible for wrapping ConcreteParameter struct, exposing all methods required.

func New

func New(val any, opt, typ string) (Parameter, error)

Parameter constructor, the constructor will automatically create the ConcreteParameter instance base on the value passed on in the params

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL