Generated on Mon May 10 06:46:31 2010 for Gecode by doxygen 1.6.3

visualnode.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2006
00008  *
00009  *  Last modified:
00010  *     $Date: 2010-03-30 15:49:32 +0200 (Tue, 30 Mar 2010) $ by $Author: tack $
00011  *     $Revision: 10604 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  * Permission is hereby granted, free of charge, to any person obtaining
00018  * a copy of this software and associated documentation files (the
00019  * "Software"), to deal in the Software without restriction, including
00020  * without limitation the rights to use, copy, modify, merge, publish,
00021  * distribute, sublicense, and/or sell copies of the Software, and to
00022  * permit persons to whom the Software is furnished to do so, subject to
00023  * the following conditions:
00024  *
00025  * The above copyright notice and this permission notice shall be
00026  * included in all copies or substantial portions of the Software.
00027  *
00028  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode { namespace Gist {
00039 
00040   forceinline
00041   Extent::Extent(void) : l(-1), r(-1) {}
00042 
00043   forceinline
00044   Extent::Extent(int l0, int r0) : l(l0), r(r0) {}
00045 
00046   inline
00047   Extent::Extent(int width) {
00048     int halfWidth = width / 2;
00049     l = 0 - halfWidth;
00050     r = 0 + halfWidth;
00051   }
00052 
00053   inline void
00054   Extent::extend(int deltaL, int deltaR) {
00055     l += deltaL; r += deltaR;
00056   }
00057 
00058   inline void
00059   Extent::move(int delta) {
00060     l += delta; r += delta;
00061   }
00062 
00063   forceinline const Extent&
00064   Shape::operator [](int i) const {
00065     assert(i < _depth);
00066     return shape[i];
00067   }
00068 
00069   forceinline Extent&
00070   Shape::operator [](int i) {
00071     assert(i < _depth);
00072     return shape[i];
00073   }
00074 
00075   inline Shape*
00076   Shape::allocate(int d) {
00077     Shape* ret =
00078       static_cast<Shape*>(heap.ralloc(sizeof(Shape) +
00079                                          (d-1)*sizeof(Extent)));
00080     ret->_depth = d;
00081     return ret;
00082   }
00083 
00084   inline Shape*
00085   Shape::allocate(Extent e) {
00086     Shape* ret = Shape::allocate(1);
00087     (*ret)[0] = e;
00088     return ret;
00089   }
00090 
00091   forceinline void
00092   Shape::deallocate(Shape* shape) {
00093     if (shape != hidden && shape != leaf)
00094       heap.rfree(shape);
00095   }
00096 
00097   forceinline int
00098   Shape::depth(void) const { return _depth; }
00099 
00100   forceinline
00101   BoundingBox::BoundingBox(int l, int r)
00102    : left(l), right(r) {}
00103 
00104   forceinline bool
00105   VisualNode::isHidden(void) {
00106     return getFlag(HIDDEN);
00107   }
00108 
00109   forceinline void
00110   VisualNode::setHidden(bool h) {
00111     setFlag(HIDDEN, h);
00112   }
00113 
00114   forceinline void
00115   VisualNode::setStop(bool h) {
00116     if (getStatus() == BRANCH && h)
00117       setStatus(STOP);
00118     else if (getStatus() == STOP && !h)
00119       setStatus(UNSTOP);
00120   }
00121 
00122   forceinline int
00123   VisualNode::getOffset(void) { return offset; }
00124 
00125   forceinline void
00126   VisualNode::setOffset(int n) { offset = n; }
00127 
00128   forceinline bool
00129   VisualNode::isDirty(void) {
00130     return getFlag(DIRTY);
00131   }
00132 
00133   forceinline void
00134   VisualNode::setDirty(bool d) {
00135     setFlag(DIRTY, d);
00136   }
00137 
00138   forceinline bool
00139   VisualNode::childrenLayoutIsDone(void) {
00140     return getFlag(CHILDRENLAYOUTDONE);
00141   }
00142 
00143   forceinline void
00144   VisualNode::setChildrenLayoutDone(bool d) {
00145     setFlag(CHILDRENLAYOUTDONE, d);
00146   }
00147 
00148   forceinline bool
00149   VisualNode::isMarked(void) {
00150     return getFlag(MARKED);
00151   }
00152 
00153   forceinline void
00154   VisualNode::setMarked(bool m) {
00155     setFlag(MARKED, m);
00156   }
00157 
00158   forceinline bool
00159   VisualNode::isBookmarked(void) {
00160     return getFlag(BOOKMARKED);
00161   }
00162 
00163   forceinline void
00164   VisualNode::setBookmarked(bool m) {
00165     setFlag(BOOKMARKED, m);
00166   }
00167 
00168   forceinline bool
00169   VisualNode::isOnPath(void) {
00170     return getFlag(ONPATH);
00171   }
00172 
00173   forceinline void
00174   VisualNode::setOnPath(bool b) {
00175     setFlag(ONPATH, b);
00176   }
00177 
00178   forceinline Shape*
00179   VisualNode::getShape(void) { return shape; }
00180 
00181   forceinline void
00182   VisualNode::setBoundingBox(BoundingBox b) { box = b; }
00183 
00184   forceinline BoundingBox
00185   VisualNode::getBoundingBox(void) { return box; }
00186 
00187   forceinline VisualNode*
00188   VisualNode::getParent() {
00189     return static_cast<VisualNode*>(SpaceNode::getParent());
00190   }
00191 
00192   forceinline VisualNode*
00193   VisualNode::getChild(int i) {
00194     return static_cast<VisualNode*>(SpaceNode::getChild(i));
00195   }
00196 
00197 }}
00198 
00199 // STATISTICS: gist-any