]> git.saurik.com Git - apple/cf.git/blame - PlugIn.subproj/CFPlugIn.h
CF-299.35.tar.gz
[apple/cf.git] / PlugIn.subproj / CFPlugIn.h
CommitLineData
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)
44extern "C" {
45#endif
46
47/* ================ Standard Info.plist keys for plugIns ================ */
48
49CF_EXPORT
50const CFStringRef kCFPlugInDynamicRegistrationKey;
51CF_EXPORT
52const CFStringRef kCFPlugInDynamicRegisterFunctionKey;
53CF_EXPORT
54const CFStringRef kCFPlugInUnloadFunctionKey;
55CF_EXPORT
56const CFStringRef kCFPlugInFactoriesKey;
57CF_EXPORT
58const CFStringRef kCFPlugInTypesKey;
59
60/* ================= Function prototypes for various callbacks ================= */
61/* Function types that plugIn authors can implement for various purposes. */
62
63typedef void (*CFPlugInDynamicRegisterFunction)(CFPlugInRef plugIn);
64typedef void (*CFPlugInUnloadFunction)(CFPlugInRef plugIn);
65typedef void *(*CFPlugInFactoryFunction)(CFAllocatorRef allocator, CFUUIDRef typeUUID);
66
67/* ================= Creating PlugIns ================= */
68
69CF_EXPORT
70UInt32 CFPlugInGetTypeID(void);
71
72CF_EXPORT
73CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL);
74 /* Might return an existing instance with the ref-count bumped. */
75
76CF_EXPORT
77CFBundleRef 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
85CF_EXPORT
86void CFPlugInSetLoadOnDemand(CFPlugInRef plugIn, Boolean flag);
87
88CF_EXPORT
89Boolean 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
95CF_EXPORT
96CFArrayRef 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
99CF_EXPORT
100CFArrayRef 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
103CF_EXPORT
104void *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
111CF_EXPORT
112Boolean CFPlugInRegisterFactoryFunction(CFUUIDRef factoryUUID, CFPlugInFactoryFunction func);
113
114CF_EXPORT
115Boolean CFPlugInRegisterFactoryFunctionByName(CFUUIDRef factoryUUID, CFPlugInRef plugIn, CFStringRef functionName);
116
117CF_EXPORT
118Boolean CFPlugInUnregisterFactory(CFUUIDRef factoryUUID);
119
120CF_EXPORT
121Boolean CFPlugInRegisterPlugInType(CFUUIDRef factoryUUID, CFUUIDRef typeUUID);
122
123CF_EXPORT
124Boolean 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
130CF_EXPORT
131void CFPlugInAddInstanceForFactory(CFUUIDRef factoryID);
132
133CF_EXPORT
134void CFPlugInRemoveInstanceForFactory(CFUUIDRef factoryID);
135
136
137/* Obsolete API */
138
139typedef struct __CFPlugInInstance *CFPlugInInstanceRef;
140
141typedef Boolean (*CFPlugInInstanceGetInterfaceFunction)(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl);
142typedef void (*CFPlugInInstanceDeallocateInstanceDataFunction)(void *instanceData);
143
144CF_EXPORT
145Boolean CFPlugInInstanceGetInterfaceFunctionTable(CFPlugInInstanceRef instance, CFStringRef interfaceName, void **ftbl);
146CF_EXPORT
147CFStringRef CFPlugInInstanceGetFactoryName(CFPlugInInstanceRef instance);
148CF_EXPORT
149void *CFPlugInInstanceGetInstanceData(CFPlugInInstanceRef instance);
150CF_EXPORT
151UInt32 CFPlugInInstanceGetTypeID(void);
152CF_EXPORT
153CFPlugInInstanceRef 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