cgma
|
#include <CubitObservable.hpp>
Public Member Functions | |
CubitObservable () | |
virtual | ~CubitObservable () |
void | get_observer_list (DLIList< CubitObserver * > &observers) |
void | notify_observers (const CubitEvent *event) |
Protected Member Functions | |
void | remove_from_observers () |
virtual CubitStatus | add_observer (CubitObserver *observer) |
virtual CubitStatus | remove_observer (CubitObserver *observer) |
CubitObservable (const CubitObservable &) | |
void | operator= (const CubitObservable &) |
Protected Attributes | |
DLIList< CubitObserver * > * | observerList |
Friends | |
class | CubitObserver |
class | CubitEventDispatcher |
Definition at line 15 of file CubitObservable.hpp.
Definition at line 5 of file CubitObservable.cpp.
{ observerList = NULL; }
CubitObservable::~CubitObservable | ( | ) | [virtual] |
Definition at line 10 of file CubitObservable.cpp.
{ if (observerList) { assert( (observerList->remove_all_with_value( NULL ), observerList->size() == 0) ); delete observerList; observerList = NULL; } }
CubitObservable::CubitObservable | ( | const CubitObservable & | ) | [protected] |
CubitStatus CubitObservable::add_observer | ( | CubitObserver * | observer | ) | [protected, virtual] |
Definition at line 21 of file CubitObservable.cpp.
{ if ( !observerList ) observerList = new DLIList <CubitObserver*>; if( observerList->append_unique( observer ) == CUBIT_TRUE ) { return CUBIT_SUCCESS; } return CUBIT_FAILURE; }
void CubitObservable::get_observer_list | ( | DLIList< CubitObserver * > & | observers | ) |
Definition at line 58 of file CubitObservable.cpp.
{ if (observerList) { for( int i = observerList->size(); i > 0; i-- ) { CubitObserver* observer = observerList->get_and_step(); if( observer ) observers.append( observer ); } } }
void CubitObservable::notify_observers | ( | const CubitEvent * | event | ) |
Definition at line 71 of file CubitObservable.cpp.
{ if ( ! observerList || observerList->size() == 0 ) return; CubitObserver *observer = NULL; for ( int i = 0; i < observerList->size(); i++ ) { observerList->reset(); observerList->step(i); observer = observerList->get(); if ( observer != NULL ) { observer->notify_observer(event); } } observerList->remove_all_with_value( NULL ); }
void CubitObservable::operator= | ( | const CubitObservable & | ) | [protected] |
void CubitObservable::remove_from_observers | ( | ) | [protected] |
Definition at line 52 of file CubitObservable.cpp.
{ if( observerList != NULL ) observerList->clean_out(); }
CubitStatus CubitObservable::remove_observer | ( | CubitObserver * | observer | ) | [protected, virtual] |
Definition at line 32 of file CubitObservable.cpp.
{ CubitStatus success = CUBIT_FAILURE; if( observerList != NULL ) { int i; for ( i = 0; i < observerList->size(); i++ ) { if ( observerList->get() == observer ) { success = CUBIT_SUCCESS; observerList->change_to( NULL ); break; } observerList->step(); } } return success; }
friend class CubitEventDispatcher [friend] |
Definition at line 21 of file CubitObservable.hpp.
friend class CubitObserver [friend] |
Definition at line 20 of file CubitObservable.hpp.
DLIList<CubitObserver*>* CubitObservable::observerList [protected] |
Definition at line 53 of file CubitObservable.hpp.