Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / dbaccess / source / core / api / RowSetCacheIterator.cxx
bloba55b0d1796f2b92921143d8c99a11e030a7d04eb
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 #include "RowSetCacheIterator.hxx"
21 #include "RowSetCache.hxx"
22 #include "RowSetBase.hxx"
23 #include <rtl/logfile.hxx>
25 using namespace dbaccess;
26 ORowSetCacheIterator::ORowSetCacheIterator(const ORowSetCacheIterator& _rRH)
27 : m_aIter(_rRH.m_aIter)
28 , m_pCache(_rRH.m_pCache)
29 ,m_pRowSet(_rRH.m_pRowSet)
31 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::ORowSetCacheIterator" );
34 ORowSetCacheIterator::operator ORowSetMatrix::iterator()
36 return m_aIter->second.aIterator;
39 ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetCacheIterator& _rRH)
41 if(this == &_rRH)
42 return *this;
44 m_pCache = _rRH.m_pCache;
45 m_aIter = _rRH.m_aIter;
46 m_pRowSet = _rRH.m_pRowSet;
48 return *this;
51 ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetMatrix::iterator& _rIter)
53 m_aIter->second.aIterator = _rIter;
54 return *this;
57 ORowSetRow& ORowSetCacheIterator::operator *()
59 return *m_aIter->second.aIterator;
62 const ORowSetRow& ORowSetCacheIterator::operator *() const
64 if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
66 OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
67 OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
68 m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
70 return *m_aIter->second.aIterator;
73 ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->()
75 return m_aIter->second.aIterator;
78 const ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->() const
80 if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
82 OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
83 OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
84 m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
86 return m_aIter->second.aIterator;
89 bool ORowSetCacheIterator::operator <=(const ORowSetMatrix::iterator& _rRH) const
91 return m_aIter->second.aIterator <= _rRH;
94 bool ORowSetCacheIterator::operator <(const ORowSetMatrix::iterator& _rRH) const
96 return m_aIter->second.aIterator < _rRH;
99 bool ORowSetCacheIterator::operator !=(const ORowSetMatrix::iterator& _rRH) const
101 return m_aIter->second.aIterator != _rRH;
104 bool ORowSetCacheIterator::operator ==(const ORowSetMatrix::iterator& _rRH) const
106 return m_aIter->second.aIterator == _rRH;
109 void ORowSetCacheIterator::setBookmark(const ::com::sun::star::uno::Any& _rBookmark)
111 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::setBookmark" );
112 m_aIter->second.aBookmark = _rBookmark;
115 sal_Bool ORowSetCacheIterator::isNull() const
117 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::isNull" );
118 sal_Bool bRet = !m_pCache || !m_pRowSet || m_aIter == m_pCache->m_aCacheIterators.end();
119 if ( !bRet )
121 ORowSetCacheIterator_Helper aHelper = m_aIter->second;
122 bRet = ( m_pRowSet->isInsertRow()
124 m_aIter->second.aIterator == m_pCache->m_pInsertMatrix->end()
126 m_aIter->second.aIterator == m_pCache->m_pMatrix->end()
129 return bRet;
132 ::osl::Mutex* ORowSetCacheIterator::getMutex() const
134 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::getMutex" );
135 return m_pRowSet ? m_pRowSet->getMutex() : NULL;
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */