repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / mediaplayer / support / Notifier.h
blobdf4fa7553c140e3d8319ea73d8d892e1e0affe7c
1 /*
2 * Copyright 2006-2007, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 */
8 #ifndef NOTIFIER_H
9 #define NOTIFIER_H
11 #include <List.h>
13 class Listener;
15 class Notifier {
16 public:
17 Notifier();
18 virtual ~Notifier();
20 bool AddListener(Listener* listener);
21 bool RemoveListener(Listener* listener);
23 int32 CountListeners() const;
24 Listener* ListenerAtFast(int32 index) const;
26 void Notify() const;
28 void SuspendNotifications(bool suspend);
30 bool HasPendingNotifications() const
31 { return fPendingNotifications; }
33 private:
34 BList fListeners;
36 int32 fSuspended;
37 mutable bool fPendingNotifications;
40 class AutoNotificationSuspender {
41 public:
42 AutoNotificationSuspender(Notifier* object)
43 : fObject(object)
45 fObject->SuspendNotifications(true);
48 virtual ~AutoNotificationSuspender()
50 fObject->SuspendNotifications(false);
52 private:
53 Notifier* fObject;
56 #endif // NOTIFIER_H