Generated on Sun Feb 17 15:24:11 2019 for Gecode by doxygen 1.6.3

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  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 #include <iostream>
00035 #include <sstream>
00036 
00037 namespace Gecode {
00038 
00043   template<class Char, class Traits>
00044   std::basic_ostream<Char,Traits>&
00045   operator <<(std::basic_ostream<Char,Traits>& os,
00046               const ViewTraceInfo& vti) {
00047     std::basic_ostringstream<Char,Traits> s;
00048     s.copyfmt(os); s.width(0);
00049     switch (vti.what()) {
00050     case ViewTraceInfo::PROPAGATOR:
00051       s << "propagator(id:" << vti.propagator().id();
00052       if (vti.propagator().group().in())
00053         s  << ",g:" << vti.propagator().group().id();
00054       s << ')';
00055       break;
00056     case ViewTraceInfo::BRANCHER:
00057       s << "brancher(id:" << vti.brancher().id();
00058       if (vti.brancher().group().in())
00059         s  << ",g:" << vti.brancher().group().id();
00060       s << ')';
00061       break;
00062     case ViewTraceInfo::POST:
00063       s << "post(";
00064       if (vti.post().in())
00065         s << "g:" << vti.post().id();
00066       s << ')';
00067       break;
00068     case ViewTraceInfo::OTHER:
00069       s << '-';
00070       break;
00071     default:
00072       GECODE_NEVER;
00073     }
00074     return os << s.str();
00075   }
00076 
00081   template<class Char, class Traits>
00082   std::basic_ostream<Char,Traits>&
00083   operator <<(std::basic_ostream<Char,Traits>& os,
00084               const PropagateTraceInfo& pti) {
00085     std::basic_ostringstream<Char,Traits> s;
00086     s.copyfmt(os); s.width(0);
00087     s << "propagate(id:" << pti.id();
00088     if (pti.group().in())
00089       s  << ",g:" << pti.group().id();
00090     s << ",s:";
00091     switch (pti.status()) {
00092     case PropagateTraceInfo::FIX:
00093       s << "fix"; break;
00094     case PropagateTraceInfo::NOFIX:
00095       s << "nofix"; break;
00096     case PropagateTraceInfo::FAILED:
00097       s << "failed"; break;
00098     case PropagateTraceInfo::SUBSUMED:
00099       s << "subsumed"; break;
00100     default:
00101       GECODE_NEVER;
00102     }
00103     s << ')';
00104     return os << s.str();
00105   }
00106 
00111   template<class Char, class Traits>
00112   std::basic_ostream<Char,Traits>&
00113   operator <<(std::basic_ostream<Char,Traits>& os,
00114               const CommitTraceInfo& cti) {
00115     std::basic_ostringstream<Char,Traits> s;
00116     s.copyfmt(os); s.width(0);
00117     s << "commit(id:" << cti.id();
00118     if (cti.group().in())
00119       s  << ",g:" << cti.group().id();
00120     s << ')';
00121     return os << s.str();
00122   }
00123 
00128   template<class Char, class Traits>
00129   std::basic_ostream<Char,Traits>&
00130   operator <<(std::basic_ostream<Char,Traits>& os,
00131               const PostTraceInfo& pti) {
00132     std::basic_ostringstream<Char,Traits> s;
00133     s.copyfmt(os); s.width(0);
00134     s << "post(";
00135     if (pti.group().in())
00136       s  << "g:" << pti.group().id() << ",";
00137     s << "s:";
00138     switch (pti.status()) {
00139     case PostTraceInfo::POSTED:
00140       s << "posted(" << pti.propagators() << ")"; break;
00141     case PostTraceInfo::FAILED:
00142       s << "failed"; break;
00143     case PostTraceInfo::SUBSUMED:
00144       s << "subsumed"; break;
00145     default:
00146       GECODE_NEVER;
00147     }
00148     s << ')';
00149     return os << s.str();
00150   }
00151 
00152 }
00153 
00154 // STATISTICS: kernel-trace