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