Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
btraii.mm
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "btraii_p.h"
5
6#include <qdebug.h>
7
8#include <Foundation/Foundation.h>
9
10#include <utility>
11
13
14namespace DarwinBluetooth {
15
17 : objCInstance(object)
18{
19 if (objCInstance && policy == RetainPolicy::doInitialRetain)
20 objCInstance = [getAs<NSObject>() retain];
21}
22
24{
25 if ((objCInstance = other.getAs<NSObject>()))
26 objCInstance = [other.getAs<NSObject>() retain];
27}
28
30{
31 std::swap(objCInstance, other.objCInstance);
32}
33
35{
36 [getAs<NSObject>() release];
37}
38
40{
41 if (this != &other) {
42 [getAs<NSObject>() release];
43 objCInstance = [other.getAs<NSObject>() retain];
44 }
45
46 return *this;
50{
51 swap(other);
52
53 return *this;
54}
55
57{
58 void *released = objCInstance;
59 objCInstance = nullptr;
60
61 return released;
62}
63
65{
66 [getAs<NSObject>() release];
67 objCInstance = nullptr;
68}
69
70void StrongReference::reset(void *obj, RetainPolicy policy)
71{
72 [getAs<NSObject>() release];
73 objCInstance = obj;
74
75 if (objCInstance && policy == RetainPolicy::doInitialRetain)
76 objCInstance = [getAs<NSObject>() retain];
77}
78
79} // namespace DarwinBluetooth
80
81QT_END_NAMESPACE
StrongReference & operator=(StrongReference &&other) noexcept
Definition btraii.mm:49
StrongReference & operator=(const StrongReference &other) noexcept
Definition btraii.mm:39
StrongReference(void *object, RetainPolicy policy)
Definition btraii.mm:16
void reset(void *newInstance, RetainPolicy policy)
Definition btraii.mm:70
StrongReference(StrongReference &&other)
Definition btraii.mm:29
void swap(StrongReference &other) noexcept
Definition btraii_p.h:56
StrongReference(const StrongReference &other)
Definition btraii.mm:23
Combined button and popup list for selecting options.