Generated on Sat Feb 7 2015 02:01:24 for Gecode by doxygen 1.8.9.1
sym-obj.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christopher Mears <chris.mears@monash.edu>
5  *
6  * Copyright:
7  * Christopher Mears, 2012
8  *
9  * Last modified:
10  * $Date: 2013-03-07 17:39:13 +0100 (Thu, 07 Mar 2013) $ by $Author: schulte $
11  * $Revision: 13458 $
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 <gecode/int/ldsb.hh>
39 
40 namespace Gecode {
42  : ref(NULL) {}
44  : ref(o) {}
46  : ref(h.ref) {
47  if (ref != NULL)
48  increment();
49  }
50  const SymmetryHandle&
52  if (h.ref == ref)
53  return *this;
54  if (ref != NULL)
55  decrement();
56  ref = h.ref;
57  if (ref != NULL)
58  increment();
59  return *this;
60  }
62  if (ref != NULL)
63  decrement();
64  }
65  void
67  (ref->nrefs)++;
68  }
69  void
71  (ref->nrefs)--;
72  if (ref->nrefs == 0)
73  delete ref;
74  ref = NULL;
75  }
76 }
77 
78 namespace Gecode { namespace Int { namespace LDSB {
79 
81  : nrefs(1) {}
83 
85  nxs = vars.size();
86  xs = new VarImpBase*[nxs];
87  for (int i = 0 ; i < nxs ; i++)
88  xs[i] = vars[i];
89  }
91  delete [] xs;
92  }
93 
95  : values(vs) {}
96 
99  : seq_size(ss) {
100  nxs = x.size();
101  xs = new VarImpBase*[nxs];
102  for (int i = 0 ; i < nxs ; i++)
103  xs[i] = x[i];
104  }
106  delete [] xs;
107  }
108 
110  : values(vs), seq_size(ss) {}
111 
112 }}}
113 
114 // STATISTICS: int-branch
VariableSequenceSymmetryObject(ArgArray< VarImpBase * > vars, int ss)
Constructor for creation.
Definition: sym-obj.cpp:98
VarImpBase ** xs
Array of variables in symmetry.
Definition: ldsb.hh:123
const SymmetryHandle & operator=(const SymmetryHandle &h)
Assignment operator.
Definition: sym-obj.cpp:51
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1662
Implementation of a symmetry at the modelling level.
Definition: ldsb.hh:110
Base-class for variable implementations.
Definition: core.hpp:243
int nxs
Number of variables in symmetry.
Definition: ldsb.hh:145
SymmetryObject(void)
Default constructor.
Definition: sym-obj.cpp:80
~SymmetryHandle(void)
Destructor.
Definition: sym-obj.cpp:61
Gecode::IntArgs i(4, 1, 2, 3, 4)
Argument array for non-primitive types.
Definition: array.hpp:727
A reference-counted pointer to a SymmetryObject.
Definition: int.hh:4263
void decrement(void)
Decrement counter.
Definition: sym-obj.cpp:70
int nxs
Number of variables in symmetry.
Definition: ldsb.hh:125
ValueSequenceSymmetryObject(IntArgs vs, int ss)
Constructor for creation.
Definition: sym-obj.cpp:109
Integer sets.
Definition: int.hh:171
VarImpBase ** xs
Array of variables in symmetry.
Definition: ldsb.hh:143
Passing integer arguments.
Definition: int.hh:607
virtual ~SymmetryObject(void)
Destructor.
Definition: sym-obj.cpp:82
void values(Home home, const IntVarArgs &x, IntSet y, IntConLevel icl=ICL_DEF)
Post constraint .
Definition: minimodel.hh:1869
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
VariableSymmetryObject(ArgArray< VarImpBase * > vars)
Constructor for creation.
Definition: sym-obj.cpp:84
ValueSymmetryObject(IntSet vs)
Constructor for creation.
Definition: sym-obj.cpp:94
Int::LDSB::SymmetryObject * ref
Symmetry object that this handle refers to.
Definition: int.hh:4266
void increment(void)
Increment counter.
Definition: sym-obj.cpp:66
Gecode toplevel namespace
SymmetryHandle(void)
Default constructor.
Definition: sym-obj.cpp:41
int nrefs
Number of references that point to this symmetry object.
Definition: ldsb.hh:113