]> git.saurik.com Git - apple/cf.git/blob - CFPlugIn.h
CF-1153.18.tar.gz
[apple/cf.git] / CFPlugIn.h
1 /*
2 * Copyright (c) 2015 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /* CFPlugIn.h
25 Copyright (c) 1999-2014, Apple Inc. All rights reserved.
26 */
27
28 #if !defined(__COREFOUNDATION_CFPLUGIN__)
29 #define __COREFOUNDATION_CFPLUGIN__ 1
30
31 #if !defined(COREFOUNDATION_CFPLUGINCOM_SEPARATE)
32 #define COREFOUNDATION_CFPLUGINCOM_SEPARATE 1
33 #endif
34
35 #include <CoreFoundation/CFBase.h>
36 #include <CoreFoundation/CFArray.h>
37 #include <CoreFoundation/CFBundle.h>
38 #include <CoreFoundation/CFString.h>
39 #include <CoreFoundation/CFURL.h>
40 #include <CoreFoundation/CFUUID.h>
41
42 CF_IMPLICIT_BRIDGING_ENABLED
43 CF_EXTERN_C_BEGIN
44
45 /* ================ Standard Info.plist keys for plugIns ================ */
46
47 CF_EXPORT const CFStringRef kCFPlugInDynamicRegistrationKey;
48 CF_EXPORT const CFStringRef kCFPlugInDynamicRegisterFunctionKey;
49 CF_EXPORT const CFStringRef kCFPlugInUnloadFunctionKey;
50 CF_EXPORT const CFStringRef kCFPlugInFactoriesKey;
51 CF_EXPORT const CFStringRef kCFPlugInTypesKey;
52
53 /* ================= Function prototypes for various callbacks ================= */
54 /* Function types that plugIn authors can implement for various purposes. */
55
56 typedef void (*CFPlugInDynamicRegisterFunction)(CFPlugInRef plugIn);
57 typedef void (*CFPlugInUnloadFunction)(CFPlugInRef plugIn);
58 typedef void *(*CFPlugInFactoryFunction)(CFAllocatorRef allocator, CFUUIDRef typeUUID);
59
60 /* ================= Creating PlugIns ================= */
61
62 CF_EXPORT CFTypeID CFPlugInGetTypeID(void);
63
64 CF_EXPORT CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL);
65 /* Might return an existing instance with the ref-count bumped. */
66
67 CF_EXPORT CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn);
68
69 /* ================= Controlling load on demand ================= */
70 /* For plugIns. */
71 /* PlugIns that do static registration are load on demand by default. */
72 /* PlugIns that do dynamic registration are not load on demand by default. */
73 /* A dynamic registration function can call CFPlugInSetLoadOnDemand(). */
74
75 CF_EXPORT void CFPlugInSetLoadOnDemand(CFPlugInRef plugIn, Boolean flag);
76
77 CF_EXPORT Boolean CFPlugInIsLoadOnDemand(CFPlugInRef plugIn);
78
79 /* ================= Finding factories and creating instances ================= */
80 /* For plugIn hosts. */
81 /* Functions for finding factories to create specific types and actually creating instances of a type. */
82
83 /* This function finds all the factories from any plugin for the given type. Returns an array that the caller must release. */
84 CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInType(CFUUIDRef typeUUID) CF_RETURNS_RETAINED;
85
86
87 /* This function restricts the result to factories from the given plug-in that can create the given type. Returns an array that the caller must release. */
88 CF_EXPORT CFArrayRef CFPlugInFindFactoriesForPlugInTypeInPlugIn(CFUUIDRef typeUUID, CFPlugInRef plugIn) CF_RETURNS_RETAINED;
89
90 /* This function returns the IUnknown interface for the new instance. */
91 CF_EXPORT void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
92
93 /* ================= Registering factories and types ================= */
94 /* For plugIn writers who must dynamically register things. */
95 /* Functions to register factory functions and to associate factories with types. */
96
97 CF_EXPORT Boolean CFPlugInRegisterFactoryFunction(CFUUIDRef factoryUUID, CFPlugInFactoryFunction func);
98
99 CF_EXPORT Boolean CFPlugInRegisterFactoryFunctionByName(CFUUIDRef factoryUUID, CFPlugInRef plugIn, CFStringRef functionName);
100
101 CF_EXPORT Boolean CFPlugInUnregisterFactory(CFUUIDRef factoryUUID);
102
103 CF_EXPORT Boolean CFPlugInRegisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
104
105 CF_EXPORT Boolean CFPlugInUnregisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
106
107 /* ================= Registering instances ================= */
108 /* When a new instance of a type is created, the instance is responsible for registering itself with the factory that created it and unregistering when it deallocates. */
109 /* This means that an instance must keep track of the CFUUIDRef of the factory that created it so it can unregister when it goes away. */
110
111 CF_EXPORT void CFPlugInAddInstanceForFactory(CFUUIDRef factoryID);
112
113 CF_EXPORT void CFPlugInRemoveInstanceForFactory(CFUUIDRef factoryID);
114
115
116 /* Obsolete API */
117
118 typedef struct __CFPlugInInstance *CFPlugInInstanceRef;
119
120 typedef Boolean (*CFPlugInInstanceGetInterfaceFunction)(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl);
121 typedef void (*CFPlugInInstanceDeallocateInstanceDataFunction)(void *instanceData);
122
123 CF_EXPORT Boolean CFPlugInInstanceGetInterfaceFunctionTable(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl);
124
125 /* This function returns a retained object on 10.8 or later. */
126 CF_EXPORT CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance) CF_RETURNS_RETAINED;
127
128 CF_EXPORT void *CFPlugInInstanceGetInstanceData(CFPlugInInstanceRef instance);
129
130 CF_EXPORT CFTypeID CFPlugInInstanceGetTypeID(void);
131
132 CF_EXPORT CFPlugInInstanceRef CFPlugInInstanceCreateWithInstanceDataSize(CFAllocatorRef allocator, CFIndex instanceDataSize, CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceFunction, CFStringRef factoryName, CFPlugInInstanceGetInterfaceFunction getInterfaceFunction);
133
134 CF_EXTERN_C_END
135 CF_IMPLICIT_BRIDGING_DISABLED
136
137 #if !COREFOUNDATION_CFPLUGINCOM_SEPARATE
138 #include <CoreFoundation/CFPlugInCOM.h>
139 #endif /* !COREFOUNDATION_CFPLUGINCOM_SEPARATE */
140
141 #endif /* ! __COREFOUNDATION_CFPLUGIN__ */
142