00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "relExpression.h"
00032
00034 class relPrintExpr : public relObject
00035 {
00036 public:
00037 virtual void
00038 interpret(bddSymTab* pSymTab, ostream* pOut) = 0;
00039 };
00040
00042 class relPrintExprSeq : public relPrintExpr
00043 {
00044 private:
00045 relPrintExpr* mPrintExpr1;
00046 relPrintExpr* mPrintExpr2;
00047
00048 public:
00049 relPrintExprSeq(relPrintExpr* pPrintExpr1, relPrintExpr* pPrintExpr2)
00050 : mPrintExpr1(pPrintExpr1),
00051 mPrintExpr2(pPrintExpr2)
00052 {}
00053
00054 ~relPrintExprSeq()
00055 {
00056 delete mPrintExpr1;
00057 delete mPrintExpr2;
00058 }
00059
00060 virtual void
00061 interpret(bddSymTab* pSymTab, ostream* pOut)
00062 {
00063 mPrintExpr1->interpret(pSymTab, pOut);
00064 mPrintExpr2->interpret(pSymTab, pOut);
00065 }
00066 };
00067
00069 class relPrintExprEndLine : public relPrintExpr
00070 {
00071 private:
00072
00073 public:
00074 relPrintExprEndLine()
00075 {}
00076
00077 ~relPrintExprEndLine()
00078 {}
00079
00080 virtual void
00081 interpret(bddSymTab* pSymTab, ostream* pOut)
00082 {
00083 *pOut << endl;
00084 }
00085 };
00086
00088 class relPrintExprString : public relPrintExpr
00089 {
00090 private:
00091 relStrExpr* mExpr;
00092
00093 public:
00094 relPrintExprString(relStrExpr* pExpr)
00095 : mExpr(pExpr)
00096 {}
00097
00098 ~relPrintExprString()
00099 {
00100 delete mExpr;
00101 }
00102
00103 virtual void
00104 interpret(bddSymTab* pSymTab, ostream* pOut)
00105 {
00106 *pOut << mExpr->interpret(pSymTab).getValue();
00107 pSymTab->removeUserAttributes(gAttributePrefix);
00108 }
00109 };
00110
00112 class relPrintExprInt : public relPrintExpr
00113 {
00114 private:
00115 relNumExpr* mExpr;
00116
00117 public:
00118 relPrintExprInt(relNumExpr* pExpr)
00119 : mExpr(pExpr)
00120 {}
00121
00122 ~relPrintExprInt()
00123 {
00124 delete mExpr;
00125 }
00126
00127 virtual void
00128 interpret(bddSymTab* pSymTab, ostream* pOut)
00129 {
00130 *pOut << mExpr->interpret(pSymTab).getValue();
00131 pSymTab->removeUserAttributes(gAttributePrefix);
00132 }
00133 };
00134
00136 class relPrintExprValues : public relPrintExpr
00137 {
00138 private:
00140 relStrExpr* mPrefix;
00141 relExpression* mExpr;
00142
00143 public:
00144 relPrintExprValues(relStrExpr* pPrefix,
00145 relExpression* pExpr)
00146 : mPrefix(pPrefix),
00147 mExpr(pExpr)
00148 {}
00149
00150 ~relPrintExprValues()
00151 {
00152 delete mPrefix;
00153 delete mExpr;
00154 }
00155
00156 virtual void
00157 interpret(bddSymTab* pSymTab, ostream* pOut)
00158 {
00159 string lPrefix = mPrefix->interpret(pSymTab).getValue();
00160 if (lPrefix.length() != 0) {
00161 lPrefix += '\t';
00162 }
00163 const set<string> lFree = mExpr->collectFreeAttrs();
00164 bddRelation lRel = mExpr->interpret(pSymTab);
00165 map<unsigned,string> lVarOrd = pSymTab->computeVariableOrder(lFree);
00166 vector<string> lAttributeList;
00167 for(map<unsigned, string>::const_iterator lIt = lVarOrd.begin();
00168 lIt != lVarOrd.end();
00169 ++lIt)
00170 {
00171 lAttributeList.push_back(lIt->second);
00172 }
00173 lRel.printRelation(*pOut, lPrefix, lAttributeList );
00174 pSymTab->removeUserAttributes(gAttributePrefix);
00175 }
00176 };
00177
00179 class relPrintExprRelInfo : public relPrintExpr
00180 {
00181 private:
00182 relExpression* mExpr;
00183
00184 public:
00185 relPrintExprRelInfo(relExpression* pExpr)
00186 : mExpr(pExpr)
00187 {}
00188
00189 ~relPrintExprRelInfo()
00190 {
00191 delete mExpr;
00192 }
00193
00194 virtual void
00195 interpret(bddSymTab* pSymTab, ostream* pOut)
00196 {
00197 bddRelation lRel = mExpr->interpret(pSymTab);
00198
00199 *pOut << "------------------------------------------------------" << endl;
00200 *pOut << "Information about the representing data structures." << endl;
00201 *pOut << endl;
00202
00203 const set<string> lFree = mExpr->collectFreeAttrs();
00204 *pOut << "Number of tuples in the relation: "
00205 << lRel.getTupleNr(lFree)
00206 << endl;
00207
00208 *pOut << "Number of values (universe): "
00209 << pSymTab->getUniverseSize() << endl;
00210
00211
00212 lRel.printBddInfo(*pOut);
00213
00214 *pOut << "Attribute order: ";
00215 const map<unsigned,string> lVarOrd = pSymTab->computeVariableOrder(lFree);
00216 for(map<unsigned, string>::const_iterator lIt = lVarOrd.begin();
00217 lIt != lVarOrd.end();
00218 ++lIt)
00219 {
00220 *pOut << lIt->second << " ";
00221 }
00222 *pOut << endl;
00223
00224 *pOut << "------------------------------------------------------" << endl;
00225
00226 pSymTab->removeUserAttributes(gAttributePrefix);
00227 }
00228 };
00229
00231 class relPrintExprNodesPerVarId : public relPrintExpr
00232 {
00233 private:
00234 relExpression* mExpr;
00235
00236 public:
00237 relPrintExprNodesPerVarId(relExpression* pExpr)
00238 : mExpr(pExpr)
00239 {}
00240
00241 ~relPrintExprNodesPerVarId()
00242 {
00243 delete mExpr;
00244 }
00245
00246 virtual void
00247 interpret(bddSymTab* pSymTab, ostream* pOut)
00248 {
00249 const bddRelation lRel = mExpr->interpret(pSymTab);
00250 const set<string> lFree = mExpr->collectFreeAttrs();
00251 lRel.printNodesPerVarId(*pOut, lFree);
00252 pSymTab->removeUserAttributes(gAttributePrefix);
00253 }
00254 };
00255
00257 class relPrintExprGraph : public relPrintExpr
00258 {
00259 private:
00260 relExpression* mExpr;
00261
00262 public:
00263 relPrintExprGraph(relExpression* pExpr)
00264 : mExpr(pExpr)
00265 {}
00266
00267 ~relPrintExprGraph()
00268 {
00269 delete mExpr;
00270 }
00271
00272 virtual void
00273 interpret(bddSymTab* pSymTab, ostream* pOut)
00274 {
00275 const bddRelation lRel = mExpr->interpret(pSymTab);
00276 const set<string> lFree = mExpr->collectFreeAttrs();
00277 lRel.printGraph(*pOut, lFree);
00278 pSymTab->removeUserAttributes(gAttributePrefix);
00279 }
00280 };
00281
00283 class relPrintExprBDT : public relPrintExpr
00284 {
00285 private:
00286 relExpression* mExpr;
00287
00288 public:
00289 relPrintExprBDT(relExpression* pExpr)
00290 : mExpr(pExpr)
00291 {}
00292
00293 ~relPrintExprBDT()
00294 {
00295 delete mExpr;
00296 }
00297
00298 virtual void
00299 interpret(bddSymTab* pSymTab, ostream* pOut)
00300 {
00301 const bddRelation lRel = mExpr->interpret(pSymTab);
00302 lRel.printBDT(*pOut);
00303 pSymTab->removeUserAttributes(gAttributePrefix);
00304 }
00305 };
00306
00307