1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_IO_SOURCE_CONNECTOR_CONNECTOR_HXX
21 #define INCLUDED_IO_SOURCE_CONNECTOR_CONNECTOR_HXX
23 #include <cppuhelper/implbase.hxx>
25 #include <com/sun/star/connection/XConnection.hpp>
26 #include <com/sun/star/connection/XConnectionBroadcaster.hpp>
28 #include <unordered_set>
29 #include <osl/socket.hxx>
30 #include <osl/pipe.hxx>
32 namespace stoc_connector
34 typedef std::unordered_set
< css::uno::Reference
< css::io::XStreamListener
> >
35 XStreamListener_hash_set
;
37 class PipeConnection
:
38 public ::cppu::WeakImplHelper
< css::connection::XConnection
>
42 explicit PipeConnection( const OUString
&sConnectionDescription
);
43 virtual ~PipeConnection() override
;
45 virtual sal_Int32 SAL_CALL
read( css::uno::Sequence
< sal_Int8
>& aReadBytes
,
46 sal_Int32 nBytesToRead
) override
;
47 virtual void SAL_CALL
write( const css::uno::Sequence
< sal_Int8
>& aData
) override
;
48 virtual void SAL_CALL
flush( ) override
;
49 virtual void SAL_CALL
close( ) override
;
50 virtual OUString SAL_CALL
getDescription( ) override
;
52 ::osl::StreamPipe m_pipe
;
53 oslInterlockedCount m_nStatus
;
54 OUString m_sDescription
;
57 class SocketConnection
:
58 public ::cppu::WeakImplHelper
< css::connection::XConnection
, css::connection::XConnectionBroadcaster
>
62 explicit SocketConnection( const OUString
& sConnectionDescription
);
63 virtual ~SocketConnection() override
;
65 virtual sal_Int32 SAL_CALL
read( css::uno::Sequence
< sal_Int8
>& aReadBytes
,
66 sal_Int32 nBytesToRead
) override
;
67 virtual void SAL_CALL
write( const css::uno::Sequence
< sal_Int8
>& aData
) override
;
68 virtual void SAL_CALL
flush( ) override
;
69 virtual void SAL_CALL
close( ) override
;
70 virtual OUString SAL_CALL
getDescription( ) override
;
73 // XConnectionBroadcaster
74 virtual void SAL_CALL
addStreamListener(const css::uno::Reference
< css::io::XStreamListener
>& aListener
) override
;
75 virtual void SAL_CALL
removeStreamListener(const css::uno::Reference
< css::io::XStreamListener
>& aListener
) override
;
78 void completeConnectionString();
80 ::osl::ConnectorSocket m_socket
;
81 oslInterlockedCount m_nStatus
;
82 OUString m_sDescription
;
89 XStreamListener_hash_set _listeners
;
93 #endif // INCLUDED_IO_SOURCE_CONNECTOR_CONNECTOR_HXX
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */