LCOV - code coverage report
Current view: top level - connectivity/source/manager - mdrivermanager.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 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             :     typedef std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection;
      44             : 
      45        1185 :     struct DriverAccess
      46             :     {
      47             :         OUString           sImplementationName;        /// the implementation name of the driver
      48             :         css::uno::Reference< css::sdbc::XDriver >                  xDriver;                    /// the driver itself
      49             :         css::uno::Reference< css::lang::XSingleComponentFactory >  xComponentFactory;          /// the factory to create the driver component (if not already done so)
      50             :     };
      51             : 
      52             : 
      53             :     // OSDBCDriverManager - the one-instance service for managing SDBC drivers
      54             : 
      55             :     typedef ::cppu::WeakImplHelper3 <   ::com::sun::star::sdbc::XDriverManager2
      56             :                                     ,   ::com::sun::star::lang::XServiceInfo
      57             :                                     ,   ::com::sun::star::uno::XNamingService
      58             :                                     >   OSDBCDriverManager_Base;
      59             : 
      60             :     class OSDBCDriverManager : public OSDBCDriverManager_Base
      61             :     {
      62             :         friend class ODriverEnumeration;
      63             : 
      64             :         ::osl::Mutex                    m_aMutex;
      65             :         css::uno::Reference<css::uno::XComponentContext>  m_xContext;
      66             :         ::comphelper::EventLogger       m_aEventLogger;
      67             : 
      68             :         typedef std::vector<DriverAccess> DriverAccessArray;
      69             :         DriverAccessArray               m_aDriversBS;
      70             : 
      71             :         // for drivers registered at runtime (not bootstrapped) we don't require an XServiceInfo interface,
      72             :         // so we have to remember their impl-name in another way
      73             :         typedef std::map< OUString, css::uno::Reference< css::sdbc::XDriver > > DriverCollection;
      74             :         DriverCollection                m_aDriversRT;
      75             : 
      76             :         ::connectivity::DriversConfig   m_aDriverConfig;
      77             :         sal_Int32                       m_nLoginTimeout;
      78             : 
      79             :     private:
      80             :         OSDBCDriverManager(
      81             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
      82             :         virtual ~OSDBCDriverManager();
      83             : 
      84             :     public:
      85             : 
      86             :     // XDriverManager
      87             :         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;
      88             :         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;
      89             :         virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      90             :         virtual sal_Int32 SAL_CALL getLoginTimeout(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      91             : 
      92             :     // XDriverAccess
      93             :         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;
      94             : 
      95             :     // XEnumerationAccess
      96             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      97             : 
      98             :     // XElementAccess
      99             :         virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     100             :         virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     101             : 
     102             :     // XServiceInfo
     103             :         virtual OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     104             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     105             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     106             : 
     107             :     // XServiceInfo - static methods
     108             :         static OUString SAL_CALL getImplementationName_static(  ) throw(::com::sun::star::uno::RuntimeException);
     109             :         static ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_static(  ) throw(::com::sun::star::uno::RuntimeException);
     110             :         static OUString SAL_CALL getSingletonName_static(  ) throw(::com::sun::star::uno::RuntimeException);
     111             :         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 );
     112             : 
     113             :     // XNamingService
     114             :         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;
     115             :         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;
     116             :         virtual void SAL_CALL revokeObject( const OUString& Name ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     117             : 
     118             :     protected:
     119             :         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > implGetDriverForURL(const OUString& _rURL);
     120             : 
     121             :         /** retrieve the driver order preferences from the configuration and
     122             :             sort m_aDriversBS accordingly.
     123             :         */
     124             :         void initializeDriverPrecedence();
     125             : 
     126             :         void bootstrapDrivers();
     127             :     };
     128             : 
     129             : }   // namespace drivermanager
     130             : 
     131             : #endif // INCLUDED_CONNECTIVITY_SOURCE_MANAGER_MDRIVERMANAGER_HXX
     132             : 
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11