gmessagestore.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 //
18 // gmessagestore.cpp
19 //
20 
21 #include "gdef.h"
22 #include "gsmtp.h"
23 #include "gmessagestore.h"
24 #include "glog.h"
25 #include "gassert.h"
26 
28 {
29 }
30 
31 // ===
32 
34  m_ref_count(1UL)
35 {
36 }
37 
39 {
40 }
41 
42 // ===
43 
45  m_imp(NULL)
46 {
47 }
48 
50  m_imp(imp)
51 {
52  G_ASSERT( m_imp->m_ref_count == 1UL ) ;
53 }
54 
55 std::auto_ptr<GSmtp::StoredMessage> GSmtp::MessageStore::Iterator::next()
56 {
57  return m_imp ? m_imp->next() : std::auto_ptr<StoredMessage>(NULL) ;
58 }
59 
61 {
62  if( m_imp )
63  {
64  m_imp->m_ref_count-- ;
65  if( m_imp->m_ref_count == 0UL )
66  delete m_imp ;
67  }
68 }
69 
71  m_imp(other.m_imp)
72 {
73  if( m_imp )
74  m_imp->m_ref_count++ ;
75 }
76 
78 {
79  if( this != &rhs )
80  {
81  if( m_imp )
82  {
83  m_imp->m_ref_count-- ;
84  if( m_imp->m_ref_count == 0UL )
85  delete m_imp ;
86  }
87  m_imp = rhs.m_imp ;
88  if( m_imp )
89  {
90  m_imp->m_ref_count++ ;
91  }
92  }
93  return *this ;
94 }
95 
97 {
98  IteratorImp * imp = m_imp ;
99  m_imp = NULL ;
100  delete imp ;
101 }
102 
A base class for MessageStore::Iterator implementations.
Definition: gmessagestore.h:52
std::auto_ptr< StoredMessage > next()
#define G_ASSERT(test)
Definition: gassert.h:30
virtual ~MessageStore()
Destructor.
Iterator & operator=(const Iterator &)
An iterator class for GSmtp::MessageStore.
Definition: gmessagestore.h:62