Generated on Sat Oct 20 2018 12:43:45 for Gecode by doxygen 1.8.13
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  * 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 <gecode/int/ldsb.hh>
35 
36 namespace Gecode {
38  : ref(NULL) {}
40  : ref(o) {}
42  : ref(h.ref) {
43  if (ref != NULL)
44  increment();
45  }
46  const SymmetryHandle&
48  if (h.ref == ref)
49  return *this;
50  if (ref != NULL)
51  decrement();
52  ref = h.ref;
53  if (ref != NULL)
54  increment();
55  return *this;
56  }
58  if (ref != NULL)
59  decrement();
60  }
61  void
63  (ref->nrefs)++;
64  }
65  void
67  (ref->nrefs)--;
68  if (ref->nrefs == 0)
69  delete ref;
70  ref = NULL;
71  }
72 }
73 
74 namespace Gecode { namespace Int { namespace LDSB {
75 
77  : nrefs(1) {}
79 
81  nxs = vars.size();
82  xs = new VarImpBase*[nxs];
83  for (int i = 0 ; i < nxs ; i++)
84  xs[i] = vars[i];
85  }
87  delete [] xs;
88  }
89 
91  : values(vs) {}
92 
95  : seq_size(ss) {
96  nxs = x.size();
97  xs = new VarImpBase*[nxs];
98  for (int i = 0 ; i < nxs ; i++)
99  xs[i] = x[i];
100  }
102  delete [] xs;
103  }
104 
106  : values(vs), seq_size(ss) {}
107 
108 }}}
109 
110 // STATISTICS: int-branch
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1569
const SymmetryHandle & operator=(const SymmetryHandle &h)
Assignment operator.
Definition: sym-obj.cpp:47
Implementation of a symmetry at the modelling level.
Definition: ldsb.hh:106
VariableSymmetryObject(ArgArray< VarImpBase *> vars)
Constructor for creation.
Definition: sym-obj.cpp:80
Base-class for variable implementations.
Definition: core.hpp:171
int nxs
Number of variables in symmetry.
Definition: ldsb.hh:141
SymmetryObject(void)
Default constructor.
Definition: sym-obj.cpp:76
~SymmetryHandle(void)
Destructor.
Definition: sym-obj.cpp:57
Argument array for non-primitive types.
Definition: array.hpp:638
Gecode::IntArgs i({1, 2, 3, 4})
A reference-counted pointer to a SymmetryObject.
Definition: int.hh:5125
void decrement(void)
Decrement counter.
Definition: sym-obj.cpp:66
int seq_size
Size of each sequence in symmetry.
Definition: ldsb.hh:143
ValueSequenceSymmetryObject(IntArgs vs, int ss)
Constructor for creation.
Definition: sym-obj.cpp:105
Integer sets.
Definition: int.hh:174
VarImpBase ** xs
Array of variables in symmetry.
Definition: ldsb.hh:139
Passing integer arguments.
Definition: int.hh:628
VariableSequenceSymmetryObject(ArgArray< VarImpBase *> vars, int ss)
Constructor for creation.
Definition: sym-obj.cpp:94
virtual ~SymmetryObject(void)
Destructor.
Definition: sym-obj.cpp:78
ValueSymmetryObject(IntSet vs)
Constructor for creation.
Definition: sym-obj.cpp:90
Int::LDSB::SymmetryObject * ref
Symmetry object that this handle refers to.
Definition: int.hh:5128
void increment(void)
Increment counter.
Definition: sym-obj.cpp:62
void values(Home home, const IntVarArgs &x, IntSet y, IntPropLevel ipl=IPL_DEF)
Post constraint .
Definition: minimodel.hh:1993
Post propagator for SetVar x
Definition: set.hh:767
Gecode toplevel namespace
SymmetryHandle(void)
Default constructor.
Definition: sym-obj.cpp:37
int nrefs
Number of references that point to this symmetry object.
Definition: ldsb.hh:109