12f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32f86921cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42f86921cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52f86921cSAndrew Rist  * distributed with this work for additional information
62f86921cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72f86921cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
82f86921cSAndrew Rist  * "License"); you may not use this file except in compliance
92f86921cSAndrew Rist  * with the License.  You may obtain a copy of the License at
102f86921cSAndrew Rist  *
112f86921cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122f86921cSAndrew Rist  *
132f86921cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
142f86921cSAndrew Rist  * software distributed under the License is distributed on an
152f86921cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162f86921cSAndrew Rist  * KIND, either express or implied.  See the License for the
172f86921cSAndrew Rist  * specific language governing permissions and limitations
182f86921cSAndrew Rist  * under the License.
192f86921cSAndrew Rist  *
202f86921cSAndrew Rist  *************************************************************/
212f86921cSAndrew Rist 
222f86921cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25*421ed02eSdamjan #include "precompiled_cacher.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <cacheddynamicresultset.hxx>
28cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
29cdf0e10cSrcweir #include <cachedcontentresultset.hxx>
30cdf0e10cSrcweir #include <osl/diagnose.h>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace com::sun::star::lang;
33cdf0e10cSrcweir using namespace com::sun::star::sdbc;
34cdf0e10cSrcweir using namespace com::sun::star::ucb;
35cdf0e10cSrcweir using namespace com::sun::star::uno;
36cdf0e10cSrcweir using namespace rtl;
37cdf0e10cSrcweir 
CachedDynamicResultSet(Reference<XDynamicResultSet> xOrigin,const Reference<XContentIdentifierMapping> & xContentMapping,const Reference<XMultiServiceFactory> & xSMgr)38cdf0e10cSrcweir CachedDynamicResultSet::CachedDynamicResultSet(
39cdf0e10cSrcweir 		Reference< XDynamicResultSet > xOrigin
40cdf0e10cSrcweir 		, const Reference< XContentIdentifierMapping > & xContentMapping
41cdf0e10cSrcweir 		, const Reference< XMultiServiceFactory > & xSMgr )
42cdf0e10cSrcweir 		: DynamicResultSetWrapper( xOrigin, xSMgr )
43cdf0e10cSrcweir 		, m_xContentIdentifierMapping( xContentMapping )
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 	impl_init();
46cdf0e10cSrcweir }
47cdf0e10cSrcweir 
~CachedDynamicResultSet()48cdf0e10cSrcweir CachedDynamicResultSet::~CachedDynamicResultSet()
49cdf0e10cSrcweir {
50cdf0e10cSrcweir 	impl_deinit();
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //virtual
54cdf0e10cSrcweir void SAL_CALL CachedDynamicResultSet
impl_InitResultSetOne(const Reference<XResultSet> & xResultSet)55cdf0e10cSrcweir 	::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 	DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
58cdf0e10cSrcweir 	OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	Reference< XResultSet > xCache(
61cdf0e10cSrcweir         new CachedContentResultSet( m_xSMgr, m_xSourceResultOne, m_xContentIdentifierMapping ) );
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
64cdf0e10cSrcweir 	m_xMyResultOne = xCache;
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir //virtual
68cdf0e10cSrcweir void SAL_CALL CachedDynamicResultSet
impl_InitResultSetTwo(const Reference<XResultSet> & xResultSet)69cdf0e10cSrcweir 	::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
72cdf0e10cSrcweir 	OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	Reference< XResultSet > xCache(
75cdf0e10cSrcweir         new CachedContentResultSet( m_xSMgr, m_xSourceResultTwo, m_xContentIdentifierMapping ) );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_aMutex );
78cdf0e10cSrcweir 	m_xMyResultTwo = xCache;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir //--------------------------------------------------------------------------
82cdf0e10cSrcweir // XInterface methods.
83cdf0e10cSrcweir //--------------------------------------------------------------------------
XINTERFACE_COMMON_IMPL(CachedDynamicResultSet)84cdf0e10cSrcweir XINTERFACE_COMMON_IMPL( CachedDynamicResultSet )
85cdf0e10cSrcweir 
86cdf0e10cSrcweir Any SAL_CALL CachedDynamicResultSet
87cdf0e10cSrcweir 	::queryInterface( const Type&  rType )
88cdf0e10cSrcweir 	throw ( RuntimeException )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	//list all interfaces inclusive baseclasses of interfaces
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	Any aRet = DynamicResultSetWrapper::queryInterface( rType );
93cdf0e10cSrcweir 	if( aRet.hasValue() )
94cdf0e10cSrcweir 		return aRet;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	aRet = cppu::queryInterface( rType,
97cdf0e10cSrcweir 				static_cast< XTypeProvider* >( this )
98cdf0e10cSrcweir 				, static_cast< XServiceInfo* >( this )
99cdf0e10cSrcweir 				);
100cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir //--------------------------------------------------------------------------
104cdf0e10cSrcweir // XTypeProvider methods.
105cdf0e10cSrcweir //--------------------------------------------------------------------------
106cdf0e10cSrcweir //list all interfaces exclusive baseclasses
107cdf0e10cSrcweir XTYPEPROVIDER_IMPL_4( CachedDynamicResultSet
108cdf0e10cSrcweir 					, XTypeProvider
109cdf0e10cSrcweir 					, XServiceInfo
110cdf0e10cSrcweir 					, XDynamicResultSet
111cdf0e10cSrcweir 					, XSourceInitialization
112cdf0e10cSrcweir 					);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir //--------------------------------------------------------------------------
115cdf0e10cSrcweir // XServiceInfo methods.
116cdf0e10cSrcweir //--------------------------------------------------------------------------
117cdf0e10cSrcweir 
118cdf0e10cSrcweir XSERVICEINFO_NOFACTORY_IMPL_1( CachedDynamicResultSet,
119cdf0e10cSrcweir 				 		   OUString::createFromAscii(
120cdf0e10cSrcweir 							"com.sun.star.comp.ucb.CachedDynamicResultSet" ),
121cdf0e10cSrcweir 				 		   OUString::createFromAscii(
122cdf0e10cSrcweir 							CACHED_DRS_SERVICE_NAME ) );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir //--------------------------------------------------------------------------
125cdf0e10cSrcweir // own methds. ( inherited )
126cdf0e10cSrcweir //--------------------------------------------------------------------------
127cdf0e10cSrcweir //virtual
128cdf0e10cSrcweir void SAL_CALL CachedDynamicResultSet
impl_disposing(const EventObject & Source)129cdf0e10cSrcweir 	::impl_disposing( const EventObject& Source )
130cdf0e10cSrcweir 	throw( RuntimeException )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	DynamicResultSetWrapper::impl_disposing( Source );
133cdf0e10cSrcweir 	m_xContentIdentifierMapping.clear();
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir //--------------------------------------------------------------------------
137cdf0e10cSrcweir //--------------------------------------------------------------------------
138cdf0e10cSrcweir // class CachedDynamicResultSetFactory
139cdf0e10cSrcweir //--------------------------------------------------------------------------
140cdf0e10cSrcweir //--------------------------------------------------------------------------
141cdf0e10cSrcweir 
CachedDynamicResultSetFactory(const Reference<XMultiServiceFactory> & rSMgr)142cdf0e10cSrcweir CachedDynamicResultSetFactory::CachedDynamicResultSetFactory(
143cdf0e10cSrcweir 		const Reference< XMultiServiceFactory > & rSMgr )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir 	m_xSMgr = rSMgr;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
~CachedDynamicResultSetFactory()148cdf0e10cSrcweir CachedDynamicResultSetFactory::~CachedDynamicResultSetFactory()
149cdf0e10cSrcweir {
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir //--------------------------------------------------------------------------
153cdf0e10cSrcweir // CachedDynamicResultSetFactory XInterface methods.
154cdf0e10cSrcweir //--------------------------------------------------------------------------
155cdf0e10cSrcweir 
156cdf0e10cSrcweir XINTERFACE_IMPL_3( CachedDynamicResultSetFactory,
157cdf0e10cSrcweir 				   XTypeProvider,
158cdf0e10cSrcweir 				   XServiceInfo,
159cdf0e10cSrcweir 				   XCachedDynamicResultSetFactory );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir //--------------------------------------------------------------------------
162cdf0e10cSrcweir // CachedDynamicResultSetFactory XTypeProvider methods.
163cdf0e10cSrcweir //--------------------------------------------------------------------------
164cdf0e10cSrcweir 
165cdf0e10cSrcweir XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetFactory,
166cdf0e10cSrcweir 					  XTypeProvider,
167cdf0e10cSrcweir 				   	  XServiceInfo,
168cdf0e10cSrcweir 					  XCachedDynamicResultSetFactory );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir //--------------------------------------------------------------------------
171cdf0e10cSrcweir // CachedDynamicResultSetFactory XServiceInfo methods.
172cdf0e10cSrcweir //--------------------------------------------------------------------------
173cdf0e10cSrcweir 
174cdf0e10cSrcweir XSERVICEINFO_IMPL_1( CachedDynamicResultSetFactory,
175cdf0e10cSrcweir 	 		   		 OUString::createFromAscii(
176cdf0e10cSrcweir 					 	"com.sun.star.comp.ucb.CachedDynamicResultSetFactory" ),
177cdf0e10cSrcweir 	 		   		 OUString::createFromAscii(
178cdf0e10cSrcweir 					 	CACHED_DRS_FACTORY_NAME ) );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir //--------------------------------------------------------------------------
181cdf0e10cSrcweir // Service factory implementation.
182cdf0e10cSrcweir //--------------------------------------------------------------------------
183cdf0e10cSrcweir 
184cdf0e10cSrcweir ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetFactory );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir //--------------------------------------------------------------------------
187cdf0e10cSrcweir // CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
188cdf0e10cSrcweir //--------------------------------------------------------------------------
189cdf0e10cSrcweir 
190cdf0e10cSrcweir //virtual
191cdf0e10cSrcweir Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
createCachedDynamicResultSet(const Reference<XDynamicResultSet> & SourceStub,const Reference<XContentIdentifierMapping> & ContentIdentifierMapping)192cdf0e10cSrcweir 	::createCachedDynamicResultSet(
193cdf0e10cSrcweir 		  const Reference< XDynamicResultSet > & SourceStub
194cdf0e10cSrcweir 		, const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
195cdf0e10cSrcweir 		throw( RuntimeException )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir 	Reference< XDynamicResultSet > xRet;
198cdf0e10cSrcweir 	xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xSMgr );
199cdf0e10cSrcweir 	return xRet;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 
203