Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / cppuhelper / factory.hxx
blob90d80cb3df0250ecaf12af4b95d0d3166d7ba9fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_CPPUHELPER_FACTORY_HXX
20 #define INCLUDED_CPPUHELPER_FACTORY_HXX
22 #include <sal/config.h>
24 #include <cstddef>
26 #include <rtl/ustring.hxx>
27 #include <rtl/unload.h>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
31 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/registry/XRegistryKey.hpp>
34 #include <cppuhelper/cppuhelperdllapi.h>
37 #define COMPONENT_GETENV "component_getImplementationEnvironment"
38 #define COMPONENT_GETENVEXT "component_getImplementationEnvironmentExt"
39 #define COMPONENT_WRITEINFO "component_writeInfo"
40 #define COMPONENT_GETFACTORY "component_getFactory"
42 typedef struct _uno_Environment uno_Environment;
44 /** Function pointer declaration.
45 Function determines the environment of the component implementation, i.e. which compiler
46 compiled it. If the environment is NOT session specific (needs no additional context),
47 then this function should return the environment type name and leave ppEnv (to 0).
49 @param ppEnvTypeName environment type name; string must be constant
50 @param ppEnv function returns its environment if the environment is session specific,
51 i.e. has special context
53 typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)(
54 const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv );
56 /** Function pointer declaration.
57 Function determines the environment of the component implementation, i.e. the compiler.
58 If the environment is NOT session specific (needs no additional context),
59 then this function should return the environment type name and leave ppEnv (to 0).
61 @param ppEnvTypeName environment type name; string must be a constant
62 @param ppEnv function returns an environment if the environment is session specific,
63 i.e. has special context
64 @param pImplName
66 typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)(
67 sal_Char const ** ppEnvTypeName,
68 uno_Environment ** ppEnv,
69 sal_Char const * pImplName,
70 uno_Environment * pTargetEnv
73 /** Function pointer declaration.
74 Function retrieves a component description.
76 @return an XML formatted string containing a short component description
77 @deprecated
79 typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void);
81 /** Function pointer declaration.
83 @deprecated component_writeInfo should no longer be used in new components
85 Function writes component registry info, at least writing the supported service names.
87 @param pServiceManager
88 a service manager (the type is an XMultiServiceFactory that can be used
89 by the environment returned by component_getImplementationEnvironment)
90 @param pRegistryKey a registry key
91 (the type is XRegistryKey that can be used by the environment
92 returned by component_getImplementationEnvironment)
93 @return true if everything went fine
95 typedef sal_Bool (SAL_CALL * component_writeInfoFunc)(
96 void * pServiceManager, void * pRegistryKey );
98 /** Function pointer declaration.
99 Retrieves a factory to create component instances.
101 @param pImplName
102 desired implementation name
103 @param pServiceManager
104 a service manager (the type is XMultiServiceFactory that can be used by the environment
105 returned by component_getImplementationEnvironment)
106 @param pRegistryKey
107 a registry key (the type is XRegistryKey that can be used by the environment
108 returned by component_getImplementationEnvironment)
109 @return acquired component factory
110 (the type is lang::XSingleComponentFactory or lang::XSingleServiceFactory to be used by the
111 environment returned by component_getImplementationEnvironment)
113 typedef void * (SAL_CALL * component_getFactoryFunc)(
114 const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
117 namespace cppu
120 /** Function pointer declaration.
121 Function creates component instance passing the component context to be used.
123 @param xContext component context to be used
124 @return component instance
126 typedef css::uno::Reference< css::uno::XInterface >(
127 SAL_CALL * ComponentFactoryFunc)(
128 css::uno::Reference< css::uno::XComponentContext > const & xContext );
130 /** Creates a single component factory supporting the XSingleComponentFactory interface.
132 @param fptr function pointer for instanciating the object
133 @param rImplementationName implementation name of service
134 @param rServiceNames supported services
135 @param pModCount a backwards-compatibility remainder of a removed library
136 unloading feature; always set to null
138 CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleComponentFactory >
139 SAL_CALL createSingleComponentFactory(
140 ComponentFactoryFunc fptr,
141 ::rtl::OUString const & rImplementationName,
142 css::uno::Sequence< ::rtl::OUString > const & rServiceNames,
143 rtl_ModuleCount * pModCount = NULL );
145 /** Creates a single service factory which holds the instance created only once.
147 @param fptr function pointer for instanciating the object
148 @param rImplementationName implementation name of service
149 @param rServiceNames supported services
150 @param pModCount a backwards-compatibility remainder of a removed library
151 unloading feature; always set to null
153 @see createSingleComponentFactory
155 CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleComponentFactory > SAL_CALL
156 createOneInstanceComponentFactory(
157 ComponentFactoryFunc fptr,
158 ::rtl::OUString const & rImplementationName,
159 css::uno::Sequence< ::rtl::OUString > const & rServiceNames,
160 rtl_ModuleCount * pModCount = NULL );
162 /** Deprecated. The type of the instanciate function used as argument of the create*Factory functions.
164 @see createSingleFactory
165 @see createOneInstanceFactory
166 @deprecated
168 typedef css::uno::Reference< css::uno::XInterface >(SAL_CALL * ComponentInstantiation)(
169 const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager );
171 /** Deprecated. Creates a single service factory.
173 @param rServiceManager the service manager used by the implementation.
174 @param rImplementationName the implementation name. An empty string is possible.
175 @param pCreateFunction the function pointer to create an object.
176 @param rServiceNames the service supported by the implementation.
177 @param pModCount a backwards-compatibility remainder of a removed library
178 unloading feature; always set to null.
179 @return a factory that support the interfaces XServiceProvider, XServiceInfo
180 XSingleServiceFactory and XComponent.
182 @see createOneInstanceFactory
183 @deprecated
185 CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL
186 createSingleFactory(
187 const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager,
188 const ::rtl::OUString & rImplementationName,
189 ComponentInstantiation pCreateFunction,
190 const css::uno::Sequence< ::rtl::OUString > & rServiceNames,
191 rtl_ModuleCount * pModCount = NULL );
193 /** Deprecated. Creates a factory wrapping another one.
194 This means the methods of the interfaces XServiceProvider, XServiceInfo and
195 XSingleServiceFactory are forwarded.
196 @attention
197 The XComponent interface is not supported!
199 @param rServiceManager the service manager used by the implementation.
200 @param rFactory the wrapped service factory.
201 @return a factory that support the interfaces XServiceProvider, XServiceInfo
202 XSingleServiceFactory.
204 @see createSingleFactory
205 @deprecated
207 CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL
208 createFactoryProxy(
209 const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager,
210 const css::uno::Reference< css::lang::XSingleServiceFactory > & rFactory );
212 /** Deprecated. Creates a single service factory which holds the instance created only once.
214 @param rServiceManager the service manager used by the implementation.
215 @param rComponentName the implementation name. An empty string is possible.
216 @param pCreateFunction the function pointer to create an object.
217 @param rServiceNames the service supported by the implementation.
218 @param pModCount a backwards-compatibility remainder of a removed library
219 unloading feature; always set to null.
220 @return a factory that support the interfaces XServiceProvider, XServiceInfo
221 XSingleServiceFactory and XComponent.
223 @see createSingleFactory
224 @deprecated
226 CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL
227 createOneInstanceFactory(
228 const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager,
229 const ::rtl::OUString & rComponentName,
230 ComponentInstantiation pCreateFunction,
231 const css::uno::Sequence< ::rtl::OUString > & rServiceNames,
232 rtl_ModuleCount * pModCount = NULL );
234 /** Deprecated. Creates a single service factory based on a registry.
236 @param rServiceManager the service manager used by the implementation.
237 @param rImplementationName the implementation name. An empty string is possible.
238 @param rImplementationKey the registry key of the implementation section.
239 @return a factory that support the interfaces XServiceProvider, XServiceInfo
240 XSingleServiceFactory and XComponent.
241 @deprecated
243 CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL
244 createSingleRegistryFactory(
245 const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager,
246 const ::rtl::OUString & rImplementationName,
247 const css::uno::Reference< css::registry::XRegistryKey > & rImplementationKey );
249 /** Deprecated. Creates a single service factory which holds the instance created only once
250 based on a registry.
252 @param rServiceManager the service manager used by the implementation.
253 @param rComponentName the implementation name. An empty string is possible.
254 @param rImplementationKey the registry key of the implementation section.
255 @return a factory that support the interfaces XServiceProvider, XServiceInfo
256 XSingleServiceFactory and XComponent.
258 @see createSingleRegistryFactory
259 @deprecated
261 CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL
262 createOneInstanceRegistryFactory(
263 const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager,
264 const ::rtl::OUString & rComponentName,
265 const css::uno::Reference< css::registry::XRegistryKey > & rImplementationKey );
269 #endif
271 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */