LCOV - code coverage report
Current view: top level - connectivity/source/manager - mdrivermanager.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10