LMMS
Loading...
Searching...
No Matches
juce_mac_CFHelpers.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23/* This file contains a few helper functions that are used internally but which
24 need to be kept away from the public headers because they use obj-C symbols.
25*/
26namespace juce
27{
28
29template <typename CFType>
31{
32 void operator() (CFType object) const noexcept
33 {
34 if (object != nullptr)
35 CFRelease (object);
36 }
37};
38
39template <typename CFType>
40using CFUniquePtr = std::unique_ptr<typename std::remove_pointer<CFType>::type, CFObjectDeleter<CFType>>;
41
42template <typename CFType>
44{
45 CFObjectHolder() = default;
46 explicit CFObjectHolder (CFType obj) : object (obj) {}
47
48 CFObjectHolder (const CFObjectHolder&) = delete;
50
51 CFObjectHolder& operator= (const CFObjectHolder&) = delete;
52 CFObjectHolder& operator= (CFObjectHolder&&) = delete;
53
55 {
56 if (object != nullptr)
57 CFRelease (object);
58 }
59
60 // Public to facilitate passing the pointer address to functions
61 CFType object = nullptr;
62};
63
64} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition carla_juce.cpp:31
std::unique_ptr< typename std::remove_pointer< CFType >::type, CFObjectDeleter< CFType > > CFUniquePtr
Definition juce_mac_CFHelpers.h:40
Definition juce_mac_CFHelpers.h:31
CFObjectHolder(CFObjectHolder &&)=delete
CFObjectHolder(CFType obj)
Definition juce_mac_CFHelpers.h:46
CFObjectHolder(const CFObjectHolder &)=delete
CFType object
Definition juce_mac_CFHelpers.h:61
CFObjectHolder()=default
~CFObjectHolder() noexcept
Definition juce_mac_CFHelpers.h:54