Generated on Tue Apr 18 10:22:07 2017 for Gecode by doxygen 1.6.3

trace-print.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2016
00008  *
00009  *  Last modified:
00010  *     $Date: 2017-03-17 23:04:57 +0100 (Fri, 17 Mar 2017) $ by $Author: schulte $
00011  *     $Revision: 15597 $
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 #include <iostream>
00039 #include <sstream>
00040 
00041 namespace Gecode {
00042 
00047   template<class Char, class Traits>
00048   std::basic_ostream<Char,Traits>&
00049   operator <<(std::basic_ostream<Char,Traits>& os,
00050               const ViewTraceInfo& vti) {
00051     std::basic_ostringstream<Char,Traits> s;
00052     s.copyfmt(os); s.width(0);
00053     switch (vti.what()) {
00054     case ViewTraceInfo::PROPAGATOR:
00055       s << "propagator(id:" << vti.propagator().id();
00056       if (vti.propagator().group().in())
00057         s  << ",g:" << vti.propagator().group().id();
00058       s << ')';
00059       break;
00060     case ViewTraceInfo::BRANCHER:
00061       s << "brancher(id:" << vti.brancher().id();
00062       if (vti.brancher().group().in())
00063         s  << ",g:" << vti.brancher().group().id();
00064       s << ')';
00065       break;
00066     case ViewTraceInfo::POST:
00067       s << "post(";
00068       if (vti.post().in())
00069         s << "g:" << vti.post().id();
00070       s << ')';
00071       break;
00072     case ViewTraceInfo::OTHER:
00073       s << '-';
00074       break;
00075     default:
00076       GECODE_NEVER;
00077     }
00078     return os << s.str();
00079   }
00080 
00085   template<class Char, class Traits>
00086   std::basic_ostream<Char,Traits>&
00087   operator <<(std::basic_ostream<Char,Traits>& os,
00088               const PropagateTraceInfo& pti) {
00089     std::basic_ostringstream<Char,Traits> s;
00090     s.copyfmt(os); s.width(0);
00091     s << "propagate(id:" << pti.id();
00092     if (pti.group().in())
00093       s  << ",g:" << pti.group().id();
00094     s << ",s:";
00095     switch (pti.status()) {
00096     case PropagateTraceInfo::FIX:
00097       s << "fix"; break;
00098     case PropagateTraceInfo::NOFIX:
00099       s << "nofix"; break;
00100     case PropagateTraceInfo::FAILED:
00101       s << "failed"; break;
00102     case PropagateTraceInfo::SUBSUMED:
00103       s << "subsumed"; break;
00104     default:
00105       GECODE_NEVER;
00106     }
00107     s << ')';
00108     return os << s.str();
00109   }
00110 
00115   template<class Char, class Traits>
00116   std::basic_ostream<Char,Traits>&
00117   operator <<(std::basic_ostream<Char,Traits>& os,
00118               const CommitTraceInfo& cti) {
00119     std::basic_ostringstream<Char,Traits> s;
00120     s.copyfmt(os); s.width(0);
00121     s << "commit(id:" << cti.id();
00122     if (cti.group().in())
00123       s  << ",g:" << cti.group().id();
00124     s << ')';
00125     return os << s.str();
00126   }
00127 
00128 }
00129 
00130 // STATISTICS: kernel-trace