update credits
[LibreOffice.git] / mysqlc / source / mysqlc_services.cxx
blob0ffe9cdee778b232cada5838038a09d4870e1ede
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 "mysqlc_driver.hxx"
22 #include <cppuhelper/factory.hxx>
23 #include <osl/diagnose.h>
24 #include <rtl/ustrbuf.hxx>
25 #include <uno/lbnames.h>
27 using namespace connectivity::mysqlc;
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*
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
52 ) : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
53 , sImplementationName(OUString::createFromAscii(pImplementationName))
57 /* {{{ CREATE_PROVIDER -I- */
58 inline sal_Bool CREATE_PROVIDER(
59 const OUString& Implname,
60 const Sequence< OUString > & Services,
61 ::cppu::ComponentInstantiation Factory,
62 createFactoryFunc creator
65 if (!xRet.is() && (Implname == sImplementationName)) {
66 try {
67 xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
68 } catch (...) {
71 return xRet.is();
74 void* getProvider() const { return xRet.get(); }
76 /* }}} */
79 /* {{{ component_getFactory -I- */
80 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
81 const sal_Char * pImplementationName,
82 void * pServiceManager,
83 void * /* pRegistryKey */)
85 void* pRet = 0;
86 if (pServiceManager) {
87 ProviderRequest aReq(pServiceManager,pImplementationName);
89 aReq.CREATE_PROVIDER(
90 MysqlCDriver::getImplementationName_Static(),
91 MysqlCDriver::getSupportedServiceNames_Static(),
92 MysqlCDriver_CreateInstance, ::cppu::createSingleFactory)
95 if(aReq.xRet.is()) {
96 aReq.xRet->acquire();
99 pRet = aReq.getProvider();
102 return pRet;
104 /* }}} */
106 extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
107 component_getImplementationEnvironment(
108 char const ** ppEnvTypeName, uno_Environment **)
110 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
114 * Local variables:
115 * tab-width: 4
116 * c-basic-offset: 4
117 * End:
118 * vim600: noet sw=4 ts=4 fdm=marker
119 * vim<600: noet sw=4 ts=4
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */