Chat-O-Matic/application/Notifier.cpp

51 lines
969 B
C++
Raw Normal View History

/*
2011-12-03 16:38:03 -06:00
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
* 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
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
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
Notifier::NotifyPointer(int32 what, void* ptr)
{
for (int i = 0; i < fObserverList.CountItems(); i++)
fObserverList.ItemAt(i)->ObservePointer(what, ptr);
}