#include "Observer.h"

/*****************************************************
*	Observable base class
*****************************************************/

void Observable::attach(Observer* observer)
{
    _observers.push_back(observer);
}

void Observable::detach(Observer* observer)
{
	_observers.remove(observer);
}

void Observable::notify()
{
    for (std::list<Observer*>::iterator iObserver = _observers.begin(); iObserver != _observers.end(); ++iObserver) {
		if (*iObserver) (*iObserver)->notify(this);
	}
}





/*****************************************************
*	Observer base class
*****************************************************/

void Observer::attach(Observable* observable)
{
    if (observable)
	    observable->attach(this);
}

void Observer::detach(Observable* observable)
{
    if (observable)
	    observable->detach(this);
}
