blob: baa343a529a904369016f9853da0f1b44e9687a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef DNS_RDATA_PIMPL_HOLDER_H
#define DNS_RDATA_PIMPL_HOLDER_H 1
#include <boost/noncopyable.hpp>
#include <cstddef> // for NULL
namespace isc {
namespace dns {
namespace rdata {
template <typename T>
class RdataPimplHolder : boost::noncopyable {
public:
RdataPimplHolder(T* obj = NULL) :
obj_(obj)
{}
~RdataPimplHolder() {
delete obj_;
}
void reset(T* obj = NULL) {
delete obj_;
obj_ = obj;
}
T* get() {
return (obj_);
}
T* release() {
T* obj = obj_;
obj_ = NULL;
return (obj);
}
private:
T* obj_;
};
} // namespace rdata
} // namespace dns
} // namespace isc
#endif // DNS_RDATA_PIMPL_HOLDER_H
|