00001 /* 00002 * CrocoPat is a tool for relational programming. 00003 * This file is part of CrocoPat. 00004 * 00005 * Copyright (C) 2002-2008 Dirk Beyer 00006 * 00007 * CrocoPat is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License 00009 * as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * CrocoPat is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with CrocoPat; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * Please find the GNU Lesser General Public License in file 00022 * License_LGPL.txt or at http://www.gnu.org/licenses/lgpl.txt 00023 * 00024 * Author: 00025 * Dirk Beyer (firstname.lastname@sfu.ca) 00026 * Simon Fraser University 00027 * 00028 * With contributions of: Andreas Noack, Michael Vogel 00029 */ 00030 00031 #ifndef _relTerm_h 00032 #define _relTerm_h 00033 00034 #include "relStrExpr.h" 00035 00037 class relTerm : public relObject 00038 { 00039 public: 00040 virtual string 00041 interpret(bddSymTab* pSymTab) = 0; 00042 }; 00043 00044 00046 class relTermAttribute : public relTerm 00047 { 00048 private: 00049 string* mAttribute; 00050 00051 public: 00052 relTermAttribute(string* pAttribute) 00053 : mAttribute(pAttribute) 00054 {} 00055 00056 ~relTermAttribute() 00057 { 00058 delete mAttribute; 00059 } 00060 00061 virtual string 00062 interpret(bddSymTab* pSymTab) 00063 { 00064 if (pSymTab->getUniverseSize() == 0) { 00065 cerr << "Error: No values available (empty universe)." << endl; 00066 exit(EXIT_FAILURE); 00067 } 00068 return *mAttribute; 00069 } 00070 }; 00071 00073 class relTermStrExpr : public relTerm 00074 { 00075 private: 00076 relStrExpr* mExpr; 00077 00078 public: 00079 relTermStrExpr(relStrExpr* pExpr) 00080 : mExpr(pExpr) 00081 {} 00082 00083 ~relTermStrExpr() 00084 { 00085 delete mExpr; 00086 } 00087 00088 virtual string 00089 interpret(bddSymTab* pSymTab) 00090 { 00091 return mExpr->interpret(pSymTab).getValue(); 00092 } 00093 }; 00094 00096 class relTermExists : public relTerm 00097 { 00098 private: 00099 00100 public: 00101 relTermExists() 00102 {} 00103 00104 ~relTermExists() 00105 {} 00106 00107 virtual string 00108 interpret(bddSymTab* pSymTab) 00109 { 00110 if (pSymTab->getUniverseSize() == 0) { 00111 cerr << "Error: No values available (empty universe)." << endl; 00112 exit(EXIT_FAILURE); 00113 } 00114 return ""; 00115 } 00116 }; 00117 00118 #endif 00119
1.5.1