PMDK C++ bindings
1.5.2
This is the C++ bindings documentation for PMDK's libpmemobj.
Main Page
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
~
Functions
_
a
b
c
d
e
f
g
l
m
n
o
p
r
s
t
u
v
w
~
Variables
Typedefs
Related Functions
Files
File List
•
All
Classes
Files
Functions
Variables
Typedefs
Friends
Pages
libpmemobj++
experimental
v.hpp
Go to the documentation of this file.
1
/*
2
* Copyright 2018, Intel Corporation
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
7
*
8
* * Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
*
11
* * Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in
13
* the documentation and/or other materials provided with the
14
* distribution.
15
*
16
* * Neither the name of the copyright holder nor the names of its
17
* contributors may be used to endorse or promote products derived
18
* from this software without specific prior written permission.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
*/
32
38
#ifndef LIBPMEMOBJ_CPP_V_HPP
39
#define LIBPMEMOBJ_CPP_V_HPP
40
41
#include <memory>
42
43
#include <
libpmemobj++/detail/common.hpp
>
44
#include <
libpmemobj++/detail/volatile.hpp
>
45
46
namespace
pmem
47
{
48
49
namespace
obj
50
{
51
52
namespace
experimental
53
{
54
66
template
<
typename
T>
67
class
v
{
68
using
this_type
=
v<T>
;
69
70
template
<
typename
N>
71
friend
class
v
;
72
73
public
:
77
v
() noexcept : vlt{0}
78
{
79
}
80
84
v &
85
operator=
(
const
v
&rhs)
86
{
87
/* make sure object is initialized */
88
(void)
get
();
89
90
val = rhs.val;
91
92
return
*
this
;
93
}
94
98
v
&
99
operator=
(
const
T &rhs)
100
{
101
/* make sure object is initialized */
102
(void)
get
();
103
104
val = rhs;
105
106
return
*
this
;
107
}
108
114
template
<
typename
Y,
115
typename
=
typename
std::enable_if<
116
std::is_convertible<Y, T>::value>::type>
117
v
&
118
operator=
(
const
v<Y>
&rhs)
119
{
120
/* make sure object is initialized */
121
(void)
get
();
122
123
val = rhs.val;
124
125
return
*
this
;
126
}
127
134
T &
135
get
() noexcept
136
{
137
PMEMobjpool *pop = pmemobj_pool_by_ptr(
this
);
138
if
(pop == NULL)
139
return
this->val;
140
141
T *value =
static_cast<
T *
>
(pmemobj_volatile(
142
pop, &this->vlt, &this->val,
sizeof
(T),
143
pmem::detail::instantiate_volatile_object<T>, NULL));
144
145
return
*value;
146
}
147
151
operator
T &() noexcept
152
{
153
return
this->
get
();
154
}
155
159
void
160
swap
(
v
&other)
161
{
162
/* make sure object is initialized */
163
(void)
get
();
164
165
std::swap(this->val, other.val);
166
}
167
168
private
:
169
struct
pmemvlt vlt;
170
T val;
171
};
172
179
template
<
class
T>
180
inline
void
181
swap
(
v<T>
&a,
v<T>
&b)
182
{
183
a.
swap
(b);
184
}
185
186
}
/* namespace experimental */
187
188
}
/* namespace obj */
189
190
}
/* namespace pmem */
191
192
#endif
/* LIBPMEMOBJ_CPP_V_HPP */
pmem::obj::experimental::v::swap
void swap(v &other)
Swaps two v objects of the same type.
Definition:
v.hpp:160
pmem::obj::experimental::v::operator=
v & operator=(const T &rhs)
Assignment operator.
Definition:
v.hpp:99
common.hpp
Commonly used functionality.
pmem::obj::experimental::v::operator=
v & operator=(const v< Y > &rhs)
Converting assignment operator from a different v<>.
Definition:
v.hpp:118
pmem::obj::experimental::swap
void swap(pmem::obj::experimental::array< T, N > &lhs, pmem::obj::experimental::array< T, N > &rhs)
Non-member swap function.
Definition:
array.hpp:731
pmem::obj::experimental::v::get
T & get() noexcept
Retrieves reference of the object.
Definition:
v.hpp:135
pmem::obj::experimental::v::operator=
v & operator=(const v &rhs)
Assignment operator.
Definition:
v.hpp:85
volatile.hpp
Implementation details of volatile variables implementation.
pmem::obj::experimental::v
pmem::obj::experimental::v - volatile resides on pmem class.
Definition:
v.hpp:67
pmem::obj::experimental::v::v
v() noexcept
Defaulted constructor.
Definition:
v.hpp:77
Generated by
1.8.20