memory

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package memory implements GoAbU logical resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResourceController

type ResourceController interface {
	// Start shall be called as soon as the node is ready to process inputs from the environment.
	Start() error
	// Inputs returns a channel providing the inputs received from the environment as strings of the form "<resource_name> = <value>,".
	Inputs() <-chan string
	// Errors returns a channel handing the errors that occurs during operation.
	Errors() <-chan error
	// Modified shall be called when the resource with the given identifier is set to a different value.
	Modified(string)
	// Extract returns a shallow copy of only the resources specified by the provided identifiers.
	Extract([]string) Resources
	// Enclose adds the provided resources to the ResourceController, overwriting previous values if present.
	Enclose(Resources)
	// HasDuplicates verifies if the ResourceController has multiple resources sharing the same identifier.
	HasDuplicates() bool
	// Has checks if the ResourceController contains a resource identified by the provided string.
	Has(string) bool
	// Types returns a map with an entry for each resource specifying its type (one of the following: "Bool", "Integer", "Float", "Text", "Time", "Other").
	// Prerequisite: !HasDuplicates()
	Types() map[string]string
	// GetResources provides access to the resources.
	GetResources() Resources
	// ResourceNames returns the list of all the managed resources' identifiers (without repeated elements).
	ResourceNames() []string
	// String returns a string representation of the ResourceController for debugging purposes.
	String() string
	// Copy returns a shallow copy of the ResourceController.
	Copy() ResourceController
}

ResourceController is the interface modeling an AbU node's state and its interaction with the environment.

type Resources

type Resources struct {
	Bool    map[string]bool
	Integer map[string]int64
	Float   map[string]float64
	Text    map[string]string
	Time    map[string]time.Time
	Other   map[string]interface{}
}

Resources is a struct implementing the ResourceController interface modeling the state of a node that has no sensors nor actuators.

func MakeResources

func MakeResources() Resources

MakeResources returns a new empty Resources struct.

func (Resources) Copy

func (r Resources) Copy() ResourceController

Copy returns a shallow copy of the struct.

func (Resources) Enclose

func (r Resources) Enclose(i Resources)

Enclose adds the provided resources to the ResourceController, overwriting previous values if present.

func (Resources) Errors

func (r Resources) Errors() <-chan error

Errors returns nil.

func (Resources) Extract

func (r Resources) Extract(resources []string) Resources

Extract returns a shallow copy of only the resources specified by the provided identifiers.

func (Resources) GetResources

func (r Resources) GetResources() Resources

GetResources returns the Resources struct itself.

func (Resources) Has

func (r Resources) Has(resource string) bool

Has checks if there is a resource identified by the provided string.

func (Resources) HasDuplicates

func (r Resources) HasDuplicates() bool

HasDuplicates verifies if there are multiple resources sharing the same identifier.

func (Resources) Inputs

func (r Resources) Inputs() <-chan string

Inputs returns nil.

func (Resources) Modified

func (r Resources) Modified(resource string)

Modified is a no-op.

func (Resources) ResourceNames

func (r Resources) ResourceNames() []string

ResourceNames returns the list of all the contained resources' identifiers (without repeated elements).

func (Resources) Start

func (r Resources) Start() error

Start is a no-op.

func (Resources) String

func (r Resources) String() string

String returns a string representation of the struct for debugging purposes.

func (Resources) Types

func (r Resources) Types() map[string]string

Types returns a map with an entry for each resource specifying its type (one of the following: "Bool", "Integer", "Float", "Text", "Time", "Other").

Prerequisite: !HasDuplicates()

Jump to

Keyboard shortcuts

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