Generated on Mon Nov 30 23:53:19 2009 for Gecode by doxygen 1.6.1

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: 2009-09-29 12:49:42 +0200 (Tue, 29 Sep 2009) $ by $Author: tack $
00011  *     $Revision: 9766 $
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 int
00115   VisualNode::getOffset(void) { return offset; }
00116 
00117   forceinline void
00118   VisualNode::setOffset(int n) { offset = n; }
00119 
00120   forceinline bool
00121   VisualNode::isDirty(void) {
00122     return getFlag(DIRTY);
00123   }
00124 
00125   forceinline void
00126   VisualNode::setDirty(bool d) {
00127     setFlag(DIRTY, d);
00128   }
00129 
00130   forceinline bool
00131   VisualNode::childrenLayoutIsDone(void) {
00132     return getFlag(CHILDRENLAYOUTDONE);
00133   }
00134 
00135   forceinline void
00136   VisualNode::setChildrenLayoutDone(bool d) {
00137     setFlag(CHILDRENLAYOUTDONE, d);
00138   }
00139 
00140   forceinline bool
00141   VisualNode::isMarked(void) {
00142     return getFlag(MARKED);
00143   }
00144 
00145   forceinline void
00146   VisualNode::setMarked(bool m) {
00147     setFlag(MARKED, m);
00148   }
00149 
00150   forceinline bool
00151   VisualNode::isOnPath(void) {
00152     return getFlag(ONPATH);
00153   }
00154 
00155   forceinline void
00156   VisualNode::setOnPath(bool b) {
00157     setFlag(ONPATH, b);
00158   }
00159 
00160   forceinline Shape*
00161   VisualNode::getShape(void) { return shape; }
00162 
00163   forceinline void
00164   VisualNode::setBoundingBox(BoundingBox b) { box = b; }
00165 
00166   forceinline BoundingBox
00167   VisualNode::getBoundingBox(void) { return box; }
00168 
00169   forceinline VisualNode*
00170   VisualNode::getParent() {
00171     return static_cast<VisualNode*>(SpaceNode::getParent());
00172   }
00173 
00174   forceinline VisualNode*
00175   VisualNode::getChild(int i) {
00176     return static_cast<VisualNode*>(SpaceNode::getChild(i));
00177   }
00178 
00179 }}
00180 
00181 // STATISTICS: gist-any