main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Jul 27 2020 00:00:00 for Gecode by
doxygen
1.8.18
gecode
kernel
branch
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
* 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 <functional>
35
36
namespace
Gecode
{
37
39
template
<
class
Var,
class
Val>
40
using
VarValPrint
= std::function<void(
const
Space
& home,
const
Brancher
&
b
,
41
unsigned
int
a
,
42
Var
x
,
int
i
,
const
Val& m,
43
std::ostream& o)>;
44
46
template
<
class
View,
class
Val>
47
class
BrancherPrint
{
48
public
:
50
typedef
typename
View::VarType
Var
;
51
protected
:
52
SharedData<VarValPrint<Var,Val>
>
p
;
53
public
:
55
BrancherPrint
(
VarValPrint<Var,Val>
vvp);
57
BrancherPrint
(
BrancherPrint
& bp);
59
operator
bool(
void
)
const
;
61
void
operator ()
(
const
Space
& home,
const
Brancher
&
b
,
62
unsigned
int
a
,
63
View
x
,
int
i
,
const
Val& m,
64
std::ostream& o)
const
;
66
bool
notice
(
void
)
const
;
68
void
dispose
(
Space
& home);
69
};
70
72
template
<
class
View,
class
Val>
73
class
BrancherNoPrint
{
74
public
:
76
typedef
typename
View::VarType
Var
;
77
public
:
79
BrancherNoPrint
(
VarValPrint<Var,Val>
vvp);
81
BrancherNoPrint
(
BrancherNoPrint
& bp);
83
operator
bool(
void
)
const
;
85
void
operator ()
(
const
Space
& home,
const
Brancher
&
b
,
86
unsigned
int
a
,
87
View
x
,
int
i
,
const
Val& m,
88
std::ostream& o)
const
;
90
bool
notice
(
void
)
const
;
92
void
dispose
(
Space
& home);
93
};
94
95
96
97
template
<
class
View,
class
Val>
98
forceinline
99
BrancherPrint<View,Val>::BrancherPrint
(
VarValPrint<Var,Val>
vvp) :
p
(vvp) {
100
if
(!vvp)
101
throw
Gecode::InvalidFunction
(
"BrancherPrint::BrancherPrint"
);
102
}
103
104
template
<
class
View,
class
Val>
105
forceinline
106
BrancherPrint<View,Val>::BrancherPrint
(
BrancherPrint<View,Val>
& bp)
107
:
p
(bp.
p
) {
108
}
109
110
template
<
class
View,
class
Val>
111
forceinline
112
BrancherPrint<View,Val>::operator
bool(
void
)
const
{
113
return
true
;
114
}
115
116
template
<
class
View,
class
Val>
117
forceinline
void
118
BrancherPrint<View,Val>::operator ()
(
const
Space
& home,
const
Brancher
&
b
,
119
unsigned
int
a
,
120
View
x
,
int
i
,
const
Val& m,
121
std::ostream& o)
const
{
122
GECODE_VALID_FUNCTION
(
p
());
123
Var
xv(
x
.
varimp
());
124
p
()(home,
b
,
a
,xv,
i
,m,o);
125
}
126
127
template
<
class
View,
class
Val>
128
forceinline
bool
129
BrancherPrint<View,Val>::notice
(
void
)
const
{
130
return
true
;
131
}
132
133
template
<
class
View,
class
Val>
134
forceinline
void
135
BrancherPrint<View,Val>::dispose
(
Space
&) {
136
p
.~SharedData<
VarValPrint<Var,Val>
>();
137
}
138
139
140
template
<
class
View,
class
Val>
141
forceinline
142
BrancherNoPrint<View,Val>::BrancherNoPrint
(
VarValPrint<Var,Val>
vvp) {
143
assert(!vvp);
144
(void) vvp;
145
}
146
147
template
<
class
View,
class
Val>
148
forceinline
149
BrancherNoPrint<View,Val>::BrancherNoPrint
(
BrancherNoPrint<View,Val>
&) {}
150
151
template
<
class
View,
class
Val>
152
forceinline
153
BrancherNoPrint<View,Val>::operator
bool(
void
)
const
{
154
return
false
;
155
}
156
157
template
<
class
View,
class
Val>
158
forceinline
void
159
BrancherNoPrint<View,Val>::operator ()
(
const
Space
&,
const
Brancher
&,
160
unsigned
int
,
161
View,
int
,
const
Val&,
162
std::ostream&)
const
{}
163
template
<
class
View,
class
Val>
164
forceinline
bool
165
BrancherNoPrint<View,Val>::notice
(
void
)
const
{
166
return
false
;
167
}
168
169
template
<
class
View,
class
Val>
170
forceinline
void
171
BrancherNoPrint<View,Val>::dispose
(
Space
&) {}
172
173
}
174
175
// STATISTICS: kernel-branch
Gecode::x
Post propagator for SetVar x
Definition:
set.hh:767
Gecode::BrancherNoPrint::Var
View::VarType Var
The corresponding variable type.
Definition:
print.hpp:76
Gecode::BrancherPrint::Var
View::VarType Var
The corresponding variable type.
Definition:
print.hpp:50
Gecode::BrancherNoPrint::operator()
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:159
Gecode::SharedData
Class for sharing data between spaces.
Definition:
shared-data.hpp:38
Gecode::BrancherNoPrint
Class without print function.
Definition:
print.hpp:73
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::BrancherNoPrint::dispose
void dispose(Space &home)
Delete.
Definition:
print.hpp:171
GECODE_VALID_FUNCTION
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition:
macros.hpp:94
Gecode::BrancherPrint::BrancherPrint
BrancherPrint(VarValPrint< Var, Val > vvp)
Initialize.
Definition:
print.hpp:99
Gecode::BrancherPrint
Class storing a print function.
Definition:
print.hpp:47
Gecode::Var
Base class for variables.
Definition:
var.hpp:40
Gecode
Gecode toplevel namespace
Gecode::BrancherPrint::dispose
void dispose(Space &home)
Delete.
Definition:
print.hpp:135
Gecode::BrancherPrint::p
SharedData< VarValPrint< Var, Val > > p
Definition:
print.hpp:52
Gecode::VarImpVar::varimp
VarImp * varimp(void) const
Return variable implementation of variable.
Definition:
var.hpp:96
Gecode::Brancher
Base-class for branchers.
Definition:
core.hpp:1442
Gecode::BrancherPrint::operator()
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:118
Gecode::BrancherPrint::notice
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition:
print.hpp:129
b
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
a
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
Gecode::InvalidFunction
Exception: invalid function
Definition:
exception.hpp:114
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::BrancherNoPrint::notice
bool notice(void) const
Whether dispose must always be called (that is, notice is needed)
Definition:
print.hpp:165
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::VarValPrint
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:43
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:232
Gecode::BrancherNoPrint::BrancherNoPrint
BrancherNoPrint(VarValPrint< Var, Val > vvp)
Initialize.
Definition:
print.hpp:142