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

Generated by: LCOV version 1.11