Generated on Wed Jul 21 2021 00:00:00 for Gecode by doxygen 1.9.1
print.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2016
8  *
9  * This file is part of Gecode, the generic constraint
10  * development environment:
11  * http://www.gecode.org
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining
14  * a copy of this software and associated documentation files (the
15  * "Software"), to deal in the Software without restriction, including
16  * without limitation the rights to use, copy, modify, merge, publish,
17  * distribute, sublicense, and/or sell copies of the Software, and to
18  * permit persons to whom the Software is furnished to do so, subject to
19  * the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be
22  * included in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  *
32  */
33 
34 #include <iostream>
35 #include <sstream>
36 
37 namespace Gecode {
38 
43  template<class Char, class Traits>
44  std::basic_ostream<Char,Traits>&
45  operator <<(std::basic_ostream<Char,Traits>& os,
46  const ViewTraceInfo& vti) {
47  std::basic_ostringstream<Char,Traits> s;
48  s.copyfmt(os); s.width(0);
49  switch (vti.what()) {
51  s << "propagator(id:" << vti.propagator().id();
52  if (vti.propagator().group().in())
53  s << ",g:" << vti.propagator().group().id();
54  s << ')';
55  break;
57  s << "brancher(id:" << vti.brancher().id();
58  if (vti.brancher().group().in())
59  s << ",g:" << vti.brancher().group().id();
60  s << ')';
61  break;
63  s << "post(";
64  if (vti.post().in())
65  s << "g:" << vti.post().id();
66  s << ')';
67  break;
69  s << '-';
70  break;
71  default:
73  }
74  return os << s.str();
75  }
76 
81  template<class Char, class Traits>
82  std::basic_ostream<Char,Traits>&
83  operator <<(std::basic_ostream<Char,Traits>& os,
84  const PropagateTraceInfo& pti) {
85  std::basic_ostringstream<Char,Traits> s;
86  s.copyfmt(os); s.width(0);
87  s << "propagate(id:" << pti.id();
88  if (pti.group().in())
89  s << ",g:" << pti.group().id();
90  s << ",s:";
91  switch (pti.status()) {
93  s << "fix"; break;
95  s << "nofix"; break;
97  s << "failed"; break;
99  s << "subsumed"; break;
100  default:
101  GECODE_NEVER;
102  }
103  s << ')';
104  return os << s.str();
105  }
106 
111  template<class Char, class Traits>
112  std::basic_ostream<Char,Traits>&
113  operator <<(std::basic_ostream<Char,Traits>& os,
114  const CommitTraceInfo& cti) {
115  std::basic_ostringstream<Char,Traits> s;
116  s.copyfmt(os); s.width(0);
117  s << "commit(id:" << cti.id();
118  if (cti.group().in())
119  s << ",g:" << cti.group().id();
120  s << ')';
121  return os << s.str();
122  }
123 
128  template<class Char, class Traits>
129  std::basic_ostream<Char,Traits>&
130  operator <<(std::basic_ostream<Char,Traits>& os,
131  const PostTraceInfo& pti) {
132  std::basic_ostringstream<Char,Traits> s;
133  s.copyfmt(os); s.width(0);
134  s << "post(";
135  if (pti.group().in())
136  s << "g:" << pti.group().id() << ",";
137  s << "s:";
138  switch (pti.status()) {
140  s << "posted(" << pti.propagators() << ")"; break;
142  s << "failed"; break;
144  s << "subsumed"; break;
145  default:
146  GECODE_NEVER;
147  }
148  s << ')';
149  return os << s.str();
150  }
151 
152 }
153 
154 // STATISTICS: kernel-trace
Commit trace information.
Definition: core.hpp:1005
BrancherGroup group(void) const
Return brancher group.
Definition: core.hpp:3412
unsigned int id(void) const
Return brancher identifier.
Definition: core.hpp:3408
unsigned int id(void) const
Return a unique id for the group.
Definition: core.hpp:4974
bool in(Group a) const
Check whether actor group a is included in this group.
Definition: core.hpp:4956
Post trace information.
Definition: core.hpp:1032
unsigned int propagators(void) const
Return number of posted propagators.
Definition: core.hpp:3445
PropagatorGroup group(void) const
Return propagator group.
Definition: core.hpp:3437
@ SUBSUMED
Propagator not posted as already subsumed.
Definition: core.hpp:1040
@ FAILED
Posting failed.
Definition: core.hpp:1039
@ POSTED
Propagator was posted.
Definition: core.hpp:1038
Status status(void) const
Return post status.
Definition: core.hpp:3441
Propagate trace information.
Definition: core.hpp:969
@ SUBSUMED
Propagator is subsumed.
Definition: core.hpp:977
@ FIX
Propagator computed fixpoint.
Definition: core.hpp:974
@ NOFIX
Propagator did not compute fixpoint.
Definition: core.hpp:975
@ FAILED
Propagator failed.
Definition: core.hpp:976
unsigned int id(void) const
Return propagator identifier.
Definition: core.hpp:3382
Status status(void) const
Return propagator status.
Definition: core.hpp:3394
PropagatorGroup group(void) const
Return propagator group.
Definition: core.hpp:3386
View trace information.
Definition: core.hpp:908
What what(void) const
Return what is currently executing.
Definition: core.hpp:3332
void brancher(Brancher &b)
Record that brancher b is executing.
Definition: core.hpp:3320
@ BRANCHER
A brancher is executing.
Definition: core.hpp:917
@ OTHER
Unknown.
Definition: core.hpp:921
@ POST
A post function is executing.
Definition: core.hpp:919
@ PROPAGATOR
A propagator is currently executing.
Definition: core.hpp:915
void propagator(Propagator &p)
Record that propagator p is executing.
Definition: core.hpp:3316
void post(PropagatorGroup g)
Record that a post function with propagator group g is executing.
Definition: core.hpp:3324
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const SingletonView &x)
Definition: print.hpp:120
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:56