2010-05-07 04:47:10 -05:00
|
|
|
/*
|
2011-12-03 16:38:03 -06:00
|
|
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
2010-05-07 04:47:10 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Andrea Anzani, andrea.anzani@gmail.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Notifier.h"
|
|
|
|
#include "Observer.h"
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Notifier::RegisterObserver(Observer* obs)
|
|
|
|
{
|
|
|
|
if (!fObserverList.HasItem(obs))
|
|
|
|
fObserverList.AddItem(obs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Notifier::UnregisterObserver(Observer* obs)
|
|
|
|
{
|
|
|
|
if (fObserverList.HasItem(obs))
|
|
|
|
fObserverList.RemoveItem(obs, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-19 17:28:26 -05:00
|
|
|
void
|
2010-05-07 04:47:10 -05:00
|
|
|
Notifier::NotifyString(int32 what, BString str)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < fObserverList.CountItems(); i++)
|
|
|
|
fObserverList.ItemAt(i)->ObserveString(what, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-19 17:28:26 -05:00
|
|
|
void
|
2010-05-07 04:47:10 -05:00
|
|
|
Notifier::NotifyInteger(int32 what, int32 value)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < fObserverList.CountItems(); i++)
|
|
|
|
fObserverList.ItemAt(i)->ObserveInteger(what, value);
|
|
|
|
}
|
|
|
|
|
2010-05-19 17:28:26 -05:00
|
|
|
|
|
|
|
void
|
2010-05-07 04:47:10 -05:00
|
|
|
Notifier::NotifyPointer(int32 what, void* ptr)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < fObserverList.CountItems(); i++)
|
|
|
|
fObserverList.ItemAt(i)->ObservePointer(what, ptr);
|
|
|
|
}
|