Generated on Sat Feb 7 2015 02:01:23 for Gecode by doxygen 1.8.9.1
idx-view.hh
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  * Guido Tack <tack@gecode.org>
6  *
7  * Copyright:
8  * Christian Schulte, 2004
9  * Guido Tack, 2004
10  *
11  * Last modified:
12  * $Date: 2015-01-16 14:10:48 +0100 (Fri, 16 Jan 2015) $ by $Author: schulte $
13  * $Revision: 14362 $
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 #ifndef __GECODE_INT_IDX_VIEW_HH__
41 #define __GECODE_INT_IDX_VIEW_HH__
42 
43 #include <gecode/int.hh>
44 
45 namespace Gecode { namespace Int {
46 
51  template<class View>
52  class IdxView {
53  public:
55  int idx;
57  View view;
59  static IdxView* allocate(Space& home, int n);
60  };
61 
63  template<class View>
64  class ViewToVarArg {};
65 
70  template<class View>
71  class IdxViewArray {
72  private:
74  IdxView<View>* xs;
76  int n;
77  public:
79  IdxViewArray(void);
83  IdxViewArray(Space& home, const typename ViewToVarArg<View>::argtype& x);
85  IdxViewArray(Space& home, int n);
86 
88  int size(void) const;
90  void size(int n);
91 
93  IdxView<View>& operator [](int n);
95  const IdxView<View>& operator [](int) const;
96 
101  void subscribe(Space& home, Propagator& p, PropCond pc, bool process=true);
106  void cancel(Space& home, Propagator& p, PropCond pc);
107 
109  void update(Space& home, bool share, IdxViewArray<View>& x);
110  };
111 
116  template<class Char, class Traits, class View>
117  std::basic_ostream<Char,Traits>&
118  operator <<(std::basic_ostream<Char,Traits>& os,
119  const IdxViewArray<View>& x);
120 
121 }}
122 
123 #include <gecode/int/idx-view.hpp>
124 
125 #endif
126 
127 
128 // STATISTICS: int-prop
129 
IdxView< View > & operator[](int n)
Access element n.
Definition: idx-view.hpp:115
Base-class for propagators.
Definition: core.hpp:755
static IdxView * allocate(Space &home, int n)
Allocate memory for n index-view pairs.
Definition: idx-view.hpp:65
Computation spaces.
Definition: core.hpp:1362
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
View view
Thhe view.
Definition: idx-view.hh:57
void cancel(Space &home, Propagator &p, PropCond pc)
Definition: idx-view.hpp:137
int PropCond
Type for propagation conditions.
Definition: core.hpp:156
int idx
The index.
Definition: idx-view.hh:55
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
void subscribe(Space &home, Propagator &p, PropCond pc, bool process=true)
Definition: idx-view.hpp:129
IdxViewArray(void)
Default constructor.
Definition: idx-view.hpp:71
An array of IdxView pairs.
Definition: idx-view.hh:71
Gecode toplevel namespace
Class to map VarArg type to view.
Definition: idx-view.hh:64
Class for pair of index and view.
Definition: idx-view.hh:52
int size(void) const
Return the current size.
Definition: idx-view.hpp:103
void update(Space &home, bool share, IdxViewArray< View > &x)
Cloning.
Definition: idx-view.hpp:144