enum: Enum objects

View source: R/enum_class.R

enumR Documentation

Enum objects

Description

A base class in the struct package. Not normally called directly.

Usage

enum(
  name,
  description = character(0),
  type = "character",
  value = character(0),
  max_length = 1,
  allowed,
  ...
)

## S4 replacement method for signature 'enum'
value(obj) <- value

Arguments

name

the name of the object

description

a description of the object

type

the type of the struct object

value

value of the enum

max_length

Maximum length of value vector (default 1)

allowed

A list of allowed values

...

additional inputs to the struct_class object

obj

an enum object

Details

An enum object is a special type of entity object that ensures the value must be one from a list of allowed values.

Enum objects are usually defined in the prototype of another object, but can be extracted using param_obj and output_obj.

Value

an enum object

Examples

# Create a new enum object
E = enum(
    name = 'example',
    description = 'this is an example',
    type = 'character',
    value = 'hello',
    allowed = c('hello','world')
)

# Get/set the value of the entity object
value(E)
value(E) = 'world'

computational-metabolomics/struct documentation built on March 27, 2024, 4:26 p.m.