update credits
[LibreOffice.git] / connectivity / source / manager / mdrivermanager.hxx
blob864158d0b2705c0e653b0dd4cecdc58592f0d5f2
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 #ifndef _CONNECTIVITY_DRIVERMANAGER_HXX_
21 #define _CONNECTIVITY_DRIVERMANAGER_HXX_
23 #include <com/sun/star/sdbc/XDriverManager2.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <com/sun/star/uno/XNamingService.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/sdbc/XDriverAccess.hpp>
28 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
30 #include <cppuhelper/implbase3.hxx>
31 #include <comphelper/stl_types.hxx>
32 #include <comphelper/logging.hxx>
33 #include <comphelper/componentcontext.hxx>
34 #include <osl/mutex.hxx>
35 #include "connectivity/DriversConfig.hxx"
37 namespace drivermanager
40 //======================================================================
41 //= various
42 //======================================================================
43 typedef ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SdbcDriver;
44 DECLARE_STL_USTRINGACCESS_MAP( SdbcDriver, DriverCollection );
46 typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > DriverFactory;
47 struct DriverAccess
49 OUString sImplementationName; /// the implementation name of the driver
50 DriverFactory xComponentFactory; /// the factory to create the driver component (if not already done so)
51 SdbcDriver xDriver; /// the driver itself
54 //==========================================================================
55 //= OSDBCDriverManager - the one-instance service for managing SDBC drivers
56 //==========================================================================
57 typedef ::cppu::WeakImplHelper3 < ::com::sun::star::sdbc::XDriverManager2
58 , ::com::sun::star::lang::XServiceInfo
59 , ::com::sun::star::uno::XNamingService
60 > OSDBCDriverManager_Base;
62 class OSDBCDriverManager : public OSDBCDriverManager_Base
64 friend class ODriverEnumeration;
66 ::osl::Mutex m_aMutex;
67 ::comphelper::ComponentContext m_aContext;
68 ::comphelper::EventLogger m_aEventLogger;
70 DECLARE_STL_VECTOR(DriverAccess, DriverAccessArray);
71 DriverAccessArray m_aDriversBS;
73 // for drivers registered at runtime (not bootstrapped) we don't require an XServiceInfo interface,
74 // so we have to remember their impl-name in another way
75 DECLARE_STL_USTRINGACCESS_MAP(SdbcDriver, DriverCollection);
76 DriverCollection m_aDriversRT;
78 ::connectivity::DriversConfig m_aDriverConfig;
79 sal_Int32 m_nLoginTimeout;
81 private:
82 OSDBCDriverManager(
83 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
84 ~OSDBCDriverManager();
86 public:
88 // XDriverManager
89 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( const OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
90 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnectionWithInfo( const OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
91 virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::uno::RuntimeException);
92 virtual sal_Int32 SAL_CALL getLoginTimeout( ) throw(::com::sun::star::uno::RuntimeException);
94 // XDriverAccess
95 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SAL_CALL getDriverByURL( const OUString& url ) throw(::com::sun::star::uno::RuntimeException);
97 // XEnumerationAccess
98 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException);
100 // XElementAccess
101 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
102 virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
104 // XServiceInfo
105 virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
106 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
107 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
109 // XServiceInfo - static methods
110 static OUString SAL_CALL getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
111 static ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
112 static OUString SAL_CALL getSingletonName_static( ) throw(::com::sun::star::uno::RuntimeException);
113 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxContext );
115 // XNamingService
116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRegisteredObject( const OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
117 virtual void SAL_CALL registerObject( const OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Object ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
118 virtual void SAL_CALL revokeObject( const OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
120 protected:
121 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > implGetDriverForURL(const OUString& _rURL);
123 /** retrieve the driver order preferences from the configuration and
124 sort m_aDriversBS accordingly.
126 void initializeDriverPrecedence();
128 void bootstrapDrivers();
131 } // namespace drivermanager
133 #endif // _CONNECTIVITY_DRIVERMANAGER_HXX_
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */