This repository was archived by the owner on Oct 16, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathDomainDecl.cs
More file actions
228 lines (213 loc) · 9.38 KB
/
Copy pathDomainDecl.cs
File metadata and controls
228 lines (213 loc) · 9.38 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
using PDDLSharp.Models.AST;
using PDDLSharp.Models.PDDL.Shared;
using PDDLSharp.Tools;
namespace PDDLSharp.Models.PDDL.Domain
{
public class DomainDecl : BaseListableNode, IDecl
{
public DomainNameDecl? Name { get; set; }
public RequirementsDecl? Requirements { get; set; }
public ExtendsDecl? Extends { get; set; }
public TimelessDecl? Timeless { get; set; }
public TypesDecl? Types { get; set; }
public ConstantsDecl? Constants { get; set; }
public PredicatesDecl? Predicates { get; set; }
public FunctionsDecl? Functions { get; set; }
public List<ActionDecl> Actions { get; set; }
public List<DurativeActionDecl> DurativeActions { get; set; }
public List<AxiomDecl> Axioms { get; set; }
public List<DerivedDecl> Deriveds { get; set; }
public DomainDecl(ASTNode node) : base(node, null)
{
Actions = new List<ActionDecl>();
Axioms = new List<AxiomDecl>();
DurativeActions = new List<DurativeActionDecl>();
Deriveds = new List<DerivedDecl>();
}
public DomainDecl() : base(null)
{
Actions = new List<ActionDecl>();
Axioms = new List<AxiomDecl>();
DurativeActions = new List<DurativeActionDecl>();
Deriveds = new List<DerivedDecl>();
}
public override bool Equals(object? obj)
{
if (obj is DomainDecl other)
{
if (!base.Equals(other)) return false;
if (Name == null && other.Name != null) return false;
if (Name != null && !Name.Equals(other.Name)) return false;
if (Requirements == null && other.Requirements != null) return false;
if (Requirements != null && !Requirements.Equals(other.Requirements)) return false;
if (Extends == null && other.Extends != null) return false;
if (Extends != null && !Extends.Equals(other.Extends)) return false;
if (Timeless == null && other.Timeless != null) return false;
if (Timeless != null && !Timeless.Equals(other.Timeless)) return false;
if (Types == null && other.Types != null) return false;
if (Types != null && !Types.Equals(other.Types)) return false;
if (Constants == null && other.Constants != null) return false;
if (Constants != null && !Constants.Equals(other.Constants)) return false;
if (Predicates == null && other.Predicates != null) return false;
if (Predicates != null && !Predicates.Equals(other.Predicates)) return false;
if (Functions == null && other.Functions != null) return false;
if (Functions != null && !Functions.Equals(other.Functions)) return false;
if (!EqualityHelper.AreListsEqualUnordered(Actions, other.Actions)) return false;
if (!EqualityHelper.AreListsEqualUnordered(DurativeActions, other.DurativeActions)) return false;
if (!EqualityHelper.AreListsEqualUnordered(Axioms, other.Axioms)) return false;
if (!EqualityHelper.AreListsEqualUnordered(Deriveds, other.Deriveds)) return false;
return true;
}
return false;
}
public override int GetHashCode()
{
var hash = base.GetHashCode();
if (Name != null)
hash *= Name.GetHashCode();
if (Requirements != null)
hash *= Requirements.GetHashCode();
if (Extends != null)
hash *= Extends.GetHashCode();
if (Timeless != null)
hash *= Timeless.GetHashCode();
if (Types != null)
hash *= Types.GetHashCode();
if (Constants != null)
hash *= Constants.GetHashCode();
if (Predicates != null)
hash *= Predicates.GetHashCode();
if (Functions != null)
hash *= Functions.GetHashCode();
if (Actions != null)
foreach (var act in Actions)
hash *= act.GetHashCode();
if (DurativeActions != null)
foreach (var act in DurativeActions)
hash *= act.GetHashCode();
if (Axioms != null)
foreach (var axi in Axioms)
hash *= axi.GetHashCode();
if (Deriveds != null)
foreach (var der in Deriveds)
hash *= der.GetHashCode();
return hash;
}
public override IEnumerator<INode> GetEnumerator()
{
if (Name != null)
yield return Name;
if (Requirements != null) yield return Requirements;
if (Extends != null) yield return Extends;
if (Timeless != null) yield return Timeless;
if (Types != null) yield return Types;
if (Constants != null) yield return Constants;
if (Predicates != null) yield return Predicates;
if (Functions != null) yield return Functions;
if (Actions != null)
foreach (var act in Actions)
yield return act;
if (DurativeActions != null)
foreach (var act in DurativeActions)
yield return act;
if (Axioms != null)
foreach (var axi in Axioms)
yield return axi;
if (Deriveds != null)
foreach (var deri in Deriveds)
yield return deri;
}
public override DomainDecl Copy(INode? newParent = null)
{
var newNode = new DomainDecl(new ASTNode(Line, "", ""));
newNode._metaInfo = new List<System.Reflection.PropertyInfo>(_metaInfo);
if (Name != null)
newNode.Name = Name.Copy(newNode);
if (Requirements != null)
newNode.Requirements = Requirements.Copy(newNode);
if (Extends != null)
newNode.Extends = Extends.Copy(newNode);
if (Timeless != null)
newNode.Timeless = Timeless.Copy(newNode);
if (Types != null)
newNode.Types = Types.Copy(newNode);
if (Constants != null)
newNode.Constants = Constants.Copy(newNode);
if (Predicates != null)
newNode.Predicates = Predicates.Copy(newNode);
if (Functions != null)
newNode.Functions = Functions.Copy(newNode);
foreach (var act in Actions)
newNode.Actions.Add(act.Copy(newNode));
foreach (var act in Axioms)
newNode.Axioms.Add(act.Copy(newNode));
foreach (var act in DurativeActions)
newNode.DurativeActions.Add(act.Copy(newNode));
foreach (var act in Deriveds)
newNode.Deriveds.Add(act.Copy(newNode));
newNode.IsHidden = IsHidden;
return newNode;
}
public override void Replace(INode node, INode with)
{
if (Name == node && with is DomainNameDecl name)
Name = name;
if (Requirements == node && with is RequirementsDecl req)
Requirements = req;
if (Extends == node && with is ExtendsDecl ext)
Extends = ext;
if (Timeless == node && with is TimelessDecl time)
Timeless = time;
if (Types == node && with is TypesDecl types)
Types = types;
if (Constants == node && with is ConstantsDecl cons)
Constants = cons;
if (Predicates == node && with is PredicatesDecl preds)
Predicates = preds;
if (Functions == node && with is FunctionsDecl func)
Functions = func;
for (int i = 0; i < Actions.Count; i++)
{
if (Actions[i] == node && with is ActionDecl act)
Actions[i] = act;
}
for (int i = 0; i < DurativeActions.Count; i++)
{
if (DurativeActions[i] == node && with is DurativeActionDecl act)
DurativeActions[i] = act;
}
for (int i = 0; i < Axioms.Count; i++)
{
if (Axioms[i] == node && with is AxiomDecl act)
Axioms[i] = act;
}
for (int i = 0; i < Deriveds.Count; i++)
{
if (Deriveds[i] == node && with is DerivedDecl act)
Deriveds[i] = act;
}
}
public override void Add(INode node)
{
if (node is ActionDecl act)
Actions.Add(act);
else if (node is DurativeActionDecl dact)
DurativeActions.Add(dact);
else if (node is AxiomDecl axi)
Axioms.Add(axi);
else if (node is DerivedDecl der)
Deriveds.Add(der);
}
public override void Remove(INode node)
{
if (node is ActionDecl act)
Actions.Remove(act);
else if (node is DurativeActionDecl dact)
DurativeActions.Remove(dact);
else if (node is AxiomDecl axi)
Axioms.Remove(axi);
else if (node is DerivedDecl der)
Deriveds.Remove(der);
}
}
}