LibreOffice Module ucb (master)  1
cacheddynamicresultset.cxx
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 
23 #include <osl/diagnose.h>
25 #include <ucbhelper/macros.hxx>
26 
27 using namespace com::sun::star::lang;
28 using namespace com::sun::star::sdbc;
29 using namespace com::sun::star::ucb;
30 using namespace com::sun::star::uno;
31 
32 
34  Reference< XDynamicResultSet > const & xOrigin
35  , const Reference< XContentIdentifierMapping > & xContentMapping
36  , const Reference< XComponentContext > & xContext )
37  : DynamicResultSetWrapper( xOrigin, xContext )
38  , m_xContentIdentifierMapping( xContentMapping )
39 {
40  impl_init();
41 }
42 
44 {
45  impl_deinit();
46 }
47 
48 //virtual
49 void CachedDynamicResultSet
50  ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
51 {
53  OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
54 
56  new CachedContentResultSet( m_xContext, m_xSourceResultOne, m_xContentIdentifierMapping ) );
57 
58  osl::Guard< osl::Mutex > aGuard( m_aMutex );
59  m_xMyResultOne = xCache;
60 }
61 
62 //virtual
63 void CachedDynamicResultSet
64  ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
65 {
67  OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
68 
70  new CachedContentResultSet( m_xContext, m_xSourceResultTwo, m_xContentIdentifierMapping ) );
71 
72  osl::Guard< osl::Mutex > aGuard( m_aMutex );
73  m_xMyResultTwo = xCache;
74 }
75 
76 
77 // XInterface methods.
79  throw()
80 {
81  OWeakObject::acquire();
82 }
83 
85  throw()
86 {
87  OWeakObject::release();
88 }
89 
90 Any SAL_CALL CachedDynamicResultSet
91  ::queryInterface( const Type& rType )
92 {
93  //list all interfaces inclusive baseclasses of interfaces
94 
96  if( aRet.hasValue() )
97  return aRet;
98 
99  aRet = cppu::queryInterface( rType,
100  static_cast< XTypeProvider* >( this )
101  , static_cast< XServiceInfo* >( this )
102  );
103  return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
104 }
105 
106 
107 // XTypeProvider methods.
108 
109 //list all interfaces exclusive baseclasses
111  , XTypeProvider
112  , XServiceInfo
113  , XDynamicResultSet
114  , XSourceInitialization
115  );
116 
117 
118 // XServiceInfo methods.
119 
121 {
122  return "com.sun.star.comp.ucb.CachedDynamicResultSet";
123 }
124 
125 sal_Bool SAL_CALL CachedDynamicResultSet::supportsService( const OUString& ServiceName )
126 {
127  return cppu::supportsService( this, ServiceName );
128 }
129 
130 css::uno::Sequence< OUString > SAL_CALL CachedDynamicResultSet::getSupportedServiceNames()
131 {
132  return { "com.sun.star.ucb.CachedDynamicResultSet" };
133 }
134 
135 
136 // own methods. ( inherited )
137 
138 //virtual
139 void CachedDynamicResultSet
140  ::impl_disposing( const EventObject& Source )
141 {
143  m_xContentIdentifierMapping.clear();
144 }
145 
146 
147 
148 
150  const Reference< XComponentContext > & xContext )
151 {
152  m_xContext = xContext;
153 }
154 
156 {
157 }
158 
159 
160 // CachedDynamicResultSetFactory XServiceInfo methods.
161 
163 {
164  return "com.sun.star.comp.ucb.CachedDynamicResultSetFactory";
165 }
166 sal_Bool SAL_CALL CachedDynamicResultSetFactory::supportsService( const OUString& ServiceName )
167 {
168  return cppu::supportsService( this, ServiceName );
169 }
170 css::uno::Sequence< OUString > SAL_CALL CachedDynamicResultSetFactory::getSupportedServiceNames()
171 {
172  return { "com.sun.star.ucb.CachedDynamicResultSetFactory" };
173 }
174 
175 // Service factory implementation.
176 
177 
178 
179 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
181  css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
182 {
183  return cppu::acquire(new CachedDynamicResultSetFactory(context));
184 }
185 
186 // CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
187 
188 
189 //virtual
190 Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
191  ::createCachedDynamicResultSet(
192  const Reference< XDynamicResultSet > & SourceStub
193  , const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
194 {
195  Reference< XDynamicResultSet > xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xContext );
196  return xRet;
197 }
198 
199 
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void impl_InitResultSetTwo(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet)
Type
osl::Mutex m_aMutex
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
CachedDynamicResultSetFactory(const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL release() override
virtual void impl_disposing(const css::lang::EventObject &Source)
virtual void SAL_CALL acquire() override
CachedDynamicResultSet(css::uno::Reference< css::ucb::XDynamicResultSet > const &xOrigin, const css::uno::Reference< css::ucb::XContentIdentifierMapping > &xContentMapping, const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual void impl_InitResultSetOne(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet)
virtual ~CachedDynamicResultSet() override
unsigned char sal_Bool
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~CachedDynamicResultSetFactory() override
virtual OUString SAL_CALL getImplementationName() override
XTYPEPROVIDER_IMPL_4(CachedDynamicResultSet, XTypeProvider, XServiceInfo, XDynamicResultSet, XSourceInitialization)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
Reference< XComponentContext > m_xContext
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_CachedDynamicResultSetFactory_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)