main page
modules
namespaces
classes
files
Gecode home
Generated on Fri Aug 24 2012 04:52:06 for Gecode by
doxygen
1.8.1.2
gecode
flatzinc
varspec.hh
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Guido Tack <tack@gecode.org>
5
*
6
* Copyright:
7
* Guido Tack, 2007
8
*
9
* Last modified:
10
* $Date: 2010-04-08 19:25:15 +1000 (Thu, 08 Apr 2010) $ by $Author: tack $
11
* $Revision: 10682 $
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
#ifndef __GECODE_FLATZINC_VARSPEC__HH__
39
#define __GECODE_FLATZINC_VARSPEC__HH__
40
41
#include <
gecode/flatzinc/option.hh
>
42
#include <
gecode/flatzinc/ast.hh
>
43
#include <vector>
44
#include <iostream>
45
46
namespace
Gecode {
namespace
FlatZinc {
47
49
class
Alias
{
50
public
:
51
const
int
v
;
52
Alias
(
int
v0) :
v
(v0) {}
53
};
54
56
class
VarSpec
{
57
public
:
59
bool
introduced
;
61
virtual
~VarSpec
(
void
) {}
63
int
i
;
65
bool
alias
;
67
bool
assigned
;
69
VarSpec
(
bool
introduced0) :
introduced
(introduced0) {}
70
};
71
73
class
IntVarSpec
:
public
VarSpec
{
74
public
:
75
Option<AST::SetLit* >
domain
;
76
IntVarSpec
(
const
Option<AST::SetLit* >
&
d
,
bool
introduced
)
77
:
VarSpec
(introduced) {
78
alias
=
false
;
79
assigned
=
false
;
80
domain
=
d
;
81
}
82
IntVarSpec
(
int
i0,
bool
introduced
) :
VarSpec
(introduced) {
83
alias
=
false
;
assigned
=
true
;
i
= i0;
84
}
85
IntVarSpec
(
const
Alias
& eq,
bool
introduced
) :
VarSpec
(introduced) {
86
alias
=
true
;
i
= eq.
v
;
87
}
88
~IntVarSpec
(
void
) {
89
if
(!
alias
&& !
assigned
&&
domain
())
90
delete
domain
.
some
();
91
}
92
};
93
95
class
BoolVarSpec
:
public
VarSpec
{
96
public
:
97
Option<AST::SetLit* >
domain
;
98
BoolVarSpec
(
Option<AST::SetLit* >
&
d
,
bool
introduced
)
99
:
VarSpec
(introduced) {
100
alias
=
false
;
assigned
=
false
;
domain
=
d
;
101
}
102
BoolVarSpec
(
bool
b
,
bool
introduced
) :
VarSpec
(introduced) {
103
alias
=
false
;
assigned
=
true
;
i
=
b
;
104
}
105
BoolVarSpec
(
const
Alias
& eq,
bool
introduced
) :
VarSpec
(introduced) {
106
alias
=
true
;
i
= eq.
v
;
107
}
108
~BoolVarSpec
(
void
) {
109
if
(!
alias
&& !
assigned
&&
domain
())
110
delete
domain
.
some
();
111
}
112
};
113
115
class
FloatVarSpec
:
public
VarSpec
{
116
public
:
117
Option<std::vector<double>
* >
domain
;
118
FloatVarSpec
(
Option
<std::vector<double>* >&
d
,
bool
introduced
)
119
:
VarSpec
(introduced) {
120
alias
=
false
;
assigned
=
false
;
domain
=
d
;
121
}
122
FloatVarSpec
(
bool
b
,
bool
introduced
) :
VarSpec
(introduced) {
123
alias
=
false
;
assigned
=
true
;
i
=
b
;
124
}
125
FloatVarSpec
(
const
Alias
& eq,
bool
introduced
) :
VarSpec
(introduced) {
126
alias
=
true
;
i
= eq.
v
;
127
}
128
~FloatVarSpec
(
void
) {
129
if
(!
alias
&& !
assigned
&&
domain
())
130
delete
domain
.
some
();
131
}
132
};
133
135
class
SetVarSpec
:
public
VarSpec
{
136
public
:
137
Option<AST::SetLit*>
upperBound
;
138
SetVarSpec
(
bool
introduced
) :
VarSpec
(introduced) {
139
alias
=
false
;
assigned
=
false
;
140
upperBound
=
Option<AST::SetLit* >::none
();
141
}
142
SetVarSpec
(
const
Option<AST::SetLit* >
&
v
,
bool
introduced
)
143
:
VarSpec
(introduced) {
144
alias
=
false
;
assigned
=
false
;
upperBound
=
v
;
145
}
146
SetVarSpec
(
AST::SetLit
*
v
,
bool
introduced
) :
VarSpec
(introduced) {
147
alias
=
false
;
assigned
=
true
;
148
upperBound
=
Option<AST::SetLit*>::some
(v);
149
}
150
SetVarSpec
(
const
Alias
& eq,
bool
introduced
) :
VarSpec
(introduced) {
151
alias
=
true
;
i
= eq.
v
;
152
}
153
~SetVarSpec
(
void
) {
154
if
(!
alias
&&
upperBound
())
155
delete
upperBound
.
some
();
156
}
157
};
158
159
}}
160
161
#endif
162
163
// STATISTICS: flatzinc-any