main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Nov 9 2013 19:18:30 for Gecode by
doxygen
1.8.4
gecode
kernel
brancher-val-sel-commit.hpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main author:
4
* Christian Schulte <schulte@gecode.org>
5
*
6
* Copyright:
7
* Christian Schulte, 2012
8
*
9
* Last modified:
10
* $Date: 2013-07-04 17:03:13 +0200 (Thu, 04 Jul 2013) $ by $Author: schulte $
11
* $Revision: 13801 $
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
namespace
Gecode {
39
46
template
<
class
_View,
class
_Val>
48
class
ValSelCommitBase
{
49
public
:
51
typedef
_View
View
;
53
typedef
_Val
Val
;
54
public
:
56
ValSelCommitBase
(
Space
& home,
const
ValBranch
& vb);
58
ValSelCommitBase
(
Space
& home,
bool
shared
,
59
ValSelCommitBase<View,Val>
& vsc);
61
virtual
Val
val
(
const
Space
& home,
View
x
,
int
i
) = 0;
63
virtual
ModEvent
commit
(
Space
& home,
unsigned
int
a
,
64
View
x
,
int
i
,
Val
n
) = 0;
66
virtual
NGL
*
ngl
(
Space
& home,
unsigned
int
a
,
67
View
x
,
Val
n
)
const
= 0;
69
virtual
void
print
(
const
Space
& home,
unsigned
int
a
,
70
View
x
,
int
i
,
const
Val
&
n
,
71
std::ostream& o)
const
= 0;
73
virtual
ValSelCommitBase<View,Val>
*
copy
(
Space
& home,
bool
shared
) = 0;
75
virtual
bool
notice
(
void
)
const
= 0;
77
virtual
void
dispose
(
Space
& home) = 0;
79
80
static
void
*
operator
new
(
size_t
s,
Space
& home);
83
static
void
operator
delete
(
void
*
p
,
Space
& home);
85
static
void
operator
delete
(
void
*
p
);
87
};
88
90
template
<
class
ValSel,
class
ValCommit>
91
class
ValSelCommit
92
:
public
ValSelCommitBase
<typename ValSel::View,typename ValSel::Val> {
93
protected
:
94
typedef
typename
ValSelCommitBase
<
typename
ValSel::View
,
95
typename
ValSel::Val
>
::Val
Val
;
96
typedef
typename
ValSelCommitBase
<
typename
ValSel::View
,
97
typename
ValSel::Val
>
::View
View
;
99
ValSel
s
;
101
ValCommit
c
;
102
public
:
104
ValSelCommit
(
Space
& home,
const
ValBranch
& vb);
106
ValSelCommit
(
Space
& home,
bool
shared
,
107
ValSelCommit<ValSel,ValCommit>
& vsc);
109
virtual
Val
val
(
const
Space
& home,
View
x
,
int
i
);
111
virtual
ModEvent
commit
(
Space
& home,
unsigned
int
a
,
View
x
,
int
i
,
Val
n
);
113
virtual
NGL
*
ngl
(
Space
& home,
unsigned
int
a
,
114
View
x
,
Val
n
)
const
;
116
virtual
void
print
(
const
Space
& home,
unsigned
int
a
,
117
View
x
,
int
i
,
const
Val
&
n
,
118
std::ostream& o)
const
;
120
virtual
ValSelCommit<ValSel,ValCommit>
*
copy
(
Space
& home,
bool
shared
);
122
virtual
bool
notice
(
void
)
const
;
124
virtual
void
dispose
(
Space
& home);
125
};
127
128
129
template
<
class
View,
class
Val>
130
forceinline
131
ValSelCommitBase<View,Val>::ValSelCommitBase
(
Space
&,
const
ValBranch
&) {}
132
template
<
class
View,
class
Val>
133
forceinline
134
ValSelCommitBase<View,Val>::
135
ValSelCommitBase
(
Space
&,
bool
,
ValSelCommitBase<View,Val>
&) {}
136
137
template
<
class
View,
class
Val>
138
forceinline
void
139
ValSelCommitBase<View,Val>::operator
delete
(
void
*) {}
140
template
<
class
View,
class
Val>
141
forceinline
void
142
ValSelCommitBase<View,Val>::operator
delete
(
void
*,
Space
&) {}
143
template
<
class
View,
class
Val>
144
forceinline
void
*
145
ValSelCommitBase<View,Val>::operator
new
(
size_t
s,
Space
& home) {
146
return
home.ralloc(s);
147
}
148
149
150
151
152
template
<
class
ValSel,
class
ValCommit>
153
forceinline
154
ValSelCommit<ValSel,ValCommit>::ValSelCommit
(
Space
& home,
155
const
ValBranch
& vb)
156
:
ValSelCommitBase
<
View
,
Val
>(home,vb), s(home,vb),
c
(home,vb) {}
157
158
template
<
class
ValSel,
class
ValCommit>
159
forceinline
160
ValSelCommit<ValSel,ValCommit>::ValSelCommit
(
Space
& home,
bool
shared
,
161
ValSelCommit<ValSel,ValCommit>
& vsc)
162
:
ValSelCommitBase
<
View
,
Val
>(home,shared,vsc),
163
s(home,shared,vsc.s),
c
(home,shared,vsc.
c
) {}
164
165
template
<
class
ValSel,
class
ValCommit>
166
typename
ValSelCommit<ValSel,ValCommit>::Val
167
ValSelCommit<ValSel,ValCommit>::val
(
const
Space
& home,
View
x
,
int
i
) {
168
return
s.val(home,x,i);
169
}
170
171
template
<
class
ValSel,
class
ValCommit>
172
ModEvent
173
ValSelCommit<ValSel,ValCommit>::commit
(
Space
& home,
unsigned
int
a
,
174
View
x
,
int
i
,
Val
n
) {
175
return
c
.commit(home,a,x,i,n);
176
}
177
178
template
<
class
ValSel,
class
ValCommit>
179
NGL
*
180
ValSelCommit<ValSel,ValCommit>::ngl
(
Space
& home,
unsigned
int
a
,
181
View
x
,
Val
n
)
const
{
182
return
c
.ngl(home, a, x, n);
183
}
184
185
template
<
class
ValSel,
class
ValCommit>
186
void
187
ValSelCommit<ValSel,ValCommit>::print
(
const
Space
& home,
unsigned
int
a
,
188
View
x
,
int
i
,
const
Val
&
n
,
189
std::ostream& o)
const
{
190
c
.print(home,a,x,i,n,o);
191
}
192
193
template
<
class
ValSel,
class
ValCommit>
194
ValSelCommit<ValSel,ValCommit>
*
195
ValSelCommit<ValSel,ValCommit>::copy
(
Space
& home,
bool
shared
) {
196
return
new
(home)
ValSelCommit<ValSel,ValCommit>
(home,shared,*
this
);
197
}
198
199
template
<
class
ValSel,
class
ValCommit>
200
bool
201
ValSelCommit<ValSel,ValCommit>::notice
(
void
)
const
{
202
return
s.notice() ||
c
.notice();
203
}
204
205
template
<
class
ValSel,
class
ValCommit>
206
void
207
ValSelCommit<ValSel,ValCommit>::dispose
(
Space
& home) {
208
s.dispose(home);
209
c
.dispose(home);
210
}
211
212
}
213
214
// STATISTICS: kernel-branch