-
Notifications
You must be signed in to change notification settings - Fork 1
/
Binding.ts
114 lines (96 loc) · 3.35 KB
/
Binding.ts
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
/*
* This file is part of Interacto.
* Interacto is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Interacto is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Interacto. If not, see <https://www.gnu.org/licenses/>.
*/
import type {VisitorBinding} from "./VisitorBinding";
import type {RuleName, Severity} from "../checker/Checker";
import type {Command} from "../command/Command";
import type {Interaction, InteractionDataType} from "../interaction/Interaction";
import type {InteractionData} from "../interaction/InteractionData";
import type {Observable} from "rxjs";
/**
* The concept of binding and its related services.
* @typeParam C - The type of the command that will produce this binding.
* @typeParam I - The type of the interaction that will use this binding.
* @typeParam A - The type of the accumulator.
* @typeParam D - The interaction data type (infered from the interaction type)
* @category API Binding
*/
export interface Binding<C extends Command, I extends Interaction<D>, A, D extends InteractionData = InteractionDataType<I>> {
/**
* The name of the binding
*/
readonly name: string;
/**
* Logs (or not) usage information of the binding for usage analysis
*/
logUsage: boolean;
/**
* Logs (or not) binding execution information.
*/
logBinding: boolean;
/**
* Logs (or not) command production information
*/
logCmd: boolean;
/**
* The accumulator used during the binding.
*/
readonly accumulator: A;
/**
* The user interaction.
*/
readonly interaction: I;
/**
* The command in progress or null.
*/
readonly command: C | undefined;
/**
* The linter rules specific to this binding.
*/
readonly linterRules: ReadonlyMap<RuleName, Severity>;
/**
* States whether the binding is activated.
*/
activated: boolean;
/**
* States whether the binding is running.
*/
readonly running: boolean;
/**
* States whether the command must be executed on each step of the interaction (and not only at the
* end of the interaction execution).
*/
readonly continuousCmdExecution: boolean;
/**
* Information method.
* @returns The number of times the binding successfully ended (nevermind a command was created or not).
*/
readonly timesEnded: number;
/**
* Information method.
* The number of times the binding was cancelled (nevermind a command was created or not).
*/
readonly timesCancelled: number;
/** An RX observable objects that will provide the commands produced by the binding. */
readonly produces: Observable<C>;
/**
* Does this binding has a 'when' predicate defined?
*/
isWhenDefined(): boolean;
uninstallBinding(): void;
/**
* Visiting the binding.
* @param visitor - The visitor.
*/
acceptVisitor(visitor: VisitorBinding): void;
}