nodecursor.hh
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Guido Tack <tack@gecode.org>
*
* Copyright:
* Guido Tack, 2006
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef GECODE_GIST_NODECURSOR_HH
#define GECODE_GIST_NODECURSOR_HH
#include <gecode/gist/visualnode.hh>
namespace Gecode { namespace Gist {
template<class Node>
class NodeCursor {
private:
Node* _startNode;
Node* _node;
unsigned int _alternative;
protected:
const typename Node::NodeAllocator& na;
void node(Node* n);
Node* startNode(void);
public:
NodeCursor(Node* theNode, const typename Node::NodeAllocator& na);
Node* node(void);
unsigned int alternative(void);
void alternative(unsigned int a);
bool mayMoveUpwards(void);
void moveUpwards(void);
bool mayMoveDownwards(void);
void moveDownwards(void);
bool mayMoveSidewards(void);
void moveSidewards(void);
};
class HideFailedCursor : public NodeCursor<VisualNode> {
private:
bool onlyDirty;
public:
HideFailedCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na,
bool onlyDirtyNodes);
bool mayMoveDownwards(void);
void processCurrentNode(void);
};
class UnhideAllCursor : public NodeCursor<VisualNode> {
public:
UnhideAllCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na);
void processCurrentNode(void);
};
class UnstopAllCursor : public NodeCursor<VisualNode> {
public:
UnstopAllCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na);
void processCurrentNode(void);
};
class NextSolCursor : public NodeCursor<VisualNode> {
private:
bool back;
bool notOnSol(void);
public:
NextSolCursor(VisualNode* theNode, bool backwards,
const VisualNode::NodeAllocator& na);
void processCurrentNode(void);
bool mayMoveUpwards(void);
bool mayMoveDownwards(void);
void moveDownwards(void);
bool mayMoveSidewards(void);
void moveSidewards(void);
};
class StatCursor : public NodeCursor<VisualNode> {
private:
int curDepth;
public:
int depth;
int failed;
int solved;
int choice;
int open;
StatCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na);
void processCurrentNode(void);
void moveDownwards(void);
void moveUpwards(void);
};
class BranchLabelCursor : public NodeCursor<VisualNode> {
private:
VisualNode::NodeAllocator& _na;
BestNode* _curBest;
int _c_d;
int _a_d;
bool _clear;
public:
BranchLabelCursor(VisualNode* theNode, BestNode* curBest,
int c_d, int a_d, bool clear,
VisualNode::NodeAllocator& na);
void processCurrentNode(void);
};
class DisposeCursor : public NodeCursor<VisualNode> {
public:
DisposeCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na);
void processCurrentNode(void);
};
}}
#include <gecode/gist/nodecursor.hpp>
#endif
// STATISTICS: gist-any
Gecode::Gist::BestNode
Static reference to the currently best space.
Definition spacenode.hh:80
Gecode::Gist::BranchLabelCursor::BranchLabelCursor
BranchLabelCursor(VisualNode *theNode, BestNode *curBest, int c_d, int a_d, bool clear, VisualNode::NodeAllocator &na)
Constructor.
Definition nodecursor.hpp:256
Gecode::Gist::BranchLabelCursor::processCurrentNode
void processCurrentNode(void)
Definition nodecursor.hpp:263
Gecode::Gist::DisposeCursor::processCurrentNode
void processCurrentNode(void)
Dispose node.
Definition nodecursor.hpp:292
Gecode::Gist::DisposeCursor::DisposeCursor
DisposeCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition nodecursor.hpp:287
Gecode::Gist::HideFailedCursor::processCurrentNode
void processCurrentNode(void)
Process node.
Definition nodecursor.hpp:130
Gecode::Gist::HideFailedCursor::HideFailedCursor
HideFailedCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na, bool onlyDirtyNodes)
Constructor.
Definition nodecursor.hpp:124
Gecode::Gist::HideFailedCursor::mayMoveDownwards
bool mayMoveDownwards(void)
Test if the cursor may move to the first child node.
Definition nodecursor.hpp:115
Gecode::Gist::NextSolCursor::processCurrentNode
void processCurrentNode(void)
Do nothing.
Definition nodecursor.hpp:175
Gecode::Gist::NextSolCursor::mayMoveUpwards
bool mayMoveUpwards(void)
Test if the cursor may move to the parent node.
Definition nodecursor.hpp:183
Gecode::Gist::NextSolCursor::NextSolCursor
NextSolCursor(VisualNode *theNode, bool backwards, const VisualNode::NodeAllocator &na)
Constructor.
Definition nodecursor.hpp:170
Gecode::Gist::NextSolCursor::moveSidewards
void moveSidewards(void)
Move cursor to the first sibling.
Definition nodecursor.hpp:215
Gecode::Gist::NextSolCursor::mayMoveDownwards
bool mayMoveDownwards(void)
Test if cursor may move to the first child node.
Definition nodecursor.hpp:188
Gecode::Gist::NextSolCursor::mayMoveSidewards
bool mayMoveSidewards(void)
Test if cursor may move to the first sibling.
Definition nodecursor.hpp:204
Gecode::Gist::NextSolCursor::moveDownwards
void moveDownwards(void)
Move cursor to the first child node.
Definition nodecursor.hpp:195
Gecode::Gist::NodeCursor::na
const Node::NodeAllocator & na
The node allocator.
Definition nodecursor.hh:53
Gecode::Gist::NodeCursor::moveDownwards
void moveDownwards(void)
Move cursor to the first child node.
Definition nodecursor.hpp:95
Gecode::Gist::NodeCursor::mayMoveUpwards
bool mayMoveUpwards(void)
Test if the cursor may move to the parent node.
Definition nodecursor.hpp:66
Gecode::Gist::NodeCursor::NodeCursor
NodeCursor(Node *theNode, const typename Node::NodeAllocator &na)
Construct cursor, initially set to theNode.
Definition nodecursor.hpp:38
Gecode::Gist::NodeCursor::node
Node * node(void)
Return current node.
Definition nodecursor.hpp:46
Gecode::Gist::NodeCursor::alternative
unsigned int alternative(void)
Return current alternative.
Definition nodecursor.hpp:50
Gecode::Gist::NodeCursor::startNode
Node * startNode(void)
Return start node.
Definition nodecursor.hpp:58
Gecode::Gist::NodeCursor::moveSidewards
void moveSidewards(void)
Move cursor to the first sibling.
Definition nodecursor.hpp:109
Gecode::Gist::NodeCursor::mayMoveSidewards
bool mayMoveSidewards(void)
Test if cursor may move to the first sibling.
Definition nodecursor.hpp:102
Gecode::Gist::NodeCursor::moveUpwards
void moveUpwards(void)
Move cursor to the parent node.
Definition nodecursor.hpp:72
Gecode::Gist::NodeCursor::mayMoveDownwards
bool mayMoveDownwards(void)
Test if cursor may move to the first child node.
Definition nodecursor.hpp:89
Gecode::Gist::Node
Base class for nodes of the search tree.
Definition node.hh:106
Gecode::Gist::Node::NodeAllocator
NodeAllocatorBase< VisualNode > NodeAllocator
Definition node.hh:143
Gecode::Gist::StatCursor::choice
int choice
Number of choice nodes.
Definition nodecursor.hh:170
Gecode::Gist::StatCursor::moveDownwards
void moveDownwards(void)
Move cursor to the first child node.
Definition nodecursor.hpp:243
Gecode::Gist::StatCursor::failed
int failed
Number of failed nodes.
Definition nodecursor.hh:166
Gecode::Gist::StatCursor::StatCursor
StatCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition nodecursor.hpp:225
Gecode::Gist::StatCursor::depth
int depth
Depth of the search tree.
Definition nodecursor.hh:164
Gecode::Gist::StatCursor::processCurrentNode
void processCurrentNode(void)
Collect statistics.
Definition nodecursor.hpp:231
Gecode::Gist::StatCursor::open
int open
Number of open nodes.
Definition nodecursor.hh:172
Gecode::Gist::StatCursor::solved
int solved
Number of solved nodes.
Definition nodecursor.hh:168
Gecode::Gist::StatCursor::moveUpwards
void moveUpwards(void)
Move cursor to the parent node.
Definition nodecursor.hpp:250
Gecode::Gist::UnhideAllCursor::UnhideAllCursor
UnhideAllCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition nodecursor.hpp:142
Gecode::Gist::UnhideAllCursor::processCurrentNode
void processCurrentNode(void)
Process node.
Definition nodecursor.hpp:147
Gecode::Gist::UnstopAllCursor::processCurrentNode
void processCurrentNode(void)
Process node.
Definition nodecursor.hpp:161
Gecode::Gist::UnstopAllCursor::UnstopAllCursor
UnstopAllCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition nodecursor.hpp:156
Gecode::Gist::VisualNode
Node class that supports visual layout
Definition visualnode.hh:125
Gecode::Gist
The Gecode Interactive Search Tool.
Gecode
Gecode toplevel namespace
nodecursor.hpp
visualnode.hh