Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
when.cpp
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  *
6  * Copyright:
7  * Christian Schulte, 2009
8  *
9  * Last modified:
10  * $Date$ by $Author$
11  * $Revision$
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/exec.hh>
39 
40 namespace Gecode { namespace Int { namespace Exec {
41 
42  Actor*
43  When::copy(Space& home) {
44  return new (home) When(home,*this);
45  }
46 
49  if (x0.zero()) {
51  e()(home);
52  } else {
53  assert(x0.one());
55  t()(home);
56  }
57  if (home.failed())
58  return ES_FAILED;
59  return home.ES_SUBSUMED(*this);
60  }
61 
62  size_t
64  home.ignore(*this,AP_DISPOSE);
65  t.~SharedData<std::function<void(Space& home)>>();
66  e.~SharedData<std::function<void(Space& home)>>();
68  return sizeof(*this);
69  }
70 
71 }}}
72 
73 // STATISTICS: int-prop
74 
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: when.cpp:48
bool zero(void) const
Test whether view is assigned to be zero.
Definition: bool.hpp:214
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:3433
Actor must always be disposed.
Definition: core.hpp:554
When(Space &home, When &p)
Constructor for cloning p.
Definition: when.hpp:49
Unary propagator.
Definition: pattern.hpp:59
bool one(void) const
Test whether view is assigned to be one.
Definition: bool.hpp:218
SharedData< std::function< void(Space &home)> > t
Then function.
Definition: exec.hh:60
Computation spaces.
Definition: core.hpp:1668
Base-class for both propagators and branchers.
Definition: core.hpp:620
virtual size_t dispose(Space &home)
Dispose propagator.
Definition: when.cpp:63
Execution has resulted in failure.
Definition: core.hpp:466
bool failed(void) const
Check whether space is failed.
Definition: core.hpp:3914
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: when.cpp:43
SharedData< std::function< void(Space &home)> > e
Else function pointer.
Definition: exec.hh:62
#define GECODE_VALID_FUNCTION(f)
Assert that a function is valid.
Definition: macros.hpp:98
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Definition: core.hpp:3944
ExecStatus
Definition: core.hpp:464
Gecode toplevel namespace
int ModEventDelta
Modification event deltas.
Definition: core.hpp:91