4 * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include <libicq2000/Contact.h>
29 #include <libicq2000/sigslot.h>
33 class ContactListEvent
;
35 class _ContactList_iterator
{
37 std::map
<unsigned int,ContactRef
>::iterator iter
;
40 _ContactList_iterator(std::map
<unsigned int,ContactRef
>::iterator i
)
43 _ContactList_iterator
& operator++() { ++iter
; return *this; }
44 _ContactList_iterator
operator++(int) { return _ContactList_iterator(iter
++); }
45 bool operator==(const _ContactList_iterator
& x
) const { return iter
== x
.iter
; }
46 bool operator!=(const _ContactList_iterator
& x
) const { return iter
!= x
.iter
; }
47 ContactRef
& operator*() { return (*iter
).second
; }
50 class _ContactList_const_iterator
{
52 std::map
<unsigned int,ContactRef
>::const_iterator iter
;
55 _ContactList_const_iterator(std::map
<unsigned int,ContactRef
>::const_iterator i
)
58 _ContactList_const_iterator
& operator++() { ++iter
; return *this; }
59 _ContactList_const_iterator
operator++(int) { return _ContactList_const_iterator(iter
++); }
60 bool operator==(const _ContactList_const_iterator
& x
) const { return iter
== x
.iter
; }
61 bool operator!=(const _ContactList_const_iterator
& x
) const { return iter
!= x
.iter
; }
62 const ContactRef
& operator*() { return (*iter
).second
; }
67 std::map
<unsigned int,ContactRef
> m_cmap
;
70 * Mobile contacts are implemented as
71 * Contact's and should still have UINs.
72 * Purely Mobile contacts will have imaginary UINs
73 * (ones counting down from -1), this is the best I could
74 * do to keep this consistent across board.
76 * It would be nice to have a hash off mobile# to contact
77 * but this was proving tricky to ensure consistency.
82 typedef _ContactList_iterator iterator
;
83 typedef _ContactList_const_iterator const_iterator
;
86 ContactList(const ContactList
& cl
);
87 ContactList(ContactRef ct
);
89 ContactRef
operator[](unsigned int uin
);
90 ContactRef
lookup_uin(unsigned int uin
);
91 ContactRef
lookup_mobile(const std::string
& m
);
92 ContactRef
lookup_email(const std::string
& em
);
93 ContactRef
add(ContactRef ct
);
94 void remove(unsigned int uin
);
96 unsigned int size() const;
99 bool exists(unsigned int uin
);
100 bool mobile_exists(const std::string
& m
);
101 bool email_exists(const std::string
& em
);
105 const_iterator
begin() const;
106 const_iterator
end() const;