main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Jan 28 2020 00:00:00 for Gecode by
doxygen
1.8.17
gecode
kernel
shared-data.hpp
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, 2017
8
*
9
* Last modified:
10
* $Date: 2017-02-10 02:39:13 +0100 (Fri, 10 Feb 2017) $ by $Author: schulte $
11
* $Revision: 15401 $
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
namespace
Gecode
{
39
41
template
<
class
Data>
42
class
SharedData
:
public
SharedHandle
{
43
protected
:
45
class
SDO
:
public
SharedHandle::Object
{
46
public
:
48
const
Data
d
;
50
SDO
(
const
Data& d0);
52
SDO
(
const
SDO
& sdo);
54
virtual
Object
*
copy
(
void
)
const
;
56
virtual
~SDO
(
void
);
57
};
58
public
:
60
SharedData
(
const
Data&
d
);
62
SharedData
(
void
);
64
SharedData
(
const
SharedData
& sd);
66
SharedData
&
operator =
(
const
SharedData
& sd);
68
const
Data&
operator ()
(
void
)
const
;
70
void
update
(
Space
& home,
bool
share,
SharedHandle
& sh);
72
~SharedData
(
void
);
73
};
74
75
76
template
<
class
Data>
77
forceinline
78
SharedData<Data>::SDO::SDO
(
const
Data& d0)
79
:
d
(d0) {}
80
81
template
<
class
Data>
82
forceinline
83
SharedData<Data>::SDO::SDO
(
const
SDO
& sdo)
84
:
d
(sdo.
d
) {}
85
86
template
<
class
Data>
87
forceinline
SharedHandle::Object
*
88
SharedData<Data>::SDO::copy
(
void
)
const
{
89
return
new
SDO
(*
this
);
90
}
91
92
template
<
class
Data>
93
forceinline
94
SharedData<Data>::SDO::~SDO
(
void
) {}
95
96
97
template
<
class
Data>
98
forceinline
99
SharedData<Data>::SharedData
(
const
Data&
d
)
100
:
SharedHandle
(new SDO(
d
)) {}
101
102
template
<
class
Data>
103
forceinline
104
SharedData<Data>::SharedData
(
void
) {}
105
106
template
<
class
Data>
107
forceinline
108
SharedData<Data>::SharedData
(
const
SharedData<Data>
& sd)
109
:
SharedHandle
(sd) {}
110
111
template
<
class
Data>
112
forceinline
SharedData<Data>
&
113
SharedData<Data>::operator =
(
const
SharedData<Data>
& sd) {
114
return
static_cast<
SharedData
&
>
(SharedHandle::operator =(sd));
115
}
116
117
template
<
class
Data>
118
forceinline
const
Data&
119
SharedData<Data>::operator ()
(
void
)
const
{
120
return
static_cast<
SDO*
>
(object())->
d
;
121
}
122
123
template
<
class
Data>
124
forceinline
void
125
SharedData<Data>::update
(
Space
& home,
bool
share,
SharedHandle
& sh) {
126
SharedHandle::update(home,share,sh);
127
}
128
129
template
<
class
Data>
130
forceinline
131
SharedData<Data>::~SharedData
(
void
) {}
132
133
}
134
135
// STATISTICS: kernel-other
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::SharedData
Class for sharing data between spaces.
Definition:
shared-data.hpp:42
Gecode::SharedData::update
void update(Space &home, bool share, SharedHandle &sh)
Update during cloning.
Definition:
shared-data.hpp:125
Gecode::SharedHandle::Object
The shared object.
Definition:
core.hpp:88
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::SharedData::SDO::~SDO
virtual ~SDO(void)
Destructor.
Definition:
shared-data.hpp:94
Gecode::SharedData::operator()
const Data & operator()(void) const
Provide access to data.
Definition:
shared-data.hpp:119
Gecode::SharedData::operator=
SharedData & operator=(const SharedData &sd)
Assignment operator.
Definition:
shared-data.hpp:113
Gecode
Gecode toplevel namespace
Gecode::SharedData::SDO::copy
virtual Object * copy(void) const
Create new non-shared copy.
Definition:
shared-data.hpp:88
Gecode::SharedData::SDO::d
const Data d
Data to be shared.
Definition:
shared-data.hpp:48
Gecode::SharedData::SDO
The object storing the actual data.
Definition:
shared-data.hpp:45
Test::Int::Distinct::d
Gecode::IntSet d(v, 7)
Gecode::SharedData::SharedData
SharedData(void)
Create as uninitialized.
Definition:
shared-data.hpp:104
Gecode::SharedHandle
The shared handle.
Definition:
core.hpp:79
Gecode::SharedData::~SharedData
~SharedData(void)
Destructors.
Definition:
shared-data.hpp:131
Gecode::SharedData::SDO::SDO
SDO(const Data &d0)
Initialization.
Definition:
shared-data.hpp:78