Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
BinaryOperatorPattern .cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
5
7{
11 public abstract class BinaryOperatorPattern : ISparqlPattern
12 {
13 private readonly ISparqlPattern left;
14 private readonly ISparqlPattern right;
15
22 {
23 this.left = Left;
24 this.right = Right;
25 }
26
30 public ISparqlPattern Left => this.left;
31
35 public ISparqlPattern Right => this.right;
36
40 public bool IsEmpty => false;
41
49 public bool ForAll(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
50 {
51 if (!this.left.ForAll(Callback, State, Order))
52 return false;
53
54 if (!this.right.ForAll(Callback, State, Order))
55 return false;
56
57 return true;
58 }
59
67 public bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
68 {
69 if (!this.left.ForAllChildNodes(Callback, State, Order))
70 return false;
71
72 if (!this.right.ForAllChildNodes(Callback, State, Order))
73 return false;
74
75 return true;
76 }
77
86 public abstract Task<IEnumerable<Possibility>> Search(ISemanticCube Cube, Variables Variables,
87 IEnumerable<Possibility> ExistingMatches, SparqlQuery Query);
88
93 public void SetParent(ScriptNode Parent)
94 {
95 this.left.SetParent(Parent);
96 this.right.SetParent(Parent);
97 }
98
100 public override bool Equals(object obj)
101 {
102 if (!(obj is BinaryOperatorPattern Typed) ||
103 this.GetType() != obj.GetType())
104 {
105 return false;
106 }
107
108 return this.left.Equals(Typed.left) &&
109 this.right.Equals(Typed.right);
110 }
111
113 public override int GetHashCode()
114 {
115 int Result = this.GetType().GetHashCode();
116 Result ^= Result << 5 ^ this.left.GetHashCode();
117 Result ^= Result << 5 ^ this.right.GetHashCode();
118
119 return Result;
120 }
121 }
122}
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
abstract Task< IEnumerable< Possibility > > Search(ISemanticCube Cube, Variables Variables, IEnumerable< Possibility > ExistingMatches, SparqlQuery Query)
Searches for the pattern on information in a semantic cube.
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed.
bool ForAll(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
BinaryOperatorPattern(ISparqlPattern Left, ISparqlPattern Right)
Intersection of two patterns.
bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
Collection of variables.
Definition: Variables.cs:25
Interface for semantic cubes.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
SearchMethod
Method to traverse the expression structure
Definition: ScriptNode.cs:38