tracer.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2016
*
* 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/kernel.hh>
namespace Gecode {
Support::Mutex TracerBase::m;
StdTracer::StdTracer(std::ostream& os0) : os(os0) {}
void
StdTracer::propagate(const Space&,
const PropagateTraceInfo& pti) {
os << "trace::" << pti << std::endl;
}
void
StdTracer::commit(const Space& home,
const CommitTraceInfo& cti) {
os << "trace::" << cti << std::endl
<< '\t';
cti.brancher().print(home, cti.choice(), cti.alternative(), os);
os << std::endl;
}
void
StdTracer::post(const Space&,
const PostTraceInfo& pti) {
os << "trace::" << pti << std::endl;
}
StdTracer StdTracer::def;
}
// STATISTICS: kernel-trace
Gecode::Brancher::print
virtual void print(const Space &home, const Choice &c, unsigned int a, std::ostream &o) const
Print branch for choice c and alternative a.
Definition core.cpp:97
Gecode::CommitTraceInfo
Commit trace information.
Definition core.hpp:1005
Gecode::CommitTraceInfo::alternative
unsigned int alternative(void) const
Return alternative.
Definition core.hpp:3424
Gecode::CommitTraceInfo::choice
const Choice & choice(void) const
Return choice.
Definition core.hpp:3420
Gecode::CommitTraceInfo::brancher
const Brancher & brancher(void) const
Return brancher.
Definition core.hpp:3416
Gecode::PostTraceInfo
Post trace information.
Definition core.hpp:1032
Gecode::PropagateTraceInfo
Propagate trace information.
Definition core.hpp:969
Gecode::StdTracer
Default tracer.
Definition tracer.hpp:210
Gecode::StdTracer::os
std::ostream & os
Output stream to use.
Definition tracer.hpp:213
Gecode::StdTracer::StdTracer
StdTracer(std::ostream &os=std::cerr)
Initialize with output stream os.
Definition tracer.cpp:41
Gecode::StdTracer::propagate
virtual void propagate(const Space &home, const PropagateTraceInfo &pti)
Propagate function.
Definition tracer.cpp:44
Gecode::StdTracer::def
static StdTracer def
Default tracer (printing to std::cerr).
Definition tracer.hpp:242
Gecode::StdTracer::commit
virtual void commit(const Space &home, const CommitTraceInfo &cti)
Commit function.
Definition tracer.cpp:50
Gecode::StdTracer::post
virtual void post(const Space &home, const PostTraceInfo &pti)
Post function.
Definition tracer.cpp:59
Gecode::Support::Mutex
A mutex for mutual exclausion among several threads.
Definition thread.hpp:96
Gecode::TracerBase::m
static Support::Mutex m
Mutex to provide synchronization.
Definition tracer.hpp:41
Gecode::Tracer::Space
friend class Space
Definition tracer.hpp:150
kernel.hh
Gecode
Gecode toplevel namespace