LCOV - code coverage report
Current view: top level - io/source/connector - connector.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4 0.0 %
Date: 2014-04-14 Functions: 0 2 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 <cppuhelper/implbase1.hxx>
      21             : #include <cppuhelper/implbase2.hxx>
      22             : 
      23             : #include <com/sun/star/connection/XConnection.hpp>
      24             : #include <com/sun/star/connection/XConnectionBroadcaster.hpp>
      25             : 
      26             : #include <boost/unordered_set.hpp>
      27             : #       include <osl/socket.hxx>
      28             : #       include <osl/pipe.hxx>
      29             : 
      30             : namespace stoc_connector
      31             : {
      32             :     template<class T>
      33             :     struct ReferenceHash
      34             :     {
      35           0 :         size_t operator () (const ::com::sun::star::uno::Reference<T> & ref) const
      36             :         {
      37           0 :             return (size_t)ref.get();
      38             :         }
      39             :     };
      40             : 
      41             :     template<class T>
      42             :     struct ReferenceEqual
      43             :     {
      44           0 :         sal_Bool operator () (const ::com::sun::star::uno::Reference<T> & op1,
      45             :                               const ::com::sun::star::uno::Reference<T> & op2) const
      46             :         {
      47           0 :             return op1.get() == op2.get();
      48             :         }
      49             :     };
      50             : 
      51             :     typedef ::boost::unordered_set< ::com::sun::star::uno::Reference< ::com::sun::star::io::XStreamListener>,
      52             :                              ReferenceHash< ::com::sun::star::io::XStreamListener>,
      53             :                              ReferenceEqual< ::com::sun::star::io::XStreamListener> >
      54             :             XStreamListener_hash_set;
      55             : 
      56             :     class PipeConnection :
      57             :         public ::cppu::WeakImplHelper1< ::com::sun::star::connection::XConnection >
      58             : 
      59             :     {
      60             :     public:
      61             :         PipeConnection( const OUString &sConnectionDescription );
      62             :         virtual ~PipeConnection();
      63             : 
      64             :         virtual sal_Int32 SAL_CALL read( ::com::sun::star::uno::Sequence< sal_Int8 >& aReadBytes,
      65             :                                          sal_Int32 nBytesToRead )
      66             :             throw(::com::sun::star::io::IOException,
      67             :                   ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      68             :         virtual void SAL_CALL write( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData )
      69             :             throw(::com::sun::star::io::IOException,
      70             :                   ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      71             :         virtual void SAL_CALL flush(  ) throw(
      72             :             ::com::sun::star::io::IOException,
      73             :             ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      74             :         virtual void SAL_CALL close(  )
      75             :             throw(::com::sun::star::io::IOException,
      76             :                   ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      77             :         virtual OUString SAL_CALL getDescription(  )
      78             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      79             :     public:
      80             :         ::osl::StreamPipe m_pipe;
      81             :         oslInterlockedCount m_nStatus;
      82             :         OUString m_sDescription;
      83             :     };
      84             : 
      85             :     class SocketConnection :
      86             :         public ::cppu::WeakImplHelper2< ::com::sun::star::connection::XConnection, ::com::sun::star::connection::XConnectionBroadcaster >
      87             : 
      88             :     {
      89             :     public:
      90             :         SocketConnection( const OUString & sConnectionDescription  );
      91             :         virtual ~SocketConnection();
      92             : 
      93             :         virtual sal_Int32 SAL_CALL read( ::com::sun::star::uno::Sequence< sal_Int8 >& aReadBytes,
      94             :                                          sal_Int32 nBytesToRead )
      95             :             throw(::com::sun::star::io::IOException,
      96             :                   ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      97             :         virtual void SAL_CALL write( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData )
      98             :             throw(::com::sun::star::io::IOException,
      99             :                   ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     100             :         virtual void SAL_CALL flush(  ) throw(
     101             :             ::com::sun::star::io::IOException,
     102             :             ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     103             :         virtual void SAL_CALL close(  )
     104             :             throw(::com::sun::star::io::IOException,
     105             :                   ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     106             :         virtual OUString SAL_CALL getDescription(  )
     107             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     108             : 
     109             : 
     110             :         // XConnectionBroadcaster
     111             :         virtual void SAL_CALL addStreamListener(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStreamListener>& aListener)
     112             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             :         virtual void SAL_CALL removeStreamListener(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStreamListener>& aListener)
     114             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             : 
     116             :     public:
     117             :         void completeConnectionString();
     118             : 
     119             :         ::osl::ConnectorSocket m_socket;
     120             :         ::osl::SocketAddr m_addr;
     121             :         oslInterlockedCount m_nStatus;
     122             :         OUString m_sDescription;
     123             : 
     124             :         ::osl::Mutex _mutex;
     125             :         sal_Bool     _started;
     126             :         sal_Bool     _closed;
     127             :         sal_Bool     _error;
     128             : 
     129             :           XStreamListener_hash_set _listeners;
     130             :     };
     131             : }
     132             : 
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10