NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
cf-releaser-osx.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2019 Regents of the University of California.
4
*
5
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6
*
7
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU Lesser General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later version.
10
*
11
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14
*
15
* You should have received copies of the GNU General Public License and GNU Lesser
16
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17
* <http://www.gnu.org/licenses/>.
18
*
19
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20
*/
21
22
#ifndef NDN_DETAIL_CF_RELEASER_OSX_HPP
23
#define NDN_DETAIL_CF_RELEASER_OSX_HPP
24
25
#include "
ndn-cxx/detail/common.hpp
"
26
27
#ifndef NDN_CXX_HAVE_OSX_FRAMEWORKS
28
#error "This file should not be included ..."
29
#endif
30
31
#include <CoreFoundation/CoreFoundation.h>
32
33
namespace
ndn
{
34
namespace
detail {
35
48
template
<
class
T>
49
class
CFReleaser
50
{
51
public
:
// Construction/destruction
52
CFReleaser
()
53
: m_typeRef(nullptr)
54
{
55
}
56
57
CFReleaser
(
const
T& typeRef)
58
: m_typeRef(typeRef)
59
{
60
}
61
62
CFReleaser
(
const
CFReleaser
& inReleaser)
63
: m_typeRef(nullptr)
64
{
65
retain
(inReleaser.m_typeRef);
66
}
67
68
CFReleaser
&
69
operator=
(
const
T& typeRef)
70
{
71
if
(typeRef != m_typeRef) {
72
release
();
73
m_typeRef = typeRef;
74
}
75
return
*
this
;
76
}
77
78
CFReleaser
&
79
operator=
(
const
CFReleaser
& inReleaser)
80
{
81
retain
(inReleaser.m_typeRef);
82
return
*
this
;
83
}
84
85
~CFReleaser
()
86
{
87
release
();
88
}
89
90
public
:
// Access
91
const
T&
92
get
()
const
93
{
94
return
m_typeRef;
95
}
96
97
T&
98
get
()
99
{
100
return
m_typeRef;
101
}
102
103
public
:
// Miscellaneous
104
void
105
retain
(
const
T& typeRef)
106
{
107
if
(typeRef !=
nullptr
) {
108
CFRetain(typeRef);
109
}
110
release
();
111
m_typeRef = typeRef;
112
}
113
114
void
115
retain
()
116
{
117
T typeRef = m_typeRef;
118
m_typeRef =
nullptr
;
119
retain
(typeRef);
120
}
121
122
void
123
release
()
124
{
125
if
(m_typeRef !=
nullptr
) {
126
CFRelease(m_typeRef);
127
m_typeRef =
nullptr
;
128
}
129
}
130
131
private
:
// Comparison with nullptr
132
friend
bool
133
operator==
(
const
CFReleaser
& lhs, std::nullptr_t)
134
{
135
return
lhs.m_typeRef ==
nullptr
;
136
}
137
138
friend
bool
139
operator!=
(
const
CFReleaser
& lhs, std::nullptr_t)
140
{
141
return
lhs.m_typeRef !=
nullptr
;
142
}
143
144
private
:
145
T m_typeRef;
146
};
147
148
}
// namespace detail
149
}
// namespace ndn
150
151
#endif // NDN_DETAIL_CF_RELEASER_OSX_HPP
ndn::detail::CFReleaser::retain
void retain(const T &typeRef)
Definition:
cf-releaser-osx.hpp:105
common.hpp
Common includes and macros used throughout the library.
ndn::detail::CFReleaser::release
void release()
Definition:
cf-releaser-osx.hpp:123
ndn::detail::CFReleaser::retain
void retain()
Definition:
cf-releaser-osx.hpp:115
ndn::detail::CFReleaser::operator=
CFReleaser & operator=(const CFReleaser &inReleaser)
Definition:
cf-releaser-osx.hpp:79
ndn::detail::CFReleaser::operator=
CFReleaser & operator=(const T &typeRef)
Definition:
cf-releaser-osx.hpp:69
ndn::detail::CFReleaser
Helper class to wrap CoreFoundation object pointers.
Definition:
cf-releaser-osx.hpp:50
ndn::detail::CFReleaser::~CFReleaser
~CFReleaser()
Definition:
cf-releaser-osx.hpp:85
ndn::detail::CFReleaser::CFReleaser
CFReleaser(const CFReleaser &inReleaser)
Definition:
cf-releaser-osx.hpp:62
ndn::detail::CFReleaser::get
T & get()
Definition:
cf-releaser-osx.hpp:98
ndn::detail::CFReleaser::operator!=
friend bool operator!=(const CFReleaser &lhs, std::nullptr_t)
Definition:
cf-releaser-osx.hpp:139
ndn::detail::CFReleaser::CFReleaser
CFReleaser(const T &typeRef)
Definition:
cf-releaser-osx.hpp:57
ndn::detail::CFReleaser::get
const T & get() const
Definition:
cf-releaser-osx.hpp:92
ndn::detail::CFReleaser::CFReleaser
CFReleaser()
Definition:
cf-releaser-osx.hpp:52
ndn::detail::CFReleaser::operator==
friend bool operator==(const CFReleaser &lhs, std::nullptr_t)
Definition:
cf-releaser-osx.hpp:133
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndnSIM
ndn-cxx
ndn-cxx
detail
cf-releaser-osx.hpp
Generated on Mon Jun 1 2020 22:32:14 for ndnSIM by
1.8.18