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