-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgospace.go
130 lines (99 loc) · 3.99 KB
/
gospace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package gospace
import (
"github.com/pspaces/gospace/container"
"github.com/pspaces/gospace/policy"
"github.com/pspaces/gospace/space"
)
// Intertuple is an interface for interacting with a tuple.
type Intertuple = container.Intertuple
// Intertemplate is an interface for interacting with a template.
type Intertemplate = container.Intertemplate
// Space defines a multi-set for tuples.
type Space = space.Space
// Tuple defines a tuple structure.
type Tuple = container.Tuple
// Template defines a template used for pattern matching.
type Template = container.Template
// Label describes a label given some entity.
type Label = container.Label
// Labels defines a set of labels.
type Labels = container.Labels
// LabelledTuple represents a labelled tuple.
type LabelledTuple = container.LabelledTuple
// Action encapsulates an operation with its parameters.
type Action = policy.Action
// AggregationRule defines an aggregation rule.
type AggregationRule = policy.AggregationRule
// AggregationPolicy defines an aggregation policy.
type AggregationPolicy = policy.Aggregation
// ComposablePolicy defines a composable policy.
type ComposablePolicy = policy.Composable
// Transformation defines a transformation.
type Transformation = policy.Transformation
// Transformations defines a transformations applied to an action.
type Transformations = policy.Transformations
// NewSpace creates a structure that represents a space.
func NewSpace(name string, policy ...*ComposablePolicy) Space {
return space.NewSpace(name, policy...)
}
// NewRemoteSpace creates a structure that represents a remote space.
func NewRemoteSpace(name string) Space {
return space.NewRemoteSpace(name)
}
// SpaceFrame contains all interfaces that can operate on a space.
type SpaceFrame interface {
space.Interspace
space.Interstar
}
// CreateTuple creates a structure that represents a tuple.
func CreateTuple(fields ...interface{}) Tuple {
return container.NewTuple(fields...)
}
// TupleFrame contains all interfaces that can operate on a tuple.
type TupleFrame interface {
Intertuple
}
// CreateTemplate creates a structure that represents a template.
func CreateTemplate(fields ...interface{}) Template {
return container.NewTemplate(fields...)
}
// TemplateFrame contains all interfaces that can operate on a template.
type TemplateFrame interface {
Intertemplate
}
// NewLabel creates a structure that represents a label.
func NewLabel(id string) Label {
return container.NewLabel(id)
}
// NewLabels creates a structure that represents a collection of labels.
func NewLabels(ll ...Label) Labels {
return container.NewLabels(ll...)
}
// NewLabelledTuple creates a structure that represents a labelled tuple.
func NewLabelledTuple(fields ...interface{}) LabelledTuple {
return container.NewLabelledTuple(fields...)
}
// NewAction creates a structure that represents an action.
func NewAction(function interface{}, params ...interface{}) *Action {
return policy.NewAction(function, params...)
}
// NewAggregationRule creates a structure that represents an aggregation rule.
func NewAggregationRule(a Action, trs Transformations) AggregationRule {
return policy.NewAggregationRule(a, trs)
}
// NewAggregationPolicy creates a structure that represents an aggregation policy.
func NewAggregationPolicy(l Label, r AggregationRule) AggregationPolicy {
return policy.NewAggregation(l, r)
}
// NewComposablePolicy creates a structure that represents a composable policy.
func NewComposablePolicy(ars ...AggregationPolicy) *ComposablePolicy {
return policy.NewComposable(ars...)
}
// NewTransformation creates a structure for representing a transformation that can be applied to an action.
func NewTransformation(function interface{}, params ...interface{}) Transformation {
return policy.NewTransformation(function, params...)
}
// NewTransformations creates a structure for representing collection of transformation that can be applied to an action.
func NewTransformations(trs ...*Transformation) *Transformations {
return policy.NewTransformations(trs...)
}