stopbrancher.cpp
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.
*
*/
#include <gecode/gist/stopbrancher.hh>
namespace Gecode { namespace Gist {
StopChoice::StopChoice(const Brancher& b) : Choice(b,1) {}
void
StopChoice::archive(Archive& e) const {
Choice::archive(e);
}
StopBrancher::StopBrancher(Home home) : Brancher(home), done(false) {}
StopBrancher::StopBrancher(Space& home, StopBrancher& b)
: Brancher(home,b), done(b.done) {}
bool
StopBrancher::status(const Space&) const {
return !done;
}
Choice*
StopBrancher::choice(Space&) {
return new StopChoice(*this);
}
Choice*
StopBrancher::choice(const Space&, Archive&) {
return new StopChoice(*this);
}
ExecStatus
StopBrancher::commit(Space&, const Choice&, unsigned int) {
done = true;
return ES_OK;
}
void
StopBrancher::print(const Space&, const Gecode::Choice&,
unsigned int, std::ostream&) const {
}
Actor*
StopBrancher::copy(Space& home) {
return new (home) StopBrancher(home, *this);
}
void
StopBrancher::post(Home home) {
(void) new (home) StopBrancher(home);
}
size_t
StopBrancher::dispose(Space&) {
return sizeof(*this);
}
}}
// STATISTICS: gist-any
Gecode::Actor
Base-class for both propagators and branchers.
Definition core.hpp:628
Gecode::Archive
Archive representation
Definition archive.hpp:42
Gecode::Brancher
Base-class for branchers.
Definition core.hpp:1442
Gecode::Brancher::Space
friend class Space
Definition core.hpp:1444
Gecode::Brancher::Brancher
Brancher(Home home)
Constructor for creation.
Definition core.hpp:3605
Gecode::Brancher::Choice
friend class Choice
Definition core.hpp:1445
Gecode::Choice
Choice for performing commit
Definition core.hpp:1412
Gecode::Choice::Choice
Choice(const Brancher &b, const unsigned int a)
Initialize for particular brancher b and alternatives a.
Definition core.hpp:3766
Gecode::Choice::archive
virtual void archive(Archive &e) const
Archive into e.
Definition core.cpp:891
Gecode::Gist::StopBrancher::copy
virtual Actor * copy(Space &home)
Copy brancher.
Definition stopbrancher.cpp:74
Gecode::Gist::StopBrancher::dispose
virtual size_t dispose(Space &)
Delete brancher and return its size.
Definition stopbrancher.cpp:82
Gecode::Gist::StopBrancher::print
virtual void print(const Space &home, const Gecode::Choice &c, unsigned int, std::ostream &o) const
Print explanation.
Definition stopbrancher.cpp:69
Gecode::Gist::StopBrancher::done
bool done
Flag whether brancher has been executed.
Definition stopbrancher.hh:52
Gecode::Gist::StopBrancher::choice
virtual Choice * choice(Space &)
Return choice.
Definition stopbrancher.cpp:55
Gecode::Gist::StopBrancher::post
static void post(Home home)
Post brancher.
Definition stopbrancher.cpp:78
Gecode::Gist::StopBrancher::StopBrancher
StopBrancher(Home home)
Construct brancher.
Definition stopbrancher.cpp:44
Gecode::Gist::StopBrancher::status
virtual bool status(const Space &) const
Check status of brancher, return true if alternatives left.
Definition stopbrancher.cpp:50
Gecode::Gist::StopBrancher::commit
virtual ExecStatus commit(Space &, const Choice &, unsigned int)
Perform commit for choice _c and alternative a.
Definition stopbrancher.cpp:63
Gecode::Gist::StopChoice
Choice for StopBrancher
Definition stopbrancher.hh:40
Gecode::Gist::StopChoice::StopChoice
StopChoice(const Brancher &b)
Initialize choice for brancher b.
Definition stopbrancher.cpp:38
Gecode::Gist::StopChoice::archive
virtual void archive(Archive &e) const
Archive into e.
Definition stopbrancher.cpp:40
Gecode::Home
Home class for posting propagators
Definition core.hpp:856
Gecode::Gist
The Gecode Interactive Search Tool.
Gecode
Gecode toplevel namespace
Gecode::ExecStatus
ExecStatus
Definition core.hpp:472
Gecode::ES_OK
@ ES_OK
Execution is okay.
Definition core.hpp:476
stopbrancher.hh