1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <cppuhelper/factory.hxx>
23 #include <osl/diagnose.h>
24 #include <sal/types.h>
26 using namespace connectivity::firebird
;
27 using ::rtl::OUString
;
28 using ::com::sun::star::uno::Reference
;
29 using ::com::sun::star::uno::Sequence
;
30 using ::com::sun::star::registry::XRegistryKey
;
31 using ::com::sun::star::lang::XSingleServiceFactory
;
32 using ::com::sun::star::lang::XMultiServiceFactory
;
34 typedef Reference
< XSingleServiceFactory
> (SAL_CALL
*createFactoryFunc
)
36 const Reference
< XMultiServiceFactory
> & rServiceManager
,
37 const OUString
& rComponentName
,
38 ::cppu::ComponentInstantiation pCreateFunction
,
39 const Sequence
< OUString
> & rServiceNames
,
40 rtl_ModuleCount
* _pTemp
43 struct ProviderRequest
45 Reference
< XSingleServiceFactory
> xRet
;
46 Reference
< XMultiServiceFactory
> const xServiceManager
;
47 OUString
const sImplementationName
;
50 void* pServiceManager
,
51 sal_Char
const* pImplementationName
53 : xServiceManager(reinterpret_cast<XMultiServiceFactory
*>(pServiceManager
))
54 , sImplementationName(OUString::createFromAscii(pImplementationName
))
60 const OUString
& Implname
,
61 const Sequence
< OUString
> & Services
,
62 ::cppu::ComponentInstantiation Factory
,
63 createFactoryFunc creator
66 if (!xRet
.is() && (Implname
== sImplementationName
))
70 xRet
= creator( xServiceManager
, sImplementationName
,Factory
, Services
,0);
79 void* getProvider() const { return xRet
.get(); }
83 extern "C" SAL_DLLPUBLIC_EXPORT
void* SAL_CALL
firebird_sdbc_component_getFactory(
84 const sal_Char
* pImplementationName
,
85 void* pServiceManager
,
92 ProviderRequest
aReq(pServiceManager
,pImplementationName
);
95 FirebirdDriver::getImplementationName_Static(),
96 FirebirdDriver::getSupportedServiceNames_Static(),
97 FirebirdDriver_CreateInstance
, ::cppu::createSingleFactory
)
101 aReq
.xRet
->acquire();
103 pRet
= aReq
.getProvider();
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */