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