update dev300-m58
[ooovba.git] / dbaccess / source / core / api / RowSetCacheIterator.cxx
blob0bdb7fc1063ba7c463be2b0aaf300726674ad755
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RowSetCacheIterator.cxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBACCESS_ROWSETCACHEITERATOR_HXX
34 #include "RowSetCacheIterator.hxx"
35 #endif
36 #ifndef DBACCESS_CORE_API_ROWSETCACHE_HXX
37 #include "RowSetCache.hxx"
38 #endif
39 #ifndef DBACCESS_CORE_API_ROWSETBASE_HXX
40 #include "RowSetBase.hxx"
41 #endif
42 #include <rtl/logfile.hxx>
44 using namespace dbaccess;
45 ORowSetCacheIterator::ORowSetCacheIterator(const ORowSetCacheIterator& _rRH)
46 : m_aIter(_rRH.m_aIter)
47 , m_pCache(_rRH.m_pCache)
48 ,m_pRowSet(_rRH.m_pRowSet)
50 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::ORowSetCacheIterator" );
52 // -----------------------------------------------------------------------------
53 ORowSetCacheIterator::operator ORowSetMatrix::iterator()
55 return m_aIter->second.aIterator;
57 // -----------------------------------------------------------------------------
58 ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetCacheIterator& _rRH)
60 if(this == &_rRH)
61 return *this;
63 m_pCache = _rRH.m_pCache;
64 m_aIter = _rRH.m_aIter;
65 m_pRowSet = _rRH.m_pRowSet;
67 return *this;
69 // -----------------------------------------------------------------------------
70 ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetMatrix::iterator& _rIter)
72 m_aIter->second.aIterator = _rIter;
73 return *this;
75 // -----------------------------------------------------------------------------
76 ORowSetRow& ORowSetCacheIterator::operator *()
78 return *m_aIter->second.aIterator;
80 // -----------------------------------------------------------------------------
81 const ORowSetRow& ORowSetCacheIterator::operator *() const
83 if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
85 OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
86 OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
87 m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
89 return *m_aIter->second.aIterator;
91 // -----------------------------------------------------------------------------
92 ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->()
94 return m_aIter->second.aIterator;
96 // -----------------------------------------------------------------------------
97 const ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->() const
99 if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
101 OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
102 OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
103 m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
105 return m_aIter->second.aIterator;
107 // -----------------------------------------------------------------------------
108 bool ORowSetCacheIterator::operator <=(const ORowSetMatrix::iterator& _rRH) const
110 return m_aIter->second.aIterator <= _rRH;
112 // -----------------------------------------------------------------------------
113 bool ORowSetCacheIterator::operator <(const ORowSetMatrix::iterator& _rRH) const
115 return m_aIter->second.aIterator < _rRH;
117 // -----------------------------------------------------------------------------
118 bool ORowSetCacheIterator::operator !=(const ORowSetMatrix::iterator& _rRH) const
120 return m_aIter->second.aIterator != _rRH;
122 // -----------------------------------------------------------------------------
123 bool ORowSetCacheIterator::operator ==(const ORowSetMatrix::iterator& _rRH) const
125 return m_aIter->second.aIterator == _rRH;
127 // -----------------------------------------------------------------------------
128 void ORowSetCacheIterator::setBookmark(const ::com::sun::star::uno::Any& _rBookmark)
130 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::setBookmark" );
131 m_aIter->second.aBookmark = _rBookmark;
133 // -----------------------------------------------------------------------------
134 sal_Bool ORowSetCacheIterator::isNull() const
136 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::isNull" );
137 sal_Bool bRet = !m_pCache || !m_pRowSet || m_aIter == m_pCache->m_aCacheIterators.end();
138 if ( !bRet )
140 ORowSetCacheIterator_Helper aHelper = m_aIter->second;
141 bRet = ( m_pRowSet->isInsertRow()
143 m_aIter->second.aIterator == m_pCache->m_pInsertMatrix->end()
145 m_aIter->second.aIterator == m_pCache->m_pMatrix->end()
148 return bRet;
150 // -----------------------------------------------------------------------------
151 ::osl::Mutex* ORowSetCacheIterator::getMutex() const
153 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::getMutex" );
154 return m_pRowSet ? m_pRowSet->getMutex() : NULL;