Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

DCCache.h

00001 /*
00002  * DCCache
00003  *
00004  * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef DCCACHE_H
00023 #define DCCACHE_H
00024 
00025 #include <libicq2000/Cache.h>
00026 
00027 #include <sigc++/signal_system.h>
00028 
00029 using SigC::Signal1;
00030 
00031 namespace ICQ2000 {
00032 
00033   // fd -> DirectClient
00034   class DCCache : public Cache<int, DirectClient*> {
00035    public:
00036     DCCache() { }
00037 
00038     void removeItem(const DCCache::literator& l) {
00039       delete ((*l).getValue());
00040       Cache<int, DirectClient*>::removeItem(l);
00041     }
00042 
00043     void expireItem(const DCCache::literator& l) {
00044       expired.emit( (*l).getValue() );
00045       Cache<int, DirectClient*>::expireItem(l);
00046     }
00047 
00048     void removeContact(Contact *c) {
00049       literator curr = m_list.begin();
00050       literator next = curr;
00051       while ( curr != m_list.end() ) {
00052         DirectClient *dc = (*curr).getValue();
00053         ++next;
00054         if ( dc->getContact() == c ) {
00055           dc->setContact(NULL); // invalidate contact so the DC doesn't attempt to redeliver
00056           removeItem(curr);
00057         }
00058         curr = next;
00059       }
00060     }
00061 
00062     void clearoutMessagesPoll() {
00063       literator curr = m_list.begin();
00064       literator next = curr;
00065       while ( curr != m_list.end() ) {
00066         DirectClient *dc = (*curr).getValue();
00067         dc->clearoutMessagesPoll();
00068         ++curr;
00069       }
00070     }
00071 
00072     Signal1<void,DirectClient*> expired;
00073   };
00074   
00075 }
00076 
00077 #endif

Generated on Tue Jan 15 12:24:35 2002 for libicq2000 by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001