PMDK C++ bindings
1.10
This is the C++ bindings documentation for PMDK's libpmemobj.
libpmemobj++
utils.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSD-3-Clause
2
/* Copyright 2016-2019, Intel Corporation */
3
8
#ifndef LIBPMEMOBJ_CPP_UTILS_HPP
9
#define LIBPMEMOBJ_CPP_UTILS_HPP
10
11
#include <
libpmemobj++/persistent_ptr.hpp
>
12
#include <
libpmemobj++/pexceptions.hpp
>
13
#include <libpmemobj/base.h>
14
15
namespace
pmem
16
{
17
18
namespace
obj
19
{
20
30
template
<
typename
T>
31
inline
pool_base
32
pool_by_vptr
(
const
T *that)
33
{
34
auto
pop = pmemobj_pool_by_ptr(that);
35
if
(!pop)
36
throw
pmem::pool_error
(
"Object not in an open pool."
);
37
38
return
pool_base
(pop);
39
}
40
50
template
<
typename
T>
51
inline
pool_base
52
pool_by_pptr
(
const
persistent_ptr<T>
ptr)
53
{
54
auto
pop = pmemobj_pool_by_oid(ptr.raw());
55
if
(!pop)
56
throw
pmem::pool_error
(
"Object not in an open pool."
);
57
58
return
pool_base
(pop);
59
}
60
61
}
/* namespace obj */
62
63
}
/* namespace pmem */
64
65
#endif
/* LIBPMEMOBJ_CPP_UTILS_HPP */
pmem::pool_error
Custom pool error class.
Definition:
pexceptions.hpp:45
pmem
Persistent memory namespace.
Definition:
allocation_flag.hpp:14
pexceptions.hpp
pmem::obj::pool_by_pptr
pool_base pool_by_pptr(const persistent_ptr< T > ptr)
Retrieve pool handle for the given persistent_ptr.
Definition:
utils.hpp:52
pmem::obj::persistent_ptr
Persistent pointer class.
Definition:
common.hpp:108
pmem::obj::pool_by_vptr
pool_base pool_by_vptr(const T *that)
Retrieve pool handle for the given pointer.
Definition:
utils.hpp:32
pmem::obj::pool_base
The non-template pool base class.
Definition:
pool.hpp:46
persistent_ptr.hpp
Generated by
1.8.17