00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef CONTACTLIST_H
00023 #define CONTACTLIST_H
00024
00025 #include <string>
00026 #include <map>
00027
00028 #include <libicq2000/Contact.h>
00029 #include <sigc++/signal_system.h>
00030
00031 namespace ICQ2000 {
00032
00033 class ContactListEvent;
00034
00035 class _ContactList_iterator {
00036 private:
00037 std::map<unsigned int,ContactRef>::iterator iter;
00038
00039 public:
00040 _ContactList_iterator(std::map<unsigned int,ContactRef>::iterator i)
00041 : iter(i) { }
00042
00043 _ContactList_iterator& operator++() { ++iter; return *this; }
00044 _ContactList_iterator operator++(int) { return _ContactList_iterator(iter++); }
00045 bool operator==(const _ContactList_iterator& x) const { return iter == x.iter; }
00046 bool operator!=(const _ContactList_iterator& x) const { return iter != x.iter; }
00047 ContactRef& operator*() { return (*iter).second; }
00048 };
00049
00050 class _ContactList_const_iterator {
00051 private:
00052 std::map<unsigned int,ContactRef>::const_iterator iter;
00053
00054 public:
00055 _ContactList_const_iterator(std::map<unsigned int,ContactRef>::const_iterator i)
00056 : iter(i) { }
00057
00058 _ContactList_const_iterator& operator++() { ++iter; return *this; }
00059 _ContactList_const_iterator operator++(int) { return _ContactList_const_iterator(iter++); }
00060 bool operator==(const _ContactList_const_iterator& x) const { return iter == x.iter; }
00061 bool operator!=(const _ContactList_const_iterator& x) const { return iter != x.iter; }
00062 const ContactRef& operator*() { return (*iter).second; }
00063 };
00064
00065 class ContactList {
00066 private:
00067 std::map<unsigned int,ContactRef> m_cmap;
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 public:
00082 typedef _ContactList_iterator iterator;
00083 typedef _ContactList_const_iterator const_iterator;
00084
00085 ContactList();
00086 ContactList(const ContactList& cl);
00087
00088 ContactRef operator[](unsigned int uin);
00089 ContactRef lookup_uin(unsigned int uin);
00090 ContactRef lookup_mobile(const std::string& m);
00091 ContactRef lookup_email(const std::string& em);
00092 ContactRef add(ContactRef ct);
00093 void remove(unsigned int uin);
00094
00095 unsigned int size() const;
00096 bool empty() const;
00097
00098 bool exists(unsigned int uin);
00099 bool mobile_exists(const std::string& m);
00100 bool email_exists(const std::string& em);
00101
00102 iterator begin();
00103 iterator end();
00104 const_iterator begin() const;
00105 const_iterator end() const;
00106
00107 SigC::Signal1<void,ContactListEvent*> contactlist_signal;
00108 };
00109
00110 }
00111
00112 #endif