Generated on Tue Jul 18 2017 18:41:42 for Gecode by doxygen 1.8.13
brancher-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: 2017-04-01 20:27:10 +0200 (Sat, 01 Apr 2017) $ by $Author: schulte $
11  * $Revision: 15623 $
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:
61  BrancherPrint(Space& home, bool shared, BrancherPrint& bp);
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:
85  BrancherNoPrint(Space& home, bool shared, BrancherNoPrint& bp);
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>
112  p.update(home,shared,bp.p);
113  }
114 
115  template<class View, class Val>
118  return true;
119  }
120 
121  template<class View, class Val>
122  forceinline void
124  unsigned int a,
125  View x, int i, const Val& m,
126  std::ostream& o) const {
128  Var xv(x.varimp());
129  p()(home,b,a,xv,i,m,o);
130  }
131 
132  template<class View, class Val>
133  forceinline bool
135  return true;
136  }
137 
138  template<class View, class Val>
139  forceinline void
142  }
143 
144 
145  template<class View, class Val>
148  assert(!vvp);
149  }
150 
151  template<class View, class Val>
155 
156  template<class View, class Val>
159  return false;
160  }
161 
162  template<class View, class Val>
163  forceinline void
165  unsigned int,
166  View, int, const Val&,
167  std::ostream&) const {}
168  template<class View, class Val>
169  forceinline bool
171  return false;
172  }
173 
174  template<class View, class Val>
175  forceinline void
177 
178 }
179 
180 // STATISTICS: kernel-branch
void update(Space &home, bool share, SharedHandle &sh)
Update during cloning.
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
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.
View::VarType Var
The corresponding variable type.
Computation spaces.
Definition: core.hpp:1748
Class storing a print function.
Class without print function.
SharedData< VarValPrint< Var, Val > > p
BrancherPrint(VarValPrint< Var, Val > vvp)
Initialize.
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
Definition: core.hpp:1446
~SharedData(void)
Destructors.
void dispose(Space &home)
Delete.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
BrancherNoPrint(VarValPrint< Var, Val > vvp)
Initialize.
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
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.
Exception: invalid function
Definition: exception.hpp:118
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition: macros.hpp:98
void dispose(Space &home)
Delete.
Class for sharing data between spaces.
Definition: shared-data.hpp:42
#define forceinline
Definition: config.hpp:173
Post propagator for SetVar x
Definition: set.hh:784
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:702
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.
View::VarType Var
The corresponding variable type.