summaryrefslogtreecommitdiff
path: root/cppuhelper/inc/cppuhelper/factory.hxx
blob: 2f1afcab1726266722637b20401cc107dfd702b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _CPPUHELPER_FACTORY_HXX_
#define _CPPUHELPER_FACTORY_HXX_

#include <rtl/ustring.hxx>
#include <uno/dispatcher.h>
#include <rtl/unload.h>

#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp>

//##################################################################################################

#define COMPONENT_GETENV            "component_getImplementationEnvironment"
#define COMPONENT_GETENVEXT         "component_getImplementationEnvironmentExt"
#define COMPONENT_GETDESCRIPTION    "component_getDescription"
#define COMPONENT_WRITEINFO         "component_writeInfo"
#define COMPONENT_GETFACTORY        "component_getFactory"

typedef struct _uno_Environment uno_Environment;

/** Function pointer declaration.
    Function determines the environment of the component implementation, i.e. which compiler
    compiled it. If the environment is NOT session specific (needs no additional context),
    then this function should return the environment type name and leave ppEnv (to 0).

    @param ppEnvTypeName environment type name; string must be constant
    @param ppEnv function returns its environment if the environment is session specific,
                 i.e. has special context
*/
typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)(
    const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv );

/** Function pointer declaration.
    Function determines the environment of the component implementation, i.e. the compiler.
    If the environment is NOT session specific (needs no additional context),
    then this function should return the environment type name and leave ppEnv (to 0).

    @param ppEnvTypeName environment type name; string must be a constant
    @param ppEnv         function returns an environment if the environment is session specific,
                         i.e. has special context
    @param pImplName
*/
typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)(
    sal_Char        const ** ppEnvTypeName,
    uno_Environment       ** ppEnv,
    sal_Char        const  * pImplName,
    uno_Environment        * pTargetEnv
);

/** Function pointer declaration.
    Function retrieves a component description.

    @return an XML formatted string containing a short component description
    @deprecated
*/
typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void);

/** Function pointer declaration.

    @obsolete component_writeInfo should no longer be used in new components

    Function writes component registry info, at least writing the supported service names.

    @param pServiceManager
    a service manager (the type is an XMultiServiceFactory that can be used
    by the environment returned by component_getImplementationEnvironment)
    @param pRegistryKey a registry key
    (the type is XRegistryKey that can be used by the environment
    returned by component_getImplementationEnvironment)
    @return true if everything went fine
*/
typedef sal_Bool (SAL_CALL * component_writeInfoFunc)(
    void * pServiceManager, void * pRegistryKey );

/** Function pointer declaration.
    Retrieves a factory to create component instances.

   @param pImplName
   desired implementation name
   @param pServiceManager
   a service manager (the type is XMultiServiceFactory that can be used by the environment
   returned by component_getImplementationEnvironment)
   @param pRegistryKey
   a registry key (the type is XRegistryKey that can be used by the environment
   returned by component_getImplementationEnvironment)
   @return acquired component factory
   (the type is lang::XSingleComponentFactory or lang::XSingleServiceFactory to be used by the
   environment returned by component_getImplementationEnvironment)
*/
typedef void * (SAL_CALL * component_getFactoryFunc)(
    const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );

//##################################################################################################

namespace cppu
{

/** Function pointer declaration.
    Function creates component instance passing the component context to be used.

    @param xContext component context to be used
    @return component instance
*/
typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
    SAL_CALL * ComponentFactoryFunc)(
        ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext )
    SAL_THROW( (::com::sun::star::uno::Exception) );

/** Creates a single component factory supporting the XSingleComponentFactory interface.

    @param fptr function pointer for instanciating the object
    @param rImplementationName implementation name of service
    @param rServiceNames supported services
    @param pModCount for future extension (library unloading concept).
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory >
SAL_CALL createSingleComponentFactory(
    ComponentFactoryFunc fptr,
    ::rtl::OUString const & rImplementationName,
    ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
    rtl_ModuleCount * pModCount = 0 )
    SAL_THROW( () );

/** Creates a single service factory which holds the instance created only once.

    @param fptr function pointer for instanciating the object
    @param rImplementationName implementation name of service
    @param rServiceNames supported services
    @param pModCount for future extension (library unloading concept).

    @see createSingleComponentFactory
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > SAL_CALL
createOneInstanceComponentFactory(
    ComponentFactoryFunc fptr,
    ::rtl::OUString const & rImplementationName,
    ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
    rtl_ModuleCount * pModCount = 0 )
    SAL_THROW( () );

/** Deprecated.  The type of the instanciate function used as argument of the create*Fcatory functions.

    @see createSingleFactory
    @see createOneInstanceFactory
    @deprecated
*/
typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(SAL_CALL * ComponentInstantiation)(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager );

/** Deprecated.  Creates a single service factory.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param ComponentInstantiation the function pointer to create an object.
    @param rServiceNames            the service supported by the implementation.
    @param pModCount             for future extension (library unloading concept).
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.

    @see createOneInstanceFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
createSingleFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rImplementationName,
    ComponentInstantiation pCreateFunction,
    const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
    rtl_ModuleCount * pModCount = 0  )
    SAL_THROW( () );

/** Deprecated.  Creates a factory wrapping another one.
    This means the methods of the interfaces XServiceProvider, XServiceInfo and
    XSingleServiceFactory are forwarded.
    @attention
    The XComponent interface is not supported!

    @param rServiceManager      the service manager used by the implementation.
    @param xSingleServiceFactory    the wrapped service factory.
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory.

    @see createSingleFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
createFactoryProxy(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > & rFactory )
    SAL_THROW( () );

/** Deprecated.  Creates a single service factory which holds the instance created only once.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param ComponentInstantiation the function pointer to create an object.
    @param rServiceNames            the service supported by the implementation.
    @param pModCount             for future extension (library unloading concept).
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.

    @see createSingleFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
createOneInstanceFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rComponentName,
    ComponentInstantiation pCreateFunction,
    const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
    rtl_ModuleCount * pModCount = 0  )
    SAL_THROW( () );

/** Deprecated.  Creates a single service factory based on a registry.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param rImplementationKey   the registry key of the implementation section.
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createSingleRegistryFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rImplementationName,
    const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey )
    SAL_THROW( () );

/** Deprecated.  Creates a single service factory which holds the instance created only once
    based on a registry.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param rImplementationKey   the registry key of the implementation section.
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.

    @see createSingleRegistryFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rComponentName,
    const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey )
    SAL_THROW( () );

}

#endif