00001 00002 /* 00003 | Author: Michael Schmidt; 00004 | Gunnar Jehl 00005 | 00006 | ************************* SOFTWARE LICENSE AGREEMENT *********************** 00007 | This source code is published under the BSD License. 00008 | 00009 | See file 'LICENSE.txt' that comes with this distribution or 00010 | http://dbis.informatik.uni-freiburg.de/index.php?project=GCX/license.php 00011 | for the full license agreement. 00012 | 00013 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00014 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00015 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00016 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00017 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00018 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00019 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00020 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00021 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00022 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00023 | POSSIBILITY OF SUCH DAMAGE. 00024 | **************************************************************************** 00025 */ 00026 00035 #include "parvarmap.h" 00036 00037 ParVarMap *ParVarMap::instance = NULL; 00038 00039 ParVarMap *ParVarMap::getInstance() { 00040 if (instance == NULL) { 00041 instance = new ParVarMap(); 00042 } 00043 00044 return instance; 00045 } 00046 00047 ParVarMap::ParVarMap() { 00048 parvarmap[TAGID_ROOT] = pair < unsigned, 00049 PathExpression * >(TAGID_ROOT, NULL); 00050 00051 varsq.push_back(TAGID_ROOT); 00052 direct_output.push_back(false); 00053 } 00054 00055 ParVarMap::~ParVarMap() { 00056 } 00057 00058 void ParVarMap::insertParVar(unsigned var, unsigned parvar, 00059 PathExpression * path, bool _direct_output) { 00060 parvarmap[var] = pair < unsigned, 00061 PathExpression * >(parvar, path); 00062 00063 varsq.push_back(var); 00064 direct_output.push_back(_direct_output); 00065 } 00066 00067 void ParVarMap::print(OutputStream & dos) { 00068 VarVarPathMap::iterator it; 00069 PathExpression *path; 00070 00071 for (it = parvarmap.begin(); it != parvarmap.end(); it++) { 00072 if (it == parvarmap.begin() && it->second.first == TAGID_ROOT) { 00073 dos << "undefined"; 00074 } else { 00075 dos << "$" << VarName::getInstance()->getVarname(it->second.first); 00076 } 00077 path = it->second.second; 00078 dos << " => "; 00079 if (path) { 00080 dos << *(path); 00081 } else { 00082 dos << "%"; 00083 } 00084 dos << NEWLINE; 00085 } 00086 } 00087 00088 unsigned ParVarMap::getParVar(unsigned var) { 00089 VarVarPathMap::iterator it; 00090 00091 it = parvarmap.find(var); 00092 return it->second.first; 00093 } 00094 00095 PathExpression *ParVarMap::getPath(unsigned var) { 00096 VarVarPathMap::iterator it; 00097 00098 it = parvarmap.find(var); 00099 return it->second.second; 00100 }