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 "dependencytuple.h" 00036 00037 DependencyTuple::DependencyTuple(PathExpression * _path, bool _cond): 00038 path(_path), cond(_cond), role(NULL) { 00039 } 00040 00041 DependencyTuple::~DependencyTuple() { 00042 delete path; 00043 } 00044 00045 void DependencyTuple::print(OutputStream & dos) { 00046 dos << "<"; 00047 if (path) { 00048 dos << *(path); 00049 } 00050 if (role) { 00051 dos << ",r" << role->getId(); 00052 } 00053 dos << ">"; 00054 } 00055 00056 bool DependencyTuple::isPosTuple() { 00057 if (path && path->getTailPathStep()->hasAttribute()) { 00058 return path->getTailPathStep()->getAttribute()->getType() == 00059 at_position; 00060 } 00061 00062 return false; 00063 } 00064 00065 bool DependencyTuple::isDosTuple() { 00066 if (path) { 00067 return path->getTailPathStep()->isDosNodeStep(); 00068 } 00069 00070 return false; 00071 } 00072 00073 bool DependencyTuple::isSyntacticallyEqualTo(DependencyTuple * tuple) { 00074 if (path == NULL) { 00075 return tuple->getPath() == NULL; 00076 } else { 00077 if ((path == NULL && tuple->getPath()) 00078 || (path && tuple->getPath() == NULL)) { 00079 return false; 00080 } else { 00081 return (!(isPosTuple() ^ tuple->isPosTuple()) 00082 && !(isDosTuple() ^ tuple->isDosTuple()) 00083 && path->isSyntacticallyEqualTo(tuple->getPath())); 00084 } 00085 } 00086 } 00087 00088 bool DependencyTuple::isSemanticallyContainedIn(DependencyTuple * tuple) { 00089 if (path == NULL) { 00090 return tuple->getPath() == NULL; 00091 } else { 00092 return !path->mightHasChildDescendantConflict(tuple->getPath()) && 00093 path->isSemanticallyContainedIn(tuple->getPath()); 00094 } 00095 } 00096 00097 void DependencyTuple::registerToPassiveProjectionTree(unsigned var, 00098 PassiveProjectionTree * 00099 ppt) { 00100 PathExpression *rpath = ppt->getPathEnv()->getPath(var)->clone(); 00101 00102 if (path) { 00103 for (unsigned i = 0; i < path->getPathSize(); i++) { 00104 rpath->addPathStep(path->getPathStepAt(i)->clone()); 00105 } 00106 } 00107 ppt->registerPath(rpath); 00108 delete rpath; 00109 }