Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
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, 2017
8  *
9  * Last modified:
10  * $Date$ by $Author$
11  * $Revision$
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #include <functional>
39 
40 namespace Gecode {
41 
43  template<class Var, class Val>
44  using VarValPrint = std::function<void(const Space& home, const Brancher& b,
45  unsigned int a,
46  Var x, int i, const Val& m,
47  std::ostream& o)>;
48 
50  template<class View, class Val>
51  class BrancherPrint {
52  public:
54  typedef typename View::VarType Var;
55  protected:
57  public:
63  operator bool(void) const;
65  void operator ()(const Space& home, const Brancher& b,
66  unsigned int a,
67  View x, int i, const Val& m,
68  std::ostream& o) const;
70  bool notice(void) const;
72  void dispose(Space& home);
73  };
74 
76  template<class View, class Val>
78  public:
80  typedef typename View::VarType Var;
81  public:
87  operator bool(void) const;
89  void operator ()(const Space& home, const Brancher& b,
90  unsigned int a,
91  View x, int i, const Val& m,
92  std::ostream& o) const;
94  bool notice(void) const;
96  void dispose(Space& home);
97  };
98 
99 
100 
101  template<class View, class Val>
104  if (!vvp)
105  throw Gecode::InvalidFunction("BrancherPrint::BrancherPrint");
106  }
107 
108  template<class View, class Val>
111  : p(bp.p) {
112  }
113 
114  template<class View, class Val>
117  return true;
118  }
119 
120  template<class View, class Val>
121  forceinline void
123  unsigned int a,
124  View x, int i, const Val& m,
125  std::ostream& o) const {
127  Var xv(x.varimp());
128  p()(home,b,a,xv,i,m,o);
129  }
130 
131  template<class View, class Val>
132  forceinline bool
134  return true;
135  }
136 
137  template<class View, class Val>
138  forceinline void
141  }
142 
143 
144  template<class View, class Val>
147  assert(!vvp);
148  (void) vvp;
149  }
150 
151  template<class View, class Val>
154 
155  template<class View, class Val>
158  return false;
159  }
160 
161  template<class View, class Val>
162  forceinline void
164  unsigned int,
165  View, int, const Val&,
166  std::ostream&) const {}
167  template<class View, class Val>
168  forceinline bool
170  return false;
171  }
172 
173  template<class View, class Val>
174  forceinline void
176 
177 }
178 
179 // STATISTICS: kernel-branch
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: print.hpp:169
std::function< void(const Space &home, const Brancher &b, unsigned int a, Var x, int i, const Val &m, std::ostream &o)> VarValPrint
Function type for printing variable and value selection.
Definition: print.hpp:47
View::VarType Var
The corresponding variable type.
Definition: print.hpp:80
#define forceinline
Definition: config.hpp:182
Computation spaces.
Definition: core.hpp:1668
Class storing a print function.
Definition: print.hpp:51
Class without print function.
Definition: print.hpp:77
SharedData< VarValPrint< Var, Val > > p
Definition: print.hpp:56
BrancherPrint(VarValPrint< Var, Val > vvp)
Initialize.
Definition: print.hpp:103
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
Definition: core.hpp:1368
~SharedData(void)
Destructors.
void dispose(Space &home)
Delete.
Definition: print.hpp:139
BrancherNoPrint(VarValPrint< Var, Val > vvp)
Initialize.
Definition: print.hpp:146
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition: print.hpp:133
void operator()(const Space &home, const Brancher &b, unsigned int a, View x, int i, const Val &m, std::ostream &o) const
Invoke print function.
Definition: print.hpp:122
Exception: invalid function
Definition: exception.hpp:118
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition: macros.hpp:98
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
void dispose(Space &home)
Delete.
Definition: print.hpp:175
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Class for sharing data between spaces.
Definition: shared-data.hpp:42
Post propagator for SetVar x
Definition: set.hh:769
Gecode toplevel namespace
void operator()(const Space &home, const Brancher &b, unsigned int a, View x, int i, const Val &m, std::ostream &o) const
Invoke print function.
Definition: print.hpp:163
View::VarType Var
The corresponding variable type.
Definition: print.hpp:54