gdb stacktraces for subsequentchecks
[LibreOffice.git] / binaryurp / source / writer.hxx
blob60d097e87647b98ca7ed5bbca866ceb93f7032bb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2011 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef INCLUDED_BINARYURP_SOURCE_WRITER_HXX
30 #define INCLUDED_BINARYURP_SOURCE_WRITER_HXX
32 #include "sal/config.h"
34 #include <cstddef>
35 #include <deque>
36 #include <vector>
38 #include "boost/noncopyable.hpp"
39 #include "osl/conditn.hxx"
40 #include "osl/mutex.hxx"
41 #include "osl/thread.hxx"
42 #include "rtl/byteseq.hxx"
43 #include "rtl/ref.hxx"
44 #include "rtl/ustring.hxx"
45 #include "sal/types.h"
46 #include "salhelper/simplereferenceobject.hxx"
47 #include "typelib/typedescription.hxx"
48 #include "uno/dispatcher.hxx"
50 #include "binaryany.hxx"
51 #include "marshal.hxx"
52 #include "writerstate.hxx"
54 namespace binaryurp { class Bridge; }
56 namespace binaryurp {
58 class Writer:
59 public osl::Thread, public salhelper::SimpleReferenceObject,
60 private boost::noncopyable
62 public:
63 static void * operator new(std::size_t size)
64 { return Thread::operator new(size); }
66 static void operator delete(void * pointer)
67 { Thread::operator delete(pointer); }
69 explicit Writer(rtl::Reference< Bridge > const & bridge);
71 // Only called from Bridge::reader_ thread, and only before Bridge::writer_
72 // thread is unblocked:
73 void sendDirectRequest(
74 rtl::ByteSequence const & tid, rtl::OUString const & oid,
75 com::sun::star::uno::TypeDescription const & type,
76 com::sun::star::uno::TypeDescription const & member,
77 std::vector< BinaryAny > const & inArguments);
79 // Only called from Bridge::reader_ thread, and only before Bridge::writer_
80 // thread is unblocked:
81 void sendDirectReply(
82 rtl::ByteSequence const & tid,
83 com::sun::star::uno::TypeDescription const & member,
84 bool exception, BinaryAny const & returnValue,
85 std::vector< BinaryAny > const & outArguments);
87 void queueRequest(
88 rtl::ByteSequence const & tid, rtl::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);
93 void queueReply(
94 rtl::ByteSequence const & tid,
95 com::sun::star::uno::TypeDescription const & member, bool setter,
96 bool exception, BinaryAny const & returnValue,
97 std::vector< BinaryAny > const & outArguments,
98 bool setCurrentContextMode);
100 void unblock();
102 void stop();
104 private:
105 virtual ~Writer();
107 virtual void SAL_CALL run();
109 virtual void SAL_CALL onTerminated();
111 void sendRequest(
112 rtl::ByteSequence const & tid, rtl::OUString const & oid,
113 com::sun::star::uno::TypeDescription const & type,
114 com::sun::star::uno::TypeDescription const & member,
115 std::vector< BinaryAny > const & inArguments, bool currentContextMode,
116 com::sun::star::uno::UnoInterfaceReference const & currentContext);
118 void sendReply(
119 rtl::ByteSequence const & tid,
120 com::sun::star::uno::TypeDescription const & member, bool setter,
121 bool exception, BinaryAny const & returnValue,
122 std::vector< BinaryAny > const & outArguments);
124 void sendMessage(std::vector< unsigned char > const & buffer);
126 struct Item {
127 Item();
129 // Request:
130 Item(
131 rtl::ByteSequence const & theTid, rtl::OUString const & theOid,
132 com::sun::star::uno::TypeDescription const & theType,
133 com::sun::star::uno::TypeDescription const & theMember,
134 std::vector< BinaryAny > const & inArguments,
135 com::sun::star::uno::UnoInterfaceReference const &
136 theCurrentContext);
138 // Reply:
139 Item(
140 rtl::ByteSequence const & theTid,
141 com::sun::star::uno::TypeDescription const & theMember,
142 bool theSetter, bool theException, BinaryAny const & theReturnValue,
143 std::vector< BinaryAny > const & outArguments,
144 bool theSetCurrentContextMode);
146 bool request;
148 rtl::ByteSequence tid; // request + reply
150 rtl::OUString oid; // request
152 com::sun::star::uno::TypeDescription type; // request
154 com::sun::star::uno::TypeDescription member; // request + reply
156 bool setter; // reply
158 std::vector< BinaryAny > arguments;
159 // request: inArguments; reply: outArguments
161 bool exception; // reply
163 BinaryAny returnValue; // reply
165 com::sun::star::uno::UnoInterfaceReference currentContext; // request
167 bool setCurrentContextMode; // reply
170 rtl::Reference< Bridge > bridge_;
171 WriterState state_;
172 Marshal marshal_;
173 com::sun::star::uno::TypeDescription lastType_;
174 rtl::OUString lastOid_;
175 rtl::ByteSequence lastTid_;
176 osl::Condition unblocked_;
177 osl::Condition items_;
179 osl::Mutex mutex_;
180 std::deque< Item > queue_;
181 bool stop_;
186 #endif
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */