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 package zeus.actors;
29
30 import java.util.*;
31 import zeus.util.*;
32 import zeus.concepts.*;
33
34 /***
35 * The Plan Database is a simple storage component that holds the plan
36 * descriptions known by the owning agent. This information is used by
37 * the agent's {@link Planner} component.
38 */
39
40 public class PlanDb extends Hashtable {
41
42 public void add(PlanRecord rec) {
43 Assert.notNull(rec);
44 Core.DEBUG(3,"Adding " + rec);
45 Goal goal = rec.getGoal();
46 String goalId = goal.getId();
47 Object obj = this.put(goalId,rec);
48 Core.ERROR(obj == null,1,this);
49 }
50
51 public void del(PlanRecord rec) {
52 Assert.notNull(rec);
53 Goal goal = rec.getGoal();
54 String goalId = goal.getId();
55
56 PlanRecord rec1 = (PlanRecord) this.remove(goalId);
57 Assert.notFalse( rec1 == rec );
58 }
59
60 public void del(Vector List) {
61 for( int i = 0; i < List.size(); i++ )
62 this.del((PlanRecord) List.elementAt(i) );
63 }
64
65 public void add(Vector List) {
66 for( int i = 0; i < List.size(); i++ )
67 this.add((PlanRecord) List.elementAt(i) );
68 }
69
70 public PlanRecord lookUp(Goal goal) {
71 return (PlanRecord)this.get(goal.getId());
72 }
73
74 public PlanRecord lookUp(String goalId) {
75 return (PlanRecord)this.get(goalId);
76 }
77 public boolean containsRecord(PlanRecord rec) {
78 return this.get(rec.getGoal().getId()) != null;
79 }
80 }