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 <list>
00026 #include <string>
00027 #include <map>
00028 
00029 #include <libicq2000/Contact.h>
00030 
00031 using std::list;
00032 using std::string;
00033 using std::map;
00034 
00035 namespace ICQ2000 {
00036 
00037   class _ContactList_iterator {
00038   private:
00039     map<unsigned int,Contact>::iterator iter;
00040   
00041   public:
00042     _ContactList_iterator(map<unsigned int,Contact>::iterator i)
00043       : iter(i) { }
00044   
00045     _ContactList_iterator& operator++() { ++iter; return *this; }
00046     _ContactList_iterator operator++(int) { return _ContactList_iterator(iter++); }
00047     bool operator==(const _ContactList_iterator& x) const { return iter == x.iter; }
00048     bool operator!=(const _ContactList_iterator& x) const { return iter != x.iter; }
00049     Contact& operator*() const { return (*iter).second; }
00050   };
00051 
00052   class _ContactList_const_iterator {
00053   private:
00054     map<unsigned int,Contact>::const_iterator iter;
00055   
00056   public:
00057     _ContactList_const_iterator(map<unsigned int,Contact>::const_iterator i)
00058       : iter(i) { }
00059   
00060     _ContactList_const_iterator& operator++() { ++iter; return *this; }
00061     _ContactList_const_iterator operator++(int) { return _ContactList_const_iterator(iter++); }
00062     bool operator==(const _ContactList_const_iterator& x) const { return iter == x.iter; }
00063     bool operator!=(const _ContactList_const_iterator& x) const { return iter != x.iter; }
00064     const Contact& operator*() const { return (*iter).second; }
00065   };
00066 
00067   class ContactList {
00068   private:
00069     map<unsigned int,Contact> m_cmap;
00070 
00071     
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082   public:
00083     typedef _ContactList_iterator iterator;
00084     typedef _ContactList_const_iterator const_iterator;
00085 
00086     ContactList();
00087 
00088     Contact& operator[](unsigned int uin);
00089     Contact& operator[](const string& m);
00090     Contact& add(const Contact& ct);
00091     void remove(unsigned int uin);
00092 
00093     unsigned int size() const;
00094     bool empty() const;
00095 
00096     bool exists(unsigned int uin);
00097     bool exists(const string& m);
00098 
00099     iterator begin();
00100     const_iterator begin() const;
00101     iterator end();
00102     const_iterator end() const;
00103   };
00104 
00105 }
00106 
00107 #endif