- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
27 GSmtp::MessageStore::~MessageStore()
28 {
29 }
30
31 // ===
32
33 GSmtp::MessageStore::IteratorImp::IteratorImp() :
34 m_ref_count(1UL)
35 {
36 }
37
38 GSmtp::MessageStore::IteratorImp::~IteratorImp()
39 {
40 }
41
42 // ===
43
44 GSmtp::MessageStore::Iterator::Iterator() :
45 m_imp(NULL)
46 {
47 }
48
49 GSmtp::MessageStore::Iterator::Iterator( IteratorImp * imp ) :
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
60 GSmtp::MessageStore::Iterator::~Iterator()
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
70 GSmtp::MessageStore::Iterator::Iterator( const Iterator & other ) :
71 m_imp(other.m_imp)
72 {
73 if( m_imp )
74 m_imp->m_ref_count++ ;
75 }
76
77 GSmtp::MessageStore::Iterator & GSmtp::MessageStore::Iterator::operator=( const Iterator & rhs )
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
96 void GSmtp::MessageStore::Iterator::last()
97 {
98 IteratorImp * imp = m_imp ;
99 m_imp = NULL ;
100 delete imp ;
101 }
102
GSmtp::MessageStore::IteratorImp::m_ref_count
unsigned long m_ref_count
Definition: gmessagestore.h:54
glog.h
GSmtp::MessageStore::Iterator::Iterator
Iterator()
Definition: gmessagestore.cpp:44
GSmtp::MessageStore::IteratorImp::~IteratorImp
virtual ~IteratorImp()
Definition: gmessagestore.cpp:38
GSmtp::MessageStore::IteratorImp
A base class for MessageStore::Iterator implementations.
Definition: gmessagestore.h:52
GSmtp::MessageStore::Iterator::next
std::auto_ptr< StoredMessage > next()
Definition: gmessagestore.cpp:55
G_ASSERT
#define G_ASSERT(test)
Definition: gassert.h:30
gassert.h
GSmtp::MessageStore::IteratorImp::IteratorImp
IteratorImp()
Definition: gmessagestore.cpp:33
gmessagestore.h
GSmtp::MessageStore::~MessageStore
virtual ~MessageStore()
Destructor.
Definition: gmessagestore.cpp:27
GSmtp::MessageStore::Iterator::operator=
Iterator & operator=(const Iterator &)
Definition: gmessagestore.cpp:77
GSmtp::MessageStore::Iterator::~Iterator
~Iterator()
Definition: gmessagestore.cpp:60
GSmtp::MessageStore::Iterator::last
void last()
Definition: gmessagestore.cpp:96
gsmtp.h
GSmtp::MessageStore::Iterator
An iterator class for GSmtp::MessageStore.
Definition: gmessagestore.h:62