LCOV - code coverage report
Current view: top level - io/source/connector - ctr_pipe.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 22 29 75.9 %
Date: 2012-08-25 Functions: 6 8 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 28 39.3 %

           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                 :            : 
      21                 :            : #include "connector.hxx"
      22                 :            : 
      23                 :            : using namespace ::osl;
      24                 :            : using namespace ::rtl;
      25                 :            : using namespace ::com::sun::star::uno;
      26                 :            : using namespace ::com::sun::star::io;
      27                 :            : using namespace ::com::sun::star::connection;
      28                 :            : 
      29                 :            : 
      30                 :            : namespace stoc_connector {
      31                 :            : 
      32                 :         26 :     PipeConnection::PipeConnection( const OUString & sConnectionDescription ) :
      33                 :            :         m_nStatus( 0 ),
      34         [ +  - ]:         26 :         m_sDescription( sConnectionDescription )
      35                 :            :     {
      36         [ +  - ]:         26 :         g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
      37                 :            :         // make it unique
      38         [ +  - ]:         26 :         m_sDescription += OUString(RTL_CONSTASCII_USTRINGPARAM(",uniqueValue="));
      39                 :            :         m_sDescription += OUString::valueOf(
      40                 :            :             sal::static_int_cast< sal_Int64 >(
      41                 :            :                 reinterpret_cast< sal_IntPtr >(&m_pipe)),
      42                 :         26 :             10 );
      43                 :         26 :     }
      44                 :            : 
      45         [ +  - ]:         24 :     PipeConnection::~PipeConnection()
      46                 :            :     {
      47         [ +  - ]:         24 :         g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
      48         [ -  + ]:         48 :     }
      49                 :            : 
      50                 :        836 :     sal_Int32 PipeConnection::read( Sequence < sal_Int8 > & aReadBytes , sal_Int32 nBytesToRead )
      51                 :            :             throw(::com::sun::star::io::IOException,
      52                 :            :                   ::com::sun::star::uno::RuntimeException)
      53                 :            :     {
      54         [ +  - ]:        836 :         if( ! m_nStatus )
      55                 :            :         {
      56         [ +  - ]:        836 :             if( aReadBytes.getLength() != nBytesToRead )
      57                 :            :             {
      58                 :        836 :                 aReadBytes.realloc( nBytesToRead );
      59                 :            :             }
      60                 :        836 :             return m_pipe.read( aReadBytes.getArray()  , aReadBytes.getLength() );
      61                 :            :         }
      62                 :            :         else {
      63         [ #  # ]:          0 :             throw IOException();
      64                 :            :         }
      65                 :            :     }
      66                 :            : 
      67                 :        376 :     void PipeConnection::write( const Sequence < sal_Int8 > &seq )
      68                 :            :             throw(::com::sun::star::io::IOException,
      69                 :            :                   ::com::sun::star::uno::RuntimeException)
      70                 :            :     {
      71         [ +  - ]:        376 :         if( ! m_nStatus )
      72                 :            :         {
      73         [ -  + ]:        376 :             if( m_pipe.write( seq.getConstArray() , seq.getLength() ) != seq.getLength() )
      74                 :            :             {
      75         [ #  # ]:          0 :                 throw IOException();
      76                 :            :             }
      77                 :            :         }
      78                 :            :         else {
      79         [ #  # ]:          0 :             throw IOException();
      80                 :            :         }
      81                 :        376 :     }
      82                 :            : 
      83                 :          0 :     void PipeConnection::flush( )
      84                 :            :             throw(::com::sun::star::io::IOException,
      85                 :            :                   ::com::sun::star::uno::RuntimeException)
      86                 :            :     {
      87                 :            : 
      88                 :          0 :     }
      89                 :            : 
      90                 :          2 :     void PipeConnection::close()
      91                 :            :             throw(::com::sun::star::io::IOException,
      92                 :            :                   ::com::sun::star::uno::RuntimeException)
      93                 :            :     {
      94                 :            :         // ensure that close is called only once
      95         [ +  - ]:          2 :         if(1 == osl_incrementInterlockedCount( (&m_nStatus) ) )
      96                 :            :         {
      97                 :          2 :             m_pipe.close();
      98                 :            :         }
      99                 :          2 :     }
     100                 :            : 
     101                 :          0 :     OUString PipeConnection::getDescription()
     102                 :            :             throw( ::com::sun::star::uno::RuntimeException)
     103                 :            :     {
     104                 :          0 :         return m_sDescription;
     105                 :            :     }
     106                 :            : 
     107                 :            : }
     108                 :            : 
     109                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10