LCOV - code coverage report
Current view: top level - binaryurp/source - writer.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 3 3 100.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             : #ifndef INCLUDED_BINARYURP_SOURCE_WRITER_HXX
      21             : #define INCLUDED_BINARYURP_SOURCE_WRITER_HXX
      22             : 
      23             : #include "sal/config.h"
      24             : 
      25             : #include <deque>
      26             : #include <vector>
      27             : 
      28             : #include "osl/conditn.hxx"
      29             : #include "osl/mutex.hxx"
      30             : #include "rtl/byteseq.hxx"
      31             : #include "rtl/ref.hxx"
      32             : #include "rtl/ustring.hxx"
      33             : #include "salhelper/thread.hxx"
      34             : #include "typelib/typedescription.hxx"
      35             : #include "uno/dispatcher.hxx"
      36             : 
      37             : #include "binaryany.hxx"
      38             : #include "marshal.hxx"
      39             : #include "writerstate.hxx"
      40             : 
      41             : namespace binaryurp { class Bridge; }
      42             : 
      43             : namespace binaryurp {
      44             : 
      45             : class Writer: public salhelper::Thread
      46             : {
      47             : public:
      48             :     explicit Writer(rtl::Reference< Bridge > const & bridge);
      49             : 
      50             :     // Only called from Bridge::reader_ thread, and only before Bridge::writer_
      51             :     // thread is unblocked:
      52             :     void sendDirectRequest(
      53             :         rtl::ByteSequence const & tid, OUString const & oid,
      54             :         com::sun::star::uno::TypeDescription const & type,
      55             :         com::sun::star::uno::TypeDescription const & member,
      56             :         std::vector< BinaryAny > const & inArguments);
      57             : 
      58             :     // Only called from Bridge::reader_ thread, and only before Bridge::writer_
      59             :     // thread is unblocked:
      60             :     void sendDirectReply(
      61             :         rtl::ByteSequence const & tid,
      62             :         com::sun::star::uno::TypeDescription const & member,
      63             :         bool exception, BinaryAny const & returnValue,
      64             :         std::vector< BinaryAny > const & outArguments);
      65             : 
      66             :     void queueRequest(
      67             :         rtl::ByteSequence const & tid, OUString const & oid,
      68             :         com::sun::star::uno::TypeDescription const & type,
      69             :         com::sun::star::uno::TypeDescription const & member,
      70             :         std::vector< BinaryAny > const & inArguments);
      71             : 
      72             :     void queueReply(
      73             :         rtl::ByteSequence const & tid,
      74             :         com::sun::star::uno::TypeDescription const & member, bool setter,
      75             :         bool exception, BinaryAny const & returnValue,
      76             :         std::vector< BinaryAny > const & outArguments,
      77             :         bool setCurrentContextMode);
      78             : 
      79             :     void unblock();
      80             : 
      81             :     void stop();
      82             : 
      83             : private:
      84             :     virtual ~Writer();
      85             : 
      86             :     virtual void execute() SAL_OVERRIDE;
      87             : 
      88             :     void sendRequest(
      89             :         rtl::ByteSequence const & tid, OUString const & oid,
      90             :         com::sun::star::uno::TypeDescription const & type,
      91             :         com::sun::star::uno::TypeDescription const & member,
      92             :         std::vector< BinaryAny > const & inArguments, bool currentContextMode,
      93             :         com::sun::star::uno::UnoInterfaceReference const & currentContext);
      94             : 
      95             :     void sendReply(
      96             :         rtl::ByteSequence const & tid,
      97             :         com::sun::star::uno::TypeDescription const & member, bool setter,
      98             :         bool exception, BinaryAny const & returnValue,
      99             :         std::vector< BinaryAny > const & outArguments);
     100             : 
     101             :     void sendMessage(std::vector< unsigned char > const & buffer);
     102             : 
     103     1096152 :     struct Item {
     104             :         Item();
     105             : 
     106             :         // Request:
     107             :         Item(
     108             :             rtl::ByteSequence const & theTid, OUString const & theOid,
     109             :             com::sun::star::uno::TypeDescription const & theType,
     110             :             com::sun::star::uno::TypeDescription const & theMember,
     111             :             std::vector< BinaryAny > const & inArguments,
     112             :             com::sun::star::uno::UnoInterfaceReference const &
     113             :                 theCurrentContext);
     114             : 
     115             :         // Reply:
     116             :         Item(
     117             :             rtl::ByteSequence const & theTid,
     118             :             com::sun::star::uno::TypeDescription const & theMember,
     119             :             bool theSetter, bool theException, BinaryAny const & theReturnValue,
     120             :             std::vector< BinaryAny > const & outArguments,
     121             :             bool theSetCurrentContextMode);
     122             : 
     123             :         bool request;
     124             : 
     125             :         rtl::ByteSequence tid; // request + reply
     126             : 
     127             :         OUString oid; // request
     128             : 
     129             :         com::sun::star::uno::TypeDescription type; // request
     130             : 
     131             :         com::sun::star::uno::TypeDescription member; // request + reply
     132             : 
     133             :         bool setter; // reply
     134             : 
     135             :         std::vector< BinaryAny > arguments;
     136             :             // request: inArguments; reply: outArguments
     137             : 
     138             :         bool exception; // reply
     139             : 
     140             :         BinaryAny returnValue; // reply
     141             : 
     142             :         com::sun::star::uno::UnoInterfaceReference currentContext; // request
     143             : 
     144             :         bool setCurrentContextMode; // reply
     145             :     };
     146             : 
     147             :     rtl::Reference< Bridge > bridge_;
     148             :     WriterState state_;
     149             :     Marshal marshal_;
     150             :     com::sun::star::uno::TypeDescription lastType_;
     151             :     OUString lastOid_;
     152             :     rtl::ByteSequence lastTid_;
     153             :     osl::Condition unblocked_;
     154             :     osl::Condition items_;
     155             : 
     156             :     osl::Mutex mutex_;
     157             :     std::deque< Item > queue_;
     158             :     bool stop_;
     159             : };
     160             : 
     161             : }
     162             : 
     163             : #endif
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11