LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/cpool - ZDriverWrapper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 40 0.0 %
Date: 2012-12-27 Functions: 0 9 0.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             : #include "ZDriverWrapper.hxx"
      21             : #include "ZConnectionPool.hxx"
      22             : #include <osl/diagnose.h>
      23             : 
      24             : //........................................................................
      25             : namespace connectivity
      26             : {
      27             : //........................................................................
      28             : 
      29             :     using namespace ::com::sun::star::uno;
      30             :     using namespace ::com::sun::star::sdbc;
      31             :     using namespace ::com::sun::star::beans;
      32             : 
      33             :     //====================================================================
      34             :     //= ODriverWrapper
      35             :     //====================================================================
      36             :     //--------------------------------------------------------------------
      37           0 :     ODriverWrapper::ODriverWrapper( Reference< XAggregation >& _rxAggregateDriver, OConnectionPool* _pPool )
      38           0 :         :m_pConnectionPool(_pPool)
      39             :     {
      40             :         OSL_ENSURE(_rxAggregateDriver.is(), "ODriverWrapper::ODriverWrapper: invalid aggregate!");
      41             :         OSL_ENSURE(m_pConnectionPool, "ODriverWrapper::ODriverWrapper: invalid connection pool!");
      42             : 
      43           0 :         if (m_pConnectionPool)
      44           0 :             m_pConnectionPool->acquire();
      45             : 
      46           0 :         osl_atomic_increment( &m_refCount );
      47           0 :         if (_rxAggregateDriver.is())
      48             :         {
      49             :             // transfer the (one and only) real ref to the aggregate to our member
      50           0 :             m_xDriverAggregate = _rxAggregateDriver;
      51           0 :             _rxAggregateDriver = NULL;
      52             : 
      53             :             // a second "real" reference
      54           0 :             m_xDriver = Reference< XDriver >(m_xDriverAggregate, UNO_QUERY);
      55             :             OSL_ENSURE(m_xDriver.is(), "ODriverWrapper::ODriverWrapper: invalid aggregate (no XDriver)!");
      56             : 
      57             :             // set ourself as delegator
      58           0 :             m_xDriverAggregate->setDelegator( static_cast< XWeak* >( this ) );
      59             :         }
      60           0 :         osl_atomic_decrement( &m_refCount );
      61           0 :     }
      62             : 
      63             :     //--------------------------------------------------------------------
      64           0 :     ODriverWrapper::~ODriverWrapper()
      65             :     {
      66           0 :         if (m_xDriverAggregate.is())
      67           0 :             m_xDriverAggregate->setDelegator(NULL);
      68             : 
      69           0 :         if (m_pConnectionPool)
      70           0 :             m_pConnectionPool->release();
      71           0 :         m_pConnectionPool = NULL;
      72           0 :     }
      73             : 
      74             :     //--------------------------------------------------------------------
      75           0 :     Any SAL_CALL ODriverWrapper::queryInterface( const Type& _rType ) throw (RuntimeException)
      76             :     {
      77           0 :         Any aReturn = ODriverWrapper_BASE::queryInterface(_rType);
      78           0 :         return aReturn.hasValue() ? aReturn : (m_xDriverAggregate.is() ? m_xDriverAggregate->queryAggregation(_rType) : aReturn);
      79             :     }
      80             : 
      81             :     //--------------------------------------------------------------------
      82           0 :     Reference< XConnection > SAL_CALL ODriverWrapper::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
      83             :     {
      84           0 :         Reference< XConnection > xConnection;
      85           0 :         if (m_pConnectionPool)
      86             :             // route this through the pool
      87           0 :             xConnection = m_pConnectionPool->getConnectionWithInfo( url, info );
      88           0 :         else if (m_xDriver.is())
      89           0 :             xConnection = m_xDriver->connect( url, info );
      90             : 
      91           0 :         return xConnection;
      92             :     }
      93             : 
      94             :     //--------------------------------------------------------------------
      95           0 :     sal_Bool SAL_CALL ODriverWrapper::acceptsURL( const ::rtl::OUString& url ) throw (SQLException, RuntimeException)
      96             :     {
      97           0 :         return m_xDriver.is() && m_xDriver->acceptsURL(url);
      98             :     }
      99             : 
     100             :     //--------------------------------------------------------------------
     101           0 :     Sequence< DriverPropertyInfo > SAL_CALL ODriverWrapper::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
     102             :     {
     103           0 :         Sequence< DriverPropertyInfo > aInfo;
     104           0 :         if (m_xDriver.is())
     105           0 :             aInfo = m_xDriver->getPropertyInfo(url, info);
     106           0 :         return aInfo;
     107             :     }
     108             : 
     109             :     //--------------------------------------------------------------------
     110           0 :     sal_Int32 SAL_CALL ODriverWrapper::getMajorVersion(  ) throw (RuntimeException)
     111             :     {
     112           0 :         return m_xDriver.is() ? m_xDriver->getMajorVersion() : 0;
     113             :     }
     114             : 
     115             :     //--------------------------------------------------------------------
     116           0 :     sal_Int32 SAL_CALL ODriverWrapper::getMinorVersion(  ) throw (RuntimeException)
     117             :     {
     118           0 :         return m_xDriver.is() ? m_xDriver->getMinorVersion() : 0;
     119             :     }
     120             : 
     121             : //........................................................................
     122             : }   // namespace connectivity
     123             : //........................................................................
     124             : 
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10