Branch libreoffice-5-0-4
[LibreOffice.git] / include / cppuhelper / factory.hxx
blob66fa0744f6741025be767fca176c601f86c5d5f5
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 <rtl/ustring.hxx>
23 #include <rtl/unload.h>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
27 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/registry/XRegistryKey.hpp>
30 #include <cppuhelper/cppuhelperdllapi.h>
34 #define COMPONENT_GETENV "component_getImplementationEnvironment"
35 #define COMPONENT_GETENVEXT "component_getImplementationEnvironmentExt"
36 #define COMPONENT_WRITEINFO "component_writeInfo"
37 #define COMPONENT_GETFACTORY "component_getFactory"
39 typedef struct _uno_Environment uno_Environment;
41 /** Function pointer declaration.
42 Function determines the environment of the component implementation, i.e. which compiler
43 compiled it. If the environment is NOT session specific (needs no additional context),
44 then this function should return the environment type name and leave ppEnv (to 0).
46 @param ppEnvTypeName environment type name; string must be constant
47 @param ppEnv function returns its environment if the environment is session specific,
48 i.e. has special context
50 typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)(
51 const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv );
53 /** Function pointer declaration.
54 Function determines the environment of the component implementation, i.e. the compiler.
55 If the environment is NOT session specific (needs no additional context),
56 then this function should return the environment type name and leave ppEnv (to 0).
58 @param ppEnvTypeName environment type name; string must be a constant
59 @param ppEnv function returns an environment if the environment is session specific,
60 i.e. has special context
61 @param pImplName
63 typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)(
64 sal_Char const ** ppEnvTypeName,
65 uno_Environment ** ppEnv,
66 sal_Char const * pImplName,
67 uno_Environment * pTargetEnv
70 /** Function pointer declaration.
71 Function retrieves a component description.
73 @return an XML formatted string containing a short component description
74 @deprecated
76 typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void);
78 /** Function pointer declaration.
80 @deprecated component_writeInfo should no longer be used in new components
82 Function writes component registry info, at least writing the supported service names.
84 @param pServiceManager
85 a service manager (the type is an XMultiServiceFactory that can be used
86 by the environment returned by component_getImplementationEnvironment)
87 @param pRegistryKey a registry key
88 (the type is XRegistryKey that can be used by the environment
89 returned by component_getImplementationEnvironment)
90 @return true if everything went fine
92 typedef sal_Bool (SAL_CALL * component_writeInfoFunc)(
93 void * pServiceManager, void * pRegistryKey );
95 /** Function pointer declaration.
96 Retrieves a factory to create component instances.
98 @param pImplName
99 desired implementation name
100 @param pServiceManager
101 a service manager (the type is XMultiServiceFactory that can be used by the environment
102 returned by component_getImplementationEnvironment)
103 @param pRegistryKey
104 a registry key (the type is XRegistryKey that can be used by the environment
105 returned by component_getImplementationEnvironment)
106 @return acquired component factory
107 (the type is lang::XSingleComponentFactory or lang::XSingleServiceFactory to be used by the
108 environment returned by component_getImplementationEnvironment)
110 typedef void * (SAL_CALL * component_getFactoryFunc)(
111 const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
115 namespace cppu
118 /** Function pointer declaration.
119 Function creates component instance passing the component context to be used.
121 @param xContext component context to be used
122 @return component instance
124 typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
125 SAL_CALL * ComponentFactoryFunc)(
126 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext );
128 /** Creates a single component factory supporting the XSingleComponentFactory interface.
130 @param fptr function pointer for instanciating the object
131 @param rImplementationName implementation name of service
132 @param rServiceNames supported services
133 @param pModCount a backwards-compatibility remainder of a removed library
134 unloading feature; always set to null
136 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory >
137 SAL_CALL createSingleComponentFactory(
138 ComponentFactoryFunc fptr,
139 ::rtl::OUString const & rImplementationName,
140 ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
141 rtl_ModuleCount * pModCount = 0 );
143 /** Creates a single service factory which holds the instance created only once.
145 @param fptr function pointer for instanciating the object
146 @param rImplementationName implementation name of service
147 @param rServiceNames supported services
148 @param pModCount a backwards-compatibility remainder of a removed library
149 unloading feature; always set to null
151 @see createSingleComponentFactory
153 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > SAL_CALL
154 createOneInstanceComponentFactory(
155 ComponentFactoryFunc fptr,
156 ::rtl::OUString const & rImplementationName,
157 ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
158 rtl_ModuleCount * pModCount = 0 );
160 /** Deprecated. The type of the instanciate function used as argument of the create*Fcatory functions.
162 @see createSingleFactory
163 @see createOneInstanceFactory
164 @deprecated
166 typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(SAL_CALL * ComponentInstantiation)(
167 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager );
169 /** Deprecated. Creates a single service factory.
171 @param rServiceManager the service manager used by the implementation.
172 @param rImplementationName the implementation name. An empty string is possible.
173 @param pCreateFunction the function pointer to create an object.
174 @param rServiceNames the service supported by the implementation.
175 @param pModCount a backwards-compatibility remainder of a removed library
176 unloading feature; always set to null.
177 @return a factory that support the interfaces XServiceProvider, XServiceInfo
178 XSingleServiceFactory and XComponent.
180 @see createOneInstanceFactory
181 @deprecated
183 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
184 createSingleFactory(
185 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
186 const ::rtl::OUString & rImplementationName,
187 ComponentInstantiation pCreateFunction,
188 const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
189 rtl_ModuleCount * pModCount = 0 );
191 /** Deprecated. Creates a factory wrapping another one.
192 This means the methods of the interfaces XServiceProvider, XServiceInfo and
193 XSingleServiceFactory are forwarded.
194 @attention
195 The XComponent interface is not supported!
197 @param rServiceManager the service manager used by the implementation.
198 @param rFactory the wrapped service factory.
199 @return a factory that support the interfaces XServiceProvider, XServiceInfo
200 XSingleServiceFactory.
202 @see createSingleFactory
203 @deprecated
205 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
206 createFactoryProxy(
207 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
208 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > & rFactory );
210 /** Deprecated. Creates a single service factory which holds the instance created only once.
212 @param rServiceManager the service manager used by the implementation.
213 @param rComponentName the implementation name. An empty string is possible.
214 @param pCreateFunction the function pointer to create an object.
215 @param rServiceNames the service supported by the implementation.
216 @param pModCount a backwards-compatibility remainder of a removed library
217 unloading feature; always set to null.
218 @return a factory that support the interfaces XServiceProvider, XServiceInfo
219 XSingleServiceFactory and XComponent.
221 @see createSingleFactory
222 @deprecated
224 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
225 createOneInstanceFactory(
226 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
227 const ::rtl::OUString & rComponentName,
228 ComponentInstantiation pCreateFunction,
229 const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
230 rtl_ModuleCount * pModCount = 0 );
232 /** Deprecated. Creates a single service factory based on a registry.
234 @param rServiceManager the service manager used by the implementation.
235 @param rImplementationName the implementation name. An empty string is possible.
236 @param rImplementationKey the registry key of the implementation section.
237 @return a factory that support the interfaces XServiceProvider, XServiceInfo
238 XSingleServiceFactory and XComponent.
239 @deprecated
241 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
242 createSingleRegistryFactory(
243 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
244 const ::rtl::OUString & rImplementationName,
245 const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey );
247 /** Deprecated. Creates a single service factory which holds the instance created only once
248 based on a registry.
250 @param rServiceManager the service manager used by the implementation.
251 @param rComponentName the implementation name. An empty string is possible.
252 @param rImplementationKey the registry key of the implementation section.
253 @return a factory that support the interfaces XServiceProvider, XServiceInfo
254 XSingleServiceFactory and XComponent.
256 @see createSingleRegistryFactory
257 @deprecated
259 CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
260 createOneInstanceRegistryFactory(
261 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
262 const ::rtl::OUString & rComponentName,
263 const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey );
267 #endif
269 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */