Clio
develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
ManagedObject.hpp
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of clio: https://github.com/XRPLF/clio
4
Copyright (c) 2023, the clio developers.
5
6
Permission to use, copy, modify, and distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#pragma once
21
22
#include <memory>
23
#include <stdexcept>
24
25
namespace
data::cassandra::impl {
26
27
template
<
typename
Managed>
28
class
ManagedObject
{
29
protected
:
30
std::unique_ptr<Managed, void (*)(Managed*)> ptr_;
31
32
public
:
33
template
<
typename
DeleterCallable>
34
ManagedObject
(Managed* rawPtr, DeleterCallable deleter) : ptr_{rawPtr, deleter}
35
{
36
if
(rawPtr ==
nullptr
)
37
throw
std::runtime_error(
"Could not create DB object - got nullptr"
);
38
}
39
40
operator
Managed*()
const
41
{
42
return
ptr_.get();
43
}
44
};
45
46
}
// namespace data::cassandra::impl
data::cassandra::impl::ManagedObject
Definition
ManagedObject.hpp:28
src
data
cassandra
impl
ManagedObject.hpp
Generated by
1.12.0