Documentation
¶
Overview ¶
Package memory implements GoAbU logical resources.
Index ¶
- type ResourceController
- type Resources
- func (r Resources) Copy() ResourceController
- func (r Resources) Enclose(i Resources)
- func (r Resources) Errors() <-chan error
- func (r Resources) Extract(resources []string) Resources
- func (r Resources) GetResources() Resources
- func (r Resources) Has(resource string) bool
- func (r Resources) HasDuplicates() bool
- func (r Resources) Inputs() <-chan string
- func (r Resources) Modified(resource string)
- func (r Resources) ResourceNames() []string
- func (r Resources) Start() error
- func (r Resources) String() string
- func (r Resources) Types() map[string]string
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 ¶
Enclose adds the provided resources to the ResourceController, overwriting previous values if present.
func (Resources) Extract ¶
Extract returns a shallow copy of only the resources specified by the provided identifiers.
func (Resources) GetResources ¶
GetResources returns the Resources struct itself.
func (Resources) HasDuplicates ¶
HasDuplicates verifies if there are multiple resources sharing the same identifier.
func (Resources) ResourceNames ¶
ResourceNames returns the list of all the contained resources' identifiers (without repeated elements).