Line data Source code
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 : #include "RowSetCacheIterator.hxx"
21 : #include "RowSetCache.hxx"
22 : #include "RowSetBase.hxx"
23 : #include <rtl/logfile.hxx>
24 :
25 : using namespace dbaccess;
26 0 : ORowSetCacheIterator::ORowSetCacheIterator(const ORowSetCacheIterator& _rRH)
27 : : m_aIter(_rRH.m_aIter)
28 : , m_pCache(_rRH.m_pCache)
29 0 : ,m_pRowSet(_rRH.m_pRowSet)
30 : {
31 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::ORowSetCacheIterator" );
32 0 : }
33 :
34 0 : ORowSetCacheIterator::operator ORowSetMatrix::iterator()
35 : {
36 0 : return m_aIter->second.aIterator;
37 : }
38 :
39 0 : ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetCacheIterator& _rRH)
40 : {
41 0 : if(this == &_rRH)
42 0 : return *this;
43 :
44 0 : m_pCache = _rRH.m_pCache;
45 0 : m_aIter = _rRH.m_aIter;
46 0 : m_pRowSet = _rRH.m_pRowSet;
47 :
48 0 : return *this;
49 : }
50 :
51 0 : ORowSetCacheIterator& ORowSetCacheIterator::operator =(const ORowSetMatrix::iterator& _rIter)
52 : {
53 0 : m_aIter->second.aIterator = _rIter;
54 0 : return *this;
55 : }
56 :
57 0 : ORowSetRow& ORowSetCacheIterator::operator *()
58 : {
59 0 : return *m_aIter->second.aIterator;
60 : }
61 :
62 0 : const ORowSetRow& ORowSetCacheIterator::operator *() const
63 : {
64 0 : if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
65 : {
66 : OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
67 0 : OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
68 0 : m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
69 : }
70 0 : return *m_aIter->second.aIterator;
71 : }
72 :
73 0 : ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->()
74 : {
75 0 : return m_aIter->second.aIterator;
76 : }
77 :
78 0 : const ORowSetMatrix::iterator& ORowSetCacheIterator::operator ->() const
79 : {
80 0 : if ( !m_pRowSet->isInsertRow() && m_aIter->second.aIterator == m_pCache->m_pMatrix->end() )
81 : {
82 : OSL_ENSURE(m_aIter->second.aBookmark.hasValue(),"bookmark has no value!");
83 0 : OSL_VERIFY(m_pCache->moveToBookmark(m_aIter->second.aBookmark));
84 0 : m_aIter->second.aIterator = m_pCache->m_aMatrixIter;
85 : }
86 0 : return m_aIter->second.aIterator;
87 : }
88 :
89 0 : bool ORowSetCacheIterator::operator <=(const ORowSetMatrix::iterator& _rRH) const
90 : {
91 0 : return m_aIter->second.aIterator <= _rRH;
92 : }
93 :
94 0 : bool ORowSetCacheIterator::operator <(const ORowSetMatrix::iterator& _rRH) const
95 : {
96 0 : return m_aIter->second.aIterator < _rRH;
97 : }
98 :
99 0 : bool ORowSetCacheIterator::operator !=(const ORowSetMatrix::iterator& _rRH) const
100 : {
101 0 : return m_aIter->second.aIterator != _rRH;
102 : }
103 :
104 0 : bool ORowSetCacheIterator::operator ==(const ORowSetMatrix::iterator& _rRH) const
105 : {
106 0 : return m_aIter->second.aIterator == _rRH;
107 : }
108 :
109 0 : void ORowSetCacheIterator::setBookmark(const ::com::sun::star::uno::Any& _rBookmark)
110 : {
111 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::setBookmark" );
112 0 : m_aIter->second.aBookmark = _rBookmark;
113 0 : }
114 :
115 0 : sal_Bool ORowSetCacheIterator::isNull() const
116 : {
117 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::isNull" );
118 0 : sal_Bool bRet = !m_pCache || !m_pRowSet || m_aIter == m_pCache->m_aCacheIterators.end();
119 0 : if ( !bRet )
120 : {
121 0 : ORowSetCacheIterator_Helper aHelper = m_aIter->second;
122 0 : bRet = ( m_pRowSet->isInsertRow()
123 : ?
124 0 : m_aIter->second.aIterator == m_pCache->m_pInsertMatrix->end()
125 : :
126 0 : m_aIter->second.aIterator == m_pCache->m_pMatrix->end()
127 0 : );
128 : }
129 0 : return bRet;
130 : }
131 :
132 0 : ::osl::Mutex* ORowSetCacheIterator::getMutex() const
133 : {
134 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSetCacheIterator::getMutex" );
135 0 : return m_pRowSet ? m_pRowSet->getMutex() : NULL;
136 : }
137 :
138 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|