src/necsus/runtime/systemVar

Types

Local[T] = distinct ptr SystemVarData[T]
Wrapper around data that is specific to a single system
LocalOrT[T] = Local[T] | T
A local value or the value itself
Shared[T] = distinct ptr SystemVarData[T]
Wrapper around data that is shared across all systems
SharedOrT[T] = Shared[T] | T
A shared value or the value itself
SystemVar[T] = Shared[T] | Local[T]
SystemVarData[T] = object
A system variable

Procs

proc `$`[T](sysvar: SystemVar[T]): string
proc `:=`[T](sysvar: SystemVar[T]; value: sink T) {.inline.}
Sets the value in a system variable
proc `==`[T](sysvar: SystemVar[T]; value: T): bool {.inline.}
Returns whether a sysvar is set and equals the given value
proc clear[T](sysvar: SystemVar[T]) {.inline.}
Unsets the value in a system variable
proc get[T](sysvar: SystemVar[T]): T {.inline.}
Returns the value in a system variable
proc get[T](sysvar: SystemVar[T]; default: T): T {.inline.}
Returns the value in a system variable
proc getOrPut[T](sysvar: SystemVar[T]): var T
Returns the value in a system variable
proc getOrRaise[T](sysvar: SystemVar[T]): var T {.inline.}
Returns the value in a system variable
proc isEmpty[T](sysvar: SystemVar[T]): bool {.inline.}
Returns whether a system variable has a value
proc isSome[T](sysvar: SystemVar[T]): bool {.inline.}
Returns whether a system variable has a value
proc set[T](sysvar: SystemVar[T]; value: sink T) {.inline.}
Sets the value in a system variable
proc unwrap[T](sysvar: SharedOrT[T] | LocalOrT[T]): T {.inline.}
Pulls a value out of a SystemVar or raises
proc unwrap[T](sysvar: SharedOrT[T] | LocalOrT[T]; otherwise: T): T {.inline.}
Pulls a value out of a SystemVar or raises

Iterators

iterator items[T](sysvar: SystemVar[T]): lent T
iterator items[T](sysvar: var SystemVar[T]): var T

Templates

template `from`[T](variable: untyped; source: SystemVar[T]): bool
Reads a value from a SystemVar, assigning it to a value and returning true if it exists. This allows you to check for the presence of a value and assign it to a variable in one step
template getOrPut[T](sysvar: SystemVar[T]; build: typed): var T
Returns the value in a system variable