Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / ucb / source / cacher / dynamicresultsetwrapper.hxx
blobba6b637b15e7570dba71d74a9243e9233caba712
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_UCB_SOURCE_CACHER_DYNAMICRESULTSETWRAPPER_HXX
21 #define INCLUDED_UCB_SOURCE_CACHER_DYNAMICRESULTSETWRAPPER_HXX
23 #include <osl/mutex.hxx>
24 #include <osl/conditn.hxx>
25 #include <cppuhelper/weak.hxx>
26 #include <comphelper/interfacecontainer2.hxx>
27 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
28 #include <com/sun/star/ucb/XSourceInitialization.hpp>
29 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
30 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <rtl/ref.hxx>
33 #include <memory>
35 class DynamicResultSetWrapperListener;
36 class DynamicResultSetWrapper
37 : public cppu::OWeakObject
38 , public css::ucb::XDynamicResultSet
39 , public css::ucb::XSourceInitialization
41 private:
42 //management of listeners
43 bool m_bDisposed; ///Dispose call ready.
44 bool m_bInDispose;///In dispose call
45 osl::Mutex m_aContainerMutex;
46 std::unique_ptr<comphelper::OInterfaceContainerHelper2>
47 m_pDisposeEventListeners;
48 protected:
49 rtl::Reference<DynamicResultSetWrapperListener>
50 m_xMyListenerImpl;
52 css::uno::Reference< css::uno::XComponentContext >
53 m_xContext;
55 osl::Mutex m_aMutex;
56 bool m_bStatic;
57 bool m_bGotWelcome;
59 //different Interfaces from Origin:
60 css::uno::Reference< css::ucb::XDynamicResultSet >
61 m_xSource;
62 css::uno::Reference< css::sdbc::XResultSet >
63 m_xSourceResultOne;
64 css::uno::Reference< css::sdbc::XResultSet >
65 m_xSourceResultTwo;
67 css::uno::Reference< css::sdbc::XResultSet >
68 m_xMyResultOne;
69 css::uno::Reference< css::sdbc::XResultSet >
70 m_xMyResultTwo;
72 css::uno::Reference< css::ucb::XDynamicResultSetListener >
73 m_xListener;
75 osl::Condition m_aSourceSet;
76 osl::Condition m_aListenerSet;
78 protected:
79 void impl_init();
80 void impl_deinit();
81 /// @throws css::lang::DisposedException
82 /// @throws css::uno::RuntimeException
83 void
84 impl_EnsureNotDisposed();
86 virtual void
87 impl_InitResultSetOne( const css::uno::Reference<
88 css::sdbc::XResultSet >& xResultSet );
89 virtual void
90 impl_InitResultSetTwo( const css::uno::Reference<
91 css::sdbc::XResultSet >& xResultSet );
93 public:
95 DynamicResultSetWrapper(
96 css::uno::Reference< css::ucb::XDynamicResultSet > const & xOrigin
97 , const css::uno::Reference< css::uno::XComponentContext > & rxContext );
99 virtual ~DynamicResultSetWrapper() override;
102 // XInterface
103 virtual css::uno::Any SAL_CALL
104 queryInterface( const css::uno::Type & rType ) override;
107 // XDynamicResultSet
108 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL
109 getStaticResultSet() override;
111 virtual void SAL_CALL
112 setListener( const css::uno::Reference< css::ucb::XDynamicResultSetListener > & Listener ) override;
114 virtual void SAL_CALL
115 connectToCache( const css::uno::Reference< css::ucb::XDynamicResultSet > & xCache ) override;
117 virtual sal_Int16 SAL_CALL
118 getCapabilities() override;
121 // XComponent ( base of XDynamicResultSet )
122 virtual void SAL_CALL
123 dispose() override;
125 virtual void SAL_CALL
126 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
128 virtual void SAL_CALL
129 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
132 // XSourceInitialization
134 virtual void SAL_CALL
135 setSource( const css::uno::Reference< css::uno::XInterface > & Source ) override;
138 // own methods:
139 /// @throws css::uno::RuntimeException
140 virtual void
141 impl_disposing( const css::lang::EventObject& Source );
143 /// @throws css::uno::RuntimeException
144 void
145 impl_notify( const css::ucb::ListEvent& Changes );
149 class DynamicResultSetWrapperListener
150 : public cppu::OWeakObject
151 , public css::ucb::XDynamicResultSetListener
153 protected:
154 DynamicResultSetWrapper* m_pOwner;
155 osl::Mutex m_aMutex;
157 public:
158 DynamicResultSetWrapperListener( DynamicResultSetWrapper* pOwner );
160 virtual ~DynamicResultSetWrapperListener() override;
163 // XInterface
164 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
165 virtual void SAL_CALL acquire()
166 throw() override;
167 virtual void SAL_CALL release()
168 throw() override;
170 // XEventListener ( base of XDynamicResultSetListener )
172 virtual void SAL_CALL
173 disposing( const css::lang::EventObject& Source ) override;
175 // XDynamicResultSetListener
176 virtual void SAL_CALL
177 notify( const css::ucb::ListEvent& Changes ) override;
180 // own methods:
181 void impl_OwnerDies();
185 #endif
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */