1
2
3
4 package net.sf.bddbddb.ir.highlevel;
5
6 import java.util.List;
7 import jwutil.collections.Pair;
8 import net.sf.bddbddb.Relation;
9 import net.sf.javabdd.BDDFactory.BDDOp;
10
11 /***
12 * BooleanOperation
13 *
14 * @author jwhaley
15 * @version $Id: BooleanOperation.java 328 2004-10-16 02:45:30Z joewhaley $
16 */
17 public abstract class BooleanOperation extends HighLevelOperation {
18 Relation r0, r1, r2;
19
20 /***
21 * @param r0
22 * @param r1
23 * @param r2
24 */
25 public BooleanOperation(Relation r0, Relation r1, Relation r2) {
26 super();
27 this.r0 = r0;
28 this.r1 = r1;
29 this.r2 = r2;
30 }
31
32 /***
33 * @return the name of this operation
34 */
35 public abstract String getName();
36
37
38
39
40
41
42 public String toString() {
43 return r0.toString() + " = " + getExpressionString();
44 }
45
46
47
48
49
50
51 public String getExpressionString() {
52 return getName() + "(" + r1.toString() + "," + r2.toString() + ")";
53 }
54
55
56
57
58
59
60 public Relation getRelationDest() {
61 return r0;
62 }
63
64
65
66
67
68
69 public List getSrcs() {
70 return new Pair(r1, r2);
71 }
72
73 /***
74 * @return Returns the source relation.
75 */
76 public Relation getSrc1() {
77 return r1;
78 }
79
80 /***
81 * @return Returns the source relation.
82 */
83 public Relation getSrc2() {
84 return r2;
85 }
86
87 /***
88 * @return the BDDOp for this operation
89 */
90 public abstract BDDOp getBDDOp();
91
92
93
94
95
96
97
98 public void replaceSrc(Relation r_old, Relation r_new) {
99 if (r1 == r_old) r1 = r_new;
100 if (r2 == r_old) r2 = r_new;
101 }
102
103
104
105
106
107
108 public void setRelationDest(Relation r0) {
109 this.r0 = r0;
110 }
111 }