Documentation ¶
Index ¶
- Constants
- type IO
- type Ingredient
- type Input
- type Output
- type Resolver
- type Subject
- func (s *Subject) AddStatic(argument string, value interface{}) error
- func (s *Subject) AddVar(argument string, source string, variable string) error
- func (s *Subject) AssignInput(ts types.TupleSpace) error
- func (s *Subject) GetInputByName(name string) (input *Input, err error)
- func (s *Subject) GetOutputByName(name string) (output *Output, err error)
- func (s *Subject) GetSubject() interface{}
- func (s *Subject) NumVariables() int
- func (s *Subject) RebuildSubject(resolver Resolver) error
- func (s *Subject) SetName(name string)
- func (s *Subject) SetResolver(resolver Resolver)
- func (s *Subject) StoreOutput(ts types.TupleSpace) error
- func (s *Subject) String() string
- func (s *Subject) Type() string
- func (s *Subject) Validate() error
Constants ¶
const ( // IngredientVar defines an ingredient type which has a input variable IngredientVar = iota // IngredientStatic defines an ingredient type which has a static value // such as string, int, bool ect. IngredientStatic = iota )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IO ¶
IO is a type which can describe input/output fields
func NewIO ¶
func NewIO(field reflect.StructField, value reflect.Value) IO
NewIO return a new IO type
func (*IO) Compatible ¶
Compatible returns whether or not this output is compatible with another. Two outputs are compatible if they have the same name and the same type
type Ingredient ¶
type Ingredient struct { Type int `json:"type"` Source string `json:"source"` Value interface{} `json:"value"` }
Ingredient describes a variable or static value. If the source is a variable it will be a string representation of which unit the ingredient links to. The frontend will use ingredients to define input for units is json format
func (*Ingredient) IsStatic ¶
func (i *Ingredient) IsStatic() bool
IsStatic returns whether or not the ingredient has static content
func (*Ingredient) IsVariable ¶
func (i *Ingredient) IsVariable() bool
IsVariable returns whether or not the ingredient is a variable representation
func (*Ingredient) Key ¶
func (i *Ingredient) Key() string
Key returns the the storage key for use in a tuple space
func (*Ingredient) Validate ¶
func (i *Ingredient) Validate() error
Validate makes sure the ingredient is valid
type Input ¶
type Input struct { IO Recipe []*Ingredient `json:"recipe"` }
Input describes the type of input and the ingredients used
func NewInput ¶
func NewInput(field reflect.StructField, value reflect.Value) *Input
NewInput returns a new input object from a struct field and value
func (*Input) AddIngredient ¶
func (i *Input) AddIngredient(ingr *Ingredient)
AddIngredient adds an ingredient to the input
func (*Input) CopyRecipe ¶
CopyRecipe assigns the recipe from raw json data
type Resolver ¶
Resolver is an interface for a type which can resolve the subject given its type as a string. The resolver has to know the type of object and resolve that object. This will be used with JSON serialization because only a string representation of the subject type is known at that point
type Subject ¶
type Subject struct { Resolver `json:"-"` Identity string `json:"id"` Name string `json:"name"` In []*Input `json:"input"` Out []*Output `json:"output"` // contains filtered or unexported fields }
Subject is a type which can manipulate and analyze structs
func New ¶
New creates a new subject from a input/output type. The input and output of the type is analysed and can be manipulated through the subject
func (*Subject) AddStatic ¶
AddStatic is a shortcut method for adding an ingredient to the unit which is a static argument
func (*Subject) AddVar ¶
AddVar is a shortcut method for adding an ingredient to the unit which is a variable reference from another unit
func (*Subject) AssignInput ¶
func (s *Subject) AssignInput(ts types.TupleSpace) error
AssignInput finds all ingredients in the state given and assigns it as input
func (*Subject) GetInputByName ¶
GetInputByName returns the input field as a reflected value
func (*Subject) GetOutputByName ¶
GetOutputByName returns the output field as a reflected value
func (*Subject) GetSubject ¶
func (s *Subject) GetSubject() interface{}
GetSubject returns the underlying subject
func (*Subject) NumVariables ¶
NumVariables returns the number of dependencies from other actions
func (*Subject) RebuildSubject ¶
RebuildSubject rebuilds the subject by resolving a new instance of the subject using the subjec resolver. The recipe for every input is copied after the subject has been analysed
func (*Subject) SetResolver ¶
SetResolver sets the resolver used to identify objects
func (*Subject) StoreOutput ¶
func (s *Subject) StoreOutput(ts types.TupleSpace) error
StoreOutput saves the computed output in the state