1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBACCESS_ROWSETCACHEITERATOR_HXX
27cdf0e10cSrcweir #include "RowSetCacheIterator.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX
30cdf0e10cSrcweir #include "RowSetCache.hxx"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef DBACCESS_CORE_API_ROWSETBASE_HXX
33cdf0e10cSrcweir #include "RowSetBase.hxx"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <rtl/logfile.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using namespace dbaccess;
ORowSetCacheIterator(const ORowSetCacheIterator & _rRH)38cdf0e10cSrcweir ORowSetCacheIterator::ORowSetCacheIterator(const ORowSetCacheIterator& _rRH)
39cdf0e10cSrcweir : m_aIter(_rRH.m_aIter)
40cdf0e10cSrcweir , m_pCache(_rRH.m_pCache)
41cdf0e10cSrcweir ,m_pRowSet(_rRH.m_pRowSet)
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::ORowSetCacheIterator" );
44cdf0e10cSrcweir }
45cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator ORowSetMatrix::iterator()46cdf0e10cSrcweir ORowSetCacheIterator::operator ORowSetMatrix::iterator()
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 	return m_aIter->second.aIterator;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator =(const ORowSetCacheIterator & _rRH)51cdf0e10cSrcweir ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetCacheIterator& _rRH)
52cdf0e10cSrcweir {
53cdf0e10cSrcweir 	if(this == &_rRH)
54cdf0e10cSrcweir 		return *this;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	m_pCache = _rRH.m_pCache;
57cdf0e10cSrcweir 	m_aIter	 = _rRH.m_aIter;
58cdf0e10cSrcweir 	m_pRowSet = _rRH.m_pRowSet;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	return *this;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator =(const ORowSetMatrix::iterator & _rIter)63cdf0e10cSrcweir ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetMatrix::iterator& _rIter)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	m_aIter->second.aIterator = _rIter;
66cdf0e10cSrcweir 	return *this;
67cdf0e10cSrcweir }
68cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator *()69cdf0e10cSrcweir ORowSetRow& ORowSetCacheIterator::operator *()
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	return *m_aIter->second.aIterator;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator *() const74cdf0e10cSrcweir const ORowSetRow& ORowSetCacheIterator::operator *() const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
77cdf0e10cSrcweir 	{
78cdf0e10cSrcweir 		OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
79cdf0e10cSrcweir 		OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
80cdf0e10cSrcweir 		m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
81cdf0e10cSrcweir 	}
82cdf0e10cSrcweir 	return *m_aIter->second.aIterator;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator ->()85cdf0e10cSrcweir ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	return m_aIter->second.aIterator;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator ->() const90cdf0e10cSrcweir const ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->() const
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
93cdf0e10cSrcweir 	{
94cdf0e10cSrcweir 		OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
95cdf0e10cSrcweir 		OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
96cdf0e10cSrcweir 		m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir 	return m_aIter->second.aIterator;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator <=(const ORowSetMatrix::iterator & _rRH) const101cdf0e10cSrcweir bool ORowSetCacheIterator::operator <=(const ORowSetMatrix::iterator& _rRH) const
102cdf0e10cSrcweir {
103cdf0e10cSrcweir 	return m_aIter->second.aIterator <= _rRH;
104cdf0e10cSrcweir }
105cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator <(const ORowSetMatrix::iterator & _rRH) const106cdf0e10cSrcweir bool ORowSetCacheIterator::operator <(const ORowSetMatrix::iterator& _rRH) const
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	return m_aIter->second.aIterator < _rRH;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator !=(const ORowSetMatrix::iterator & _rRH) const111cdf0e10cSrcweir bool ORowSetCacheIterator::operator !=(const ORowSetMatrix::iterator& _rRH) const
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	return m_aIter->second.aIterator != _rRH;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir // -----------------------------------------------------------------------------
operator ==(const ORowSetMatrix::iterator & _rRH) const116cdf0e10cSrcweir bool ORowSetCacheIterator::operator ==(const ORowSetMatrix::iterator& _rRH) const
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	return m_aIter->second.aIterator == _rRH;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir // -----------------------------------------------------------------------------
setBookmark(const::com::sun::star::uno::Any & _rBookmark)121cdf0e10cSrcweir void ORowSetCacheIterator::setBookmark(const ::com::sun::star::uno::Any&	_rBookmark)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::setBookmark" );
124cdf0e10cSrcweir 	m_aIter->second.aBookmark = _rBookmark;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir // -----------------------------------------------------------------------------
isNull() const127cdf0e10cSrcweir sal_Bool ORowSetCacheIterator::isNull() const
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::isNull" );
130cdf0e10cSrcweir 	sal_Bool bRet = !m_pCache || !m_pRowSet || m_aIter == m_pCache->m_aCacheIterators.end();
131cdf0e10cSrcweir 	if ( !bRet )
132cdf0e10cSrcweir 	{
133cdf0e10cSrcweir 		ORowSetCacheIterator_Helper aHelper = m_aIter->second;
134cdf0e10cSrcweir 		bRet = ( m_pRowSet->isInsertRow()
135cdf0e10cSrcweir 			?
136cdf0e10cSrcweir 			m_aIter->second.aIterator == m_pCache->m_pInsertMatrix->end()
137cdf0e10cSrcweir 			:
138cdf0e10cSrcweir 			m_aIter->second.aIterator == m_pCache->m_pMatrix->end()
139cdf0e10cSrcweir 		);
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir 	return  bRet;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir // -----------------------------------------------------------------------------
getMutex() const144cdf0e10cSrcweir ::osl::Mutex* ORowSetCacheIterator::getMutex() const
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::getMutex" );
147cdf0e10cSrcweir 	return m_pRowSet ? m_pRowSet->getMutex() : NULL;
148cdf0e10cSrcweir }
149