Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / firebird / Services.cxx
blob0efd4229992515b237f0c43423374b9a7b69ac3d
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 .
20 #include "Driver.hxx"
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;
49 ProviderRequest(
50 void* pServiceManager,
51 sal_Char const* pImplementationName
53 : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
54 , sImplementationName(OUString::createFromAscii(pImplementationName))
58 inline
59 bool CREATE_PROVIDER(
60 const OUString& Implname,
61 const Sequence< OUString > & Services,
62 ::cppu::ComponentInstantiation Factory,
63 createFactoryFunc creator
66 if (!xRet.is() && (Implname == sImplementationName))
68 try
70 xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
72 catch(...)
76 return xRet.is();
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,
86 void* pRegistryKey)
88 (void) pRegistryKey;
89 void* pRet = 0;
90 if (pServiceManager)
92 ProviderRequest aReq(pServiceManager,pImplementationName);
94 aReq.CREATE_PROVIDER(
95 FirebirdDriver::getImplementationName_Static(),
96 FirebirdDriver::getSupportedServiceNames_Static(),
97 FirebirdDriver_CreateInstance, ::cppu::createSingleFactory)
100 if(aReq.xRet.is())
101 aReq.xRet->acquire();
103 pRet = aReq.getProvider();
106 return pRet;
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */