LibreOffice Module binaryurp (master) 1
writer.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <sal/config.h>
23
24#include <deque>
25#include <mutex>
26#include <vector>
27
28#include <osl/conditn.hxx>
29#include <rtl/byteseq.hxx>
30#include <rtl/ref.hxx>
31#include <rtl/ustring.hxx>
32#include <salhelper/thread.hxx>
33#include <typelib/typedescription.hxx>
34#include <uno/dispatcher.hxx>
35
36#include "binaryany.hxx"
37#include "marshal.hxx"
38#include "writerstate.hxx"
39
40namespace binaryurp { class Bridge; }
41
42namespace binaryurp {
43
45{
46public:
47 explicit Writer(rtl::Reference< Bridge > const & bridge);
48
49 // Only called from Bridge::reader_ thread, and only before Bridge::writer_
50 // thread is unblocked:
52 rtl::ByteSequence const & tid, OUString const & oid,
53 com::sun::star::uno::TypeDescription const & type,
54 com::sun::star::uno::TypeDescription const & member,
55 std::vector< BinaryAny > const & inArguments);
56
57 // Only called from Bridge::reader_ thread, and only before Bridge::writer_
58 // thread is unblocked:
59 void sendDirectReply(
60 rtl::ByteSequence const & tid,
61 com::sun::star::uno::TypeDescription const & member,
62 bool exception, BinaryAny const & returnValue,
63 std::vector< BinaryAny > const & outArguments);
64
65 void queueRequest(
66 rtl::ByteSequence const & tid, OUString const & oid,
67 com::sun::star::uno::TypeDescription const & type,
68 com::sun::star::uno::TypeDescription const & member,
69 std::vector< BinaryAny >&& inArguments);
70
71 void queueReply(
72 rtl::ByteSequence const & tid,
73 com::sun::star::uno::TypeDescription const & member, bool setter,
74 bool exception, BinaryAny const & returnValue,
75 std::vector< BinaryAny >&& outArguments,
76 bool setCurrentContextMode);
77
78 void unblock();
79
80 void stop();
81
82private:
83 virtual ~Writer() override;
84
85 virtual void execute() override;
86
87 void sendRequest(
88 rtl::ByteSequence const & tid, OUString const & oid,
89 com::sun::star::uno::TypeDescription const & type,
90 com::sun::star::uno::TypeDescription const & member,
91 std::vector< BinaryAny > const & inArguments, bool currentContextMode,
92 com::sun::star::uno::UnoInterfaceReference const & currentContext);
93
94 void sendReply(
95 rtl::ByteSequence const & tid,
96 com::sun::star::uno::TypeDescription const & member, bool setter,
97 bool exception, BinaryAny const & returnValue,
98 std::vector< BinaryAny > const & outArguments);
99
100 void sendMessage(std::vector< unsigned char > const & buffer);
101
102 struct Item {
103 Item();
104
105 // Request:
107 rtl::ByteSequence theTid, OUString theOid,
108 com::sun::star::uno::TypeDescription theType,
109 com::sun::star::uno::TypeDescription theMember,
110 std::vector< BinaryAny >&& inArguments,
111 com::sun::star::uno::UnoInterfaceReference theCurrentContext);
112
113 // Reply:
115 rtl::ByteSequence theTid,
116 com::sun::star::uno::TypeDescription theMember,
117 bool theSetter, bool theException, BinaryAny theReturnValue,
118 std::vector< BinaryAny >&& outArguments,
119 bool theSetCurrentContextMode);
120
121 rtl::ByteSequence tid; // request + reply
122 OUString oid; // request
123 com::sun::star::uno::TypeDescription type; // request
124 com::sun::star::uno::TypeDescription member; // request + reply
125 com::sun::star::uno::UnoInterfaceReference currentContext; // request
127 std::vector< BinaryAny > arguments; // request: inArguments; reply: outArguments
129 bool setter; // reply
130 bool exception; // reply
132 };
133
137 com::sun::star::uno::TypeDescription lastType_;
138 OUString lastOid_;
139 rtl::ByteSequence lastTid_;
140 osl::Condition unblocked_;
141 osl::Condition items_;
142
143 std::mutex mutex_;
144 std::deque< Item > queue_;
145 bool stop_;
146};
147
148}
149
150/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::mutex mutex_
Definition: writer.hxx:143
Marshal marshal_
Definition: writer.hxx:136
void sendDirectReply(rtl::ByteSequence const &tid, com::sun::star::uno::TypeDescription const &member, bool exception, BinaryAny const &returnValue, std::vector< BinaryAny > const &outArguments)
Definition: writer.cxx:95
std::deque< Item > queue_
Definition: writer.hxx:144
void queueRequest(rtl::ByteSequence const &tid, OUString const &oid, com::sun::star::uno::TypeDescription const &type, com::sun::star::uno::TypeDescription const &member, std::vector< BinaryAny > &&inArguments)
Definition: writer.cxx:104
void sendRequest(rtl::ByteSequence const &tid, OUString const &oid, com::sun::star::uno::TypeDescription const &type, com::sun::star::uno::TypeDescription const &member, std::vector< BinaryAny > const &inArguments, bool currentContextMode, com::sun::star::uno::UnoInterfaceReference const &currentContext)
Definition: writer.cxx:192
osl::Condition items_
Definition: writer.hxx:141
com::sun::star::uno::TypeDescription lastType_
Definition: writer.hxx:137
void queueReply(rtl::ByteSequence const &tid, com::sun::star::uno::TypeDescription const &member, bool setter, bool exception, BinaryAny const &returnValue, std::vector< BinaryAny > &&outArguments, bool setCurrentContextMode)
Definition: writer.cxx:116
void sendDirectRequest(rtl::ByteSequence const &tid, OUString const &oid, com::sun::star::uno::TypeDescription const &type, com::sun::star::uno::TypeDescription const &member, std::vector< BinaryAny > const &inArguments)
Definition: writer.cxx:83
Writer(rtl::Reference< Bridge > const &bridge)
Definition: writer.cxx:76
rtl::ByteSequence lastTid_
Definition: writer.hxx:139
WriterState state_
Definition: writer.hxx:135
rtl::Reference< Bridge > bridge_
Definition: writer.hxx:134
virtual ~Writer() override
Definition: writer.cxx:145
void sendReply(rtl::ByteSequence const &tid, com::sun::star::uno::TypeDescription const &member, bool setter, bool exception, BinaryAny const &returnValue, std::vector< BinaryAny > const &outArguments)
Definition: writer.cxx:343
virtual void execute() override
Definition: writer.cxx:147
osl::Condition unblocked_
Definition: writer.hxx:140
void sendMessage(std::vector< unsigned char > const &buffer)
Definition: writer.cxx:410
OUString lastOid_
Definition: writer.hxx:138
std::vector< BinaryAny > arguments
Definition: writer.hxx:127
com::sun::star::uno::UnoInterfaceReference currentContext
Definition: writer.hxx:125
rtl::ByteSequence tid
Definition: writer.hxx:121
Item(rtl::ByteSequence theTid, OUString theOid, com::sun::star::uno::TypeDescription theType, com::sun::star::uno::TypeDescription theMember, std::vector< BinaryAny > &&inArguments, com::sun::star::uno::UnoInterfaceReference theCurrentContext)
com::sun::star::uno::TypeDescription member
Definition: writer.hxx:124
com::sun::star::uno::TypeDescription type
Definition: writer.hxx:123
Item(rtl::ByteSequence theTid, com::sun::star::uno::TypeDescription theMember, bool theSetter, bool theException, BinaryAny theReturnValue, std::vector< BinaryAny > &&outArguments, bool theSetCurrentContextMode)
ResultType type