annotate Implab/Automaton/AutomatonTransition.cs @ 209:a867536c68fc v2

Bound promise to CancellationToken Added new states to ExecutionSate enum. Added Safe.Guard() method to handle cleanup of the result of the promise
author cin
date Wed, 16 Nov 2016 03:06:08 +0300
parents 8200ab154c8a
children d6fe09f5592c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
162
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
1 using System;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
2
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
3 namespace Implab.Automaton {
166
cin
parents: 162
diff changeset
4 public struct AutomatonTransition : IEquatable<AutomatonTransition> {
162
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
5 public readonly int s1;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
6 public readonly int s2;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
7 public readonly int edge;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
8
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
9 public AutomatonTransition(int s1, int s2, int edge) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
10 this.s1 = s1;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
11 this.s2 = s2;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
12 this.edge = edge;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
13 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
14
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
15
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
16 #region IEquatable implementation
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
17 public bool Equals(AutomatonTransition other) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
18 return other.s1 == s1 && other.s2 == s2 && other.edge == edge ;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
19 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
20 #endregion
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
21
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
22 public override bool Equals(object obj) {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
23 if (obj is AutomatonTransition)
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
24 return Equals((AutomatonTransition)obj);
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
25 return base.Equals(obj);
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
26 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
27
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
28 public override int GetHashCode() {
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
29 return s1 + s2 + edge;
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
30 }
205
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 166
diff changeset
31
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 166
diff changeset
32 public static bool operator == (AutomatonTransition rv, AutomatonTransition lv) {
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 166
diff changeset
33 return rv.Equals(lv);
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 166
diff changeset
34 }
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 166
diff changeset
35
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 166
diff changeset
36 public static bool operator !=(AutomatonTransition rv, AutomatonTransition lv) {
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 166
diff changeset
37 return rv.Equals(lv);
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 166
diff changeset
38 }
162
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
39 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
40 }
0526412bbb26 DFA refactoring
cin
parents:
diff changeset
41