LCOV - code coverage report
Current view: top level - connectivity/source/manager - mdrivermanager.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 1 100.0 %
Date: 2014-11-03 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_CONNECTIVITY_SOURCE_MANAGER_MDRIVERMANAGER_HXX
      21             : #define INCLUDED_CONNECTIVITY_SOURCE_MANAGER_MDRIVERMANAGER_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <map>
      26             : #include <vector>
      27             : 
      28             : #include <com/sun/star/sdbc/XDriverManager2.hpp>
      29             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      30             : #include <com/sun/star/uno/XNamingService.hpp>
      31             : #include <com/sun/star/lang/XServiceInfo.hpp>
      32             : #include <com/sun/star/sdbc/XDriverAccess.hpp>
      33             : #include <com/sun/star/lang/XSingleComponentFactory.hpp>
      34             : 
      35             : #include <cppuhelper/implbase3.hxx>
      36             : #include <comphelper/logging.hxx>
      37             : #include <osl/mutex.hxx>
      38             : #include <connectivity/DriversConfig.hxx>
      39             : 
      40             : namespace drivermanager
      41             : {
      42             : 
      43             : 
      44             :     //= various
      45             : 
      46             :     typedef std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection;
      47             : 
      48        1812 :     struct DriverAccess
      49             :     {
      50             :         OUString           sImplementationName;        /// the implementation name of the driver
      51             :         css::uno::Reference< css::sdbc::XDriver >                  xDriver;                    /// the driver itself
      52             :         css::uno::Reference< css::lang::XSingleComponentFactory >  xComponentFactory;          /// the factory to create the driver component (if not already done so)
      53             :     };
      54             : 
      55             : 
      56             :     //= OSDBCDriverManager - the one-instance service for managing SDBC drivers
      57             : 
      58             :     typedef ::cppu::WeakImplHelper3 <   ::com::sun::star::sdbc::XDriverManager2
      59             :                                     ,   ::com::sun::star::lang::XServiceInfo
      60             :                                     ,   ::com::sun::star::uno::XNamingService
      61             :                                     >   OSDBCDriverManager_Base;
      62             : 
      63             :     class OSDBCDriverManager : public OSDBCDriverManager_Base
      64             :     {
      65             :         friend class ODriverEnumeration;
      66             : 
      67             :         ::osl::Mutex                    m_aMutex;
      68             :         css::uno::Reference<css::uno::XComponentContext>  m_xContext;
      69             :         ::comphelper::EventLogger       m_aEventLogger;
      70             : 
      71             :         typedef std::vector<DriverAccess> DriverAccessArray;
      72             :         DriverAccessArray               m_aDriversBS;
      73             : 
      74             :         // for drivers registered at runtime (not bootstrapped) we don't require an XServiceInfo interface,
      75             :         // so we have to remember their impl-name in another way
      76             :         typedef std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection;
      77             :         DriverCollection                m_aDriversRT;
      78             : 
      79             :         ::connectivity::DriversConfig   m_aDriverConfig;
      80             :         sal_Int32                       m_nLoginTimeout;
      81             : 
      82             :     private:
      83             :         OSDBCDriverManager(
      84             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
      85             :         virtual ~OSDBCDriverManager();
      86             : 
      87             :     public:
      88             : 
      89             :     // XDriverManager
      90             :         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, std::exception) SAL_OVERRIDE;
      91             :         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, std::exception) SAL_OVERRIDE;
      92             :         virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      93             :         virtual sal_Int32 SAL_CALL getLoginTimeout(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      94             : 
      95             :     // XDriverAccess
      96             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SAL_CALL getDriverByURL( const OUString& url ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      97             : 
      98             :     // XEnumerationAccess
      99             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     100             : 
     101             :     // XElementAccess
     102             :         virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     103             :         virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     104             : 
     105             :     // XServiceInfo
     106             :         virtual OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     107             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     108             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     109             : 
     110             :     // XServiceInfo - static methods
     111             :         static OUString SAL_CALL getImplementationName_static(  ) throw(::com::sun::star::uno::RuntimeException);
     112             :         static ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_static(  ) throw(::com::sun::star::uno::RuntimeException);
     113             :         static OUString SAL_CALL getSingletonName_static(  ) throw(::com::sun::star::uno::RuntimeException);
     114             :         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             : 
     116             :     // XNamingService
     117             :         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, std::exception) SAL_OVERRIDE;
     118             :         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, std::exception) SAL_OVERRIDE;
     119             :         virtual void SAL_CALL revokeObject( const OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     120             : 
     121             :     protected:
     122             :         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > implGetDriverForURL(const OUString& _rURL);
     123             : 
     124             :         /** retrieve the driver order preferences from the configuration and
     125             :             sort m_aDriversBS accordingly.
     126             :         */
     127             :         void initializeDriverPrecedence();
     128             : 
     129             :         void bootstrapDrivers();
     130             :     };
     131             : 
     132             : }   // namespace drivermanager
     133             : 
     134             : #endif // INCLUDED_CONNECTIVITY_SOURCE_MANAGER_MDRIVERMANAGER_HXX
     135             : 
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10