bump product version to 6.3.0.0.beta1
[LibreOffice.git] / binaryurp / source / writer.hxx
blob42ea687cea7ab91119ac249b256b41ef0fd3ca16
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_BINARYURP_SOURCE_WRITER_HXX
21 #define INCLUDED_BINARYURP_SOURCE_WRITER_HXX
23 #include <sal/config.h>
25 #include <deque>
26 #include <vector>
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>
37 #include "binaryany.hxx"
38 #include "marshal.hxx"
39 #include "writerstate.hxx"
41 namespace binaryurp { class Bridge; }
43 namespace binaryurp {
45 class Writer: public salhelper::Thread
47 public:
48 explicit Writer(rtl::Reference< Bridge > const & bridge);
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);
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);
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);
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);
79 void unblock();
81 void stop();
83 private:
84 virtual ~Writer() override;
86 virtual void execute() override;
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);
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);
101 void sendMessage(std::vector< unsigned char > const & buffer);
103 struct Item {
104 Item();
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);
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);
123 bool request;
125 rtl::ByteSequence tid; // request + reply
127 OUString oid; // request
129 com::sun::star::uno::TypeDescription type; // request
131 com::sun::star::uno::TypeDescription member; // request + reply
133 bool setter; // reply
135 std::vector< BinaryAny > arguments;
136 // request: inArguments; reply: outArguments
138 bool exception; // reply
140 BinaryAny returnValue; // reply
142 com::sun::star::uno::UnoInterfaceReference currentContext; // request
144 bool setCurrentContextMode; // reply
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_;
156 osl::Mutex mutex_;
157 std::deque< Item > queue_;
158 bool stop_;
163 #endif
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */