]> git.saurik.com Git - apple/cf.git/blob - CFPlugIn.h
CF-635.21.tar.gz
[apple/cf.git] / CFPlugIn.h
1 /*
2 * Copyright (c) 2012 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-2011, 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_EXTERN_C_BEGIN
43
44 /* ================ Standard Info.plist keys for plugIns ================ */
45
46 CF_EXPORT
47 const CFStringRef kCFPlugInDynamicRegistrationKey;
48 CF_EXPORT
49 const CFStringRef kCFPlugInDynamicRegisterFunctionKey;
50 CF_EXPORT
51 const CFStringRef kCFPlugInUnloadFunctionKey;
52 CF_EXPORT
53 const CFStringRef kCFPlugInFactoriesKey;
54 CF_EXPORT
55 const CFStringRef kCFPlugInTypesKey;
56
57 /* ================= Function prototypes for various callbacks ================= */
58 /* Function types that plugIn authors can implement for various purposes. */
59
60 typedef void (*CFPlugInDynamicRegisterFunction)(CFPlugInRef plugIn);
61 typedef void (*CFPlugInUnloadFunction)(CFPlugInRef plugIn);
62 typedef void *(*CFPlugInFactoryFunction)(CFAllocatorRef allocator, CFUUIDRef typeUUID);
63
64 /* ================= Creating PlugIns ================= */
65
66 CF_EXPORT
67 CFTypeID CFPlugInGetTypeID(void);
68
69 CF_EXPORT
70 CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL);
71 /* Might return an existing instance with the ref-count bumped. */
72
73 CF_EXPORT
74 CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn);
75
76 /* ================= Controlling load on demand ================= */
77 /* For plugIns. */
78 /* PlugIns that do static registration are load on demand by default. */
79 /* PlugIns that do dynamic registration are not load on demand by default. */
80 /* A dynamic registration function can call CFPlugInSetLoadOnDemand(). */
81
82 CF_EXPORT
83 void CFPlugInSetLoadOnDemand(CFPlugInRef plugIn, Boolean flag);
84
85 CF_EXPORT
86 Boolean CFPlugInIsLoadOnDemand(CFPlugInRef plugIn);
87
88 /* ================= Finding factories and creating instances ================= */
89 /* For plugIn hosts. */
90 /* Functions for finding factories to create specific types and actually creating instances of a type. */
91
92 CF_EXPORT
93 CFArrayRef CFPlugInFindFactoriesForPlugInType(CFUUIDRef typeUUID);
94 /* This function finds all the factories from any plugin for the given type. Returns an array that the caller must release. */
95
96 CF_EXPORT
97 CFArrayRef CFPlugInFindFactoriesForPlugInTypeInPlugIn(CFUUIDRef typeUUID, CFPlugInRef plugIn);
98 /* 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. */
99
100 CF_EXPORT
101 void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
102 /* This function returns the IUnknown interface for the new instance. */
103
104 /* ================= Registering factories and types ================= */
105 /* For plugIn writers who must dynamically register things. */
106 /* Functions to register factory functions and to associate factories with types. */
107
108 CF_EXPORT
109 Boolean CFPlugInRegisterFactoryFunction(CFUUIDRef factoryUUID, CFPlugInFactoryFunction func);
110
111 CF_EXPORT
112 Boolean CFPlugInRegisterFactoryFunctionByName(CFUUIDRef factoryUUID, CFPlugInRef plugIn, CFStringRef functionName);
113
114 CF_EXPORT
115 Boolean CFPlugInUnregisterFactory(CFUUIDRef factoryUUID);
116
117 CF_EXPORT
118 Boolean CFPlugInRegisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
119
120 CF_EXPORT
121 Boolean CFPlugInUnregisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
122
123 /* ================= Registering instances ================= */
124 /* 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. */
125 /* 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. */
126
127 CF_EXPORT
128 void CFPlugInAddInstanceForFactory(CFUUIDRef factoryID);
129
130 CF_EXPORT
131 void CFPlugInRemoveInstanceForFactory(CFUUIDRef factoryID);
132
133
134 /* Obsolete API */
135
136 typedef struct __CFPlugInInstance *CFPlugInInstanceRef;
137
138 typedef Boolean (*CFPlugInInstanceGetInterfaceFunction)(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl);
139 typedef void (*CFPlugInInstanceDeallocateInstanceDataFunction)(void *instanceData);
140
141 CF_EXPORT
142 Boolean CFPlugInInstanceGetInterfaceFunctionTable(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl);
143 CF_EXPORT
144 CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance);
145 CF_EXPORT
146 void *CFPlugInInstanceGetInstanceData(CFPlugInInstanceRef instance);
147 CF_EXPORT
148 CFTypeID CFPlugInInstanceGetTypeID(void);
149 CF_EXPORT
150 CFPlugInInstanceRef CFPlugInInstanceCreateWithInstanceDataSize(CFAllocatorRef allocator, CFIndex instanceDataSize, CFPlugInInstanceDeallocateInstanceDataFunction deallocateInstanceFunction, CFStringRef factoryName, CFPlugInInstanceGetInterfaceFunction getInterfaceFunction);
151
152 CF_EXTERN_C_END
153
154 #if !COREFOUNDATION_CFPLUGINCOM_SEPARATE
155 #include <CoreFoundation/CFPlugInCOM.h>
156 #endif /* !COREFOUNDATION_CFPLUGINCOM_SEPARATE */
157
158 #endif /* ! __COREFOUNDATION_CFPLUGIN__ */
159