Generated on Tue Jul 27 2010 21:59:10 for Gecode by doxygen 1.7.1

node.hh

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-01-21 11:36:29 +0100 (Wed, 21 Jan 2009) $ by $Author: schulte $
00011  *     $Revision: 8083 $
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 #ifndef GECODE_GIST_NODE_HH
00039 #define GECODE_GIST_NODE_HH
00040 
00041 #include <gecode/support.hh>
00042 
00043 namespace Gecode { namespace Gist {
00044 
00045   class VisualNode;
00046 
00047   static const int NodeBlockSize = 10000;
00048 
00050   class Node : public Support::BlockClient<VisualNode,NodeBlockSize> {
00051   private:
00053     Node* parent;
00054 
00056     enum {
00057       UNDET, //< Number of children not determined
00058       LEAF,  //< Leaf node
00059       TWO_CHILDREN, //< Node with at most two children
00060       MORE_CHILDREN //< Node with more than two children
00061     };
00062 
00064     void* childrenOrFirstChild;
00065 
00066     union {
00068       Node* secondChild;
00070       unsigned int noOfChildren;
00071     } c;
00072 
00074     unsigned int getTag(void) const;
00076     void setTag(unsigned int tag);
00078     void* getPtr(void) const;
00079 
00080   protected:
00082     bool isUndetermined(void) const;
00083 
00084   public:
00085     typedef Support::BlockAllocator<VisualNode,NodeBlockSize> NodeAllocator;
00086 
00088     Node(void);
00090     ~Node(void);
00091 
00093     Node* getParent(void);
00095     Node* getChild(unsigned int n);
00096 
00098     bool isRoot(void) const;
00099 
00101     void setNumberOfChildren(unsigned int n);
00103     void setChild(unsigned int n, Node* child);
00104 
00106     void addChild(Node* child);
00107 
00109     unsigned int getNumberOfChildren(void) const;
00110   };
00111 
00112 }}
00113 
00114 #include <gecode/gist/node.hpp>
00115 
00116 #endif
00117 
00118 // STATISTICS: gist-any