trace-print.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
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