enum {struct} | R 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
`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'

[Package struct version 1.2.0 Index]