This repository was archived by the owner on Oct 16, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathActionDecl.cs
More file actions
111 lines (99 loc) · 3.97 KB
/
Copy pathActionDecl.cs
File metadata and controls
111 lines (99 loc) · 3.97 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
using PDDLSharp.Models.AST;
using PDDLSharp.Models.PDDL.Expressions;
namespace PDDLSharp.Models.PDDL.Domain
{
public class ActionDecl : BaseNamedWalkableNode, IDecl, IParametized
{
public ParameterExp Parameters { get; set; }
public IExp Preconditions { get; set; }
public IExp Effects { get; set; }
public ActionDecl(ASTNode node, INode? parent, string name, ParameterExp parameters, IExp preconditions, IExp effects) : base(node, parent, name)
{
Parameters = parameters;
Preconditions = preconditions;
Effects = effects;
}
public ActionDecl(INode? parent, string name, ParameterExp parameters, IExp preconditions, IExp effects) : base(parent, name)
{
Parameters = parameters;
Preconditions = preconditions;
Effects = effects;
}
public ActionDecl(string name, ParameterExp parameters, IExp preconditions, IExp effects) : base(name)
{
Parameters = parameters;
Preconditions = preconditions;
Effects = effects;
}
public ActionDecl(ASTNode node, INode? parent, string name) : base(node, parent, name)
{
Parameters = new ParameterExp(this, new List<NameExp>());
Preconditions = new AndExp(this, new List<IExp>());
Effects = new AndExp(this, new List<IExp>());
}
public ActionDecl(INode? parent, string name) : base(parent, name)
{
Parameters = new ParameterExp(this, new List<NameExp>());
Preconditions = new AndExp(this, new List<IExp>());
Effects = new AndExp(this, new List<IExp>());
}
public ActionDecl(string name) : base(name)
{
Parameters = new ParameterExp(this, new List<NameExp>());
Preconditions = new AndExp(this, new List<IExp>());
Effects = new AndExp(this, new List<IExp>());
}
public override bool Equals(object? obj)
{
if (obj is ActionDecl other)
{
if (!base.Equals(other)) return false;
if (!Parameters.Equals(other.Parameters)) return false;
if (!Preconditions.Equals(other.Preconditions)) return false;
if (!Effects.Equals(other.Effects)) return false;
return true;
}
return false;
}
public override int GetHashCode()
{
var hash = base.GetHashCode();
hash ^= Parameters.GetHashCode();
hash ^= Preconditions.GetHashCode();
hash ^= Effects.GetHashCode();
return hash;
}
public override IEnumerator<INode> GetEnumerator()
{
yield return Parameters;
yield return Preconditions;
yield return Effects;
}
public override ActionDecl Copy(INode? newParent = null)
{
var newNode = new ActionDecl(new ASTNode(Line, "", ""), newParent, Name);
newNode._metaInfo = new List<System.Reflection.PropertyInfo>(_metaInfo);
var newParams = Parameters.Copy(newNode);
var newPreconditions = ((dynamic)Preconditions).Copy(newNode);
var newEffects = ((dynamic)Effects).Copy(newNode);
newNode.Parameters = newParams;
newNode.Preconditions = newPreconditions;
newNode.Effects = newEffects;
newNode.IsHidden = IsHidden;
return newNode;
}
public override void Replace(INode node, INode with)
{
if (Parameters == node && with is ParameterExp param)
Parameters = param;
if (Preconditions == node && with is IExp exp1)
Preconditions = exp1;
if (Effects == node && with is IExp exp2)
Effects = exp2;
}
public override string ToString()
{
return Name + Parameters.ToString();
}
}
}