isubject.cpp
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004
00005 #include "isubject.h"
00006 #include "iobserver.h"
00007 #include <kdebug.h>
00008
00009 namespace KMail {
00010
00011 ISubject::ISubject()
00012 {
00013 }
00014
00015 ISubject::~ISubject()
00016 {
00017 mObserverList.clear();
00018 }
00019
00020 void ISubject::attach( IObserver * pObserver )
00021 {
00022 if (mObserverList.find( pObserver ) == -1)
00023 mObserverList.append( pObserver );
00024 }
00025
00026 void ISubject::detach( IObserver * pObserver )
00027 {
00028 mObserverList.remove( pObserver );
00029 }
00030
00031 void ISubject::notify()
00032 {
00033 kdDebug(5006) << "ISubject::notify " << mObserverList.count() << endl;
00034 QPtrListIterator<IObserver> it( mObserverList );
00035 IObserver* observer;
00036 while ( (observer = it.current()) != 0 )
00037 {
00038 ++it;
00039 bool success = observer->update( this );
00040 if ( !success )
00041 kdWarning(5006) << "ISubject::notify returned false for observer " << observer << endl;
00042 }
00043 }
00044
00045 }
00046
This file is part of the documentation for kmail Library Version 3.2.2.