aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2011-09-05 16:18:04 -0400
committerMatthew Hoops2011-09-05 16:18:04 -0400
commitdbb538dd048b7dc6c155a560dc847b98ba8c85cb (patch)
tree5c9764f047c7b26f0665a4568a77c310225bbbd6
parentfe99e953194c356136cd1e2edb87142e2c18b1e5 (diff)
downloadscummvm-rg350-dbb538dd048b7dc6c155a560dc847b98ba8c85cb.tar.gz
scummvm-rg350-dbb538dd048b7dc6c155a560dc847b98ba8c85cb.tar.bz2
scummvm-rg350-dbb538dd048b7dc6c155a560dc847b98ba8c85cb.zip
PEGASUS: Cleanup and hookup the notification code
-rwxr-xr-xengines/pegasus/MMShell/Notification/MMNotification.cpp99
-rwxr-xr-xengines/pegasus/MMShell/Notification/MMNotificationManager.cpp61
-rwxr-xr-xengines/pegasus/MMShell/Notification/MMNotificationManager.h58
-rwxr-xr-xengines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp46
-rwxr-xr-xengines/pegasus/MMShell/Notification/MMNotificationReceiver.h53
-rw-r--r--engines/pegasus/module.mk4
-rw-r--r--engines/pegasus/neighborhood/neighborhood.cpp7
-rw-r--r--engines/pegasus/neighborhood/neighborhood.h8
-rwxr-xr-xengines/pegasus/notification.cpp143
-rwxr-xr-xengines/pegasus/notification.h (renamed from engines/pegasus/MMShell/Notification/MMNotification.h)75
10 files changed, 212 insertions, 342 deletions
diff --git a/engines/pegasus/MMShell/Notification/MMNotification.cpp b/engines/pegasus/MMShell/Notification/MMNotification.cpp
deleted file mode 100755
index e91417a292..0000000000
--- a/engines/pegasus/MMShell/Notification/MMNotification.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/constants.h"
-#include "pegasus/MMShell/Notification/MMNotification.h"
-#include "pegasus/MMShell/Notification/MMNotificationManager.h"
-#include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
-
-namespace Pegasus {
-
-typedef tReceiverList::iterator tReceiverIterator;
-
-MMNotification::MMNotification(const tNotificationID id, MMNotificationManager *owner) : MMIDObject(id) {
- fOwner = owner;
- fCurrentFlags = kNoNotificationFlags;
- if (fOwner)
- fOwner->AddNotification(this);
-}
-
-MMNotification::~MMNotification() {
- for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++)
- it->fReceiver->NewNotification(NULL);
-
- if (fOwner)
- fOwner->RemoveNotification(this);
-}
-
-// Selectively set or clear notificiation bits.
-// Wherever mask is 0, leave existing bits untouched.
-// Wherever mask is 1, set bit equivalent to flags.
-void MMNotification::NotifyMe(MMNotificationReceiver* receiver, tNotificationFlags flags, tNotificationFlags mask) {
- for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++) {
- if (it->fReceiver == receiver) {
- it->fMask = (it->fMask & ~mask) | (flags & mask);
- receiver->NewNotification(this);
- return;
- }
- }
-
- tReceiverEntry newEntry;
- newEntry.fReceiver = receiver;
- newEntry.fMask = flags;
- fReceivers.push_back(newEntry);
-
- receiver->NewNotification(this);
-}
-
-void MMNotification::CancelNotification(MMNotificationReceiver *receiver) {
- for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++)
- if (it->fReceiver == receiver)
- fReceivers.erase(it);
-}
-
-void MMNotification::SetNotificationFlags(tNotificationFlags flags, tNotificationFlags mask) {
- fCurrentFlags = (fCurrentFlags & ~mask) | flags;
-}
-
-void MMNotification::CheckReceivers() {
- tNotificationFlags currentFlags = fCurrentFlags;
- fCurrentFlags = kNoNotificationFlags;
-
- for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++)
- if (it->fMask & currentFlags)
- it->fReceiver->ReceiveNotification(this, currentFlags);
-}
-
-// Receiver entries are equal if their receivers are equal.
-
-int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
- return entry1.fReceiver == entry2.fReceiver;
-}
-
-int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
- return entry1.fReceiver != entry2.fReceiver;
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp b/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
deleted file mode 100755
index 4bcaa794e8..0000000000
--- a/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/constants.h"
-#include "pegasus/MMShell/Notification/MMNotificationManager.h"
-
-namespace Pegasus {
-
-typedef tNotificationList::iterator tNotificationIterator;
-
-MMNotificationManager::MMNotificationManager() {
-}
-
-MMNotificationManager::~MMNotificationManager() {
- DetachNotifications();
-}
-
-void MMNotificationManager::AddNotification(MMNotification *notification) {
- fNotifications.push_back(notification);
-}
-
-void MMNotificationManager::RemoveNotification(MMNotification *notification) {
- for (tNotificationIterator it = fNotifications.begin(); it != fNotifications.end(); it++)
- if ((*it) == notification)
- fNotifications.erase(it);
-}
-
-void MMNotificationManager::DetachNotifications() {
- for (tNotificationIterator it = fNotifications.begin(); it != fNotifications.end(); it++)
- (*it)->fOwner = 0;
-}
-
-void MMNotificationManager::CheckNotifications() {
- for (tNotificationIterator it = fNotifications.begin(); it != fNotifications.end(); it++)
- if ((*it)->fCurrentFlags != kNoNotificationFlags)
- (*it)->CheckReceivers();
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationManager.h b/engines/pegasus/MMShell/Notification/MMNotificationManager.h
deleted file mode 100755
index 3df455fafd..0000000000
--- a/engines/pegasus/MMShell/Notification/MMNotificationManager.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONMANAGER_H
-#define PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONMANAGER_H
-
-#include "common/list.h"
-
-#include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
-
-namespace Pegasus {
-
-class MMNotification;
-
-typedef Common::List<MMNotification *> tNotificationList;
-
-class MMNotificationManager : public MMNotificationReceiver {
-friend class MMNotification;
-
-public:
- MMNotificationManager();
- virtual ~MMNotificationManager();
-
- void CheckNotifications();
-
-protected:
- void AddNotification(MMNotification *notification);
- void RemoveNotification(MMNotification *notification);
- void DetachNotifications();
-
- tNotificationList fNotifications;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
deleted file mode 100755
index 037cf185db..0000000000
--- a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
-
-namespace Pegasus {
-
-MMNotificationReceiver::MMNotificationReceiver() {
- fNotification = NULL;
-}
-
-MMNotificationReceiver::~MMNotificationReceiver() {
- if (fNotification)
- fNotification->CancelNotification(this);
-}
-
-void MMNotificationReceiver::ReceiveNotification(MMNotification *, const tNotificationFlags) {
-}
-
-void MMNotificationReceiver::NewNotification(MMNotification *notification) {
- fNotification = notification;
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
deleted file mode 100755
index cb72047f37..0000000000
--- a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONRECEIVER_H
-#define PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONRECEIVER_H
-
-#include "pegasus/MMShell/Notification/MMNotification.h"
-
-namespace Pegasus {
-
-class MMNotificationReceiver {
-friend class MMNotification;
-
-public:
- MMNotificationReceiver();
- virtual ~MMNotificationReceiver();
-
-protected:
- // ReceiveNotification is called automatically whenever a notification that this
- // receiver depends on has its flags set
-
- virtual void ReceiveNotification(MMNotification *, const tNotificationFlags);
- virtual void NewNotification(MMNotification *notification);
-
-private:
- MMNotification *fNotification;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 7a2d5b1a2c..642e94a017 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS = \
graphics.o \
hotspot.o \
menu.o \
+ notification.o \
overview.o \
pegasus.o \
sound.o \
@@ -18,9 +19,6 @@ MODULE_OBJS = \
items/biochips/biochipitem.o \
items/inventory/inventoryitem.o \
MMShell/Base_Classes/MMFunctionPtr.o \
- MMShell/Notification/MMNotification.o \
- MMShell/Notification/MMNotificationManager.o \
- MMShell/Notification/MMNotificationReceiver.o \
MMShell/Utilities/MMResourceFile.o \
MMShell/Utilities/MMTimeValue.o \
MMShell/Utilities/MMUtilities.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index cf4a29ee15..8048fa4240 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -108,6 +108,13 @@ void Neighborhood::start() {
arriveAt(GameState.getNextRoom(), GameState.getNextDirection());
}
+void Neighborhood::receiveNotification(Notification *, const tNotificationFlags flags) {
+ if (flags & kMoveForwardCompletedFlag)
+ arriveAt(GameState.getNextRoom(), GameState.getNextDirection());
+
+ // TODO: Other types
+}
+
void Neighborhood::arriveAt(tRoomID room, tDirectionConstant direction) {
// TODO
}
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 269443c6af..d567a5b3d3 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -30,6 +30,7 @@
#include "common/str.h"
#include "pegasus/hotspot.h"
+#include "pegasus/notification.h"
#include "pegasus/sound.h"
#include "pegasus/MMShell/Utilities/MMIDObject.h"
#include "pegasus/neighborhood/door.h"
@@ -43,7 +44,6 @@
namespace Pegasus {
-class MMNotification;
class PegasusEngine;
// Pegasus Prime neighborhood id's
@@ -76,7 +76,7 @@ struct tQueueRequest {
tInputBits interruptionFilter;
bool playing;
tNotificationFlags flags;
- MMNotification *notification;
+ Notification *notification;
};
bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2);
@@ -84,7 +84,7 @@ bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
-class Neighborhood : public MMIDObject {
+class Neighborhood : public MMIDObject, public NotificationReceiver {
public:
Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
virtual ~Neighborhood();
@@ -114,6 +114,8 @@ public:
virtual bool actionQueueEmpty() { return _actionQueue.empty(); }
protected:
+ virtual void receiveNotification(Notification *, const tNotificationFlags);
+
virtual void createNeighborhoodSpots();
virtual void loadSoundSpots();
diff --git a/engines/pegasus/notification.cpp b/engines/pegasus/notification.cpp
new file mode 100755
index 0000000000..f03e4705b7
--- /dev/null
+++ b/engines/pegasus/notification.cpp
@@ -0,0 +1,143 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/constants.h"
+#include "pegasus/notification.h"
+
+namespace Pegasus {
+
+typedef tReceiverList::iterator tReceiverIterator;
+
+Notification::Notification(const tNotificationID id, NotificationManager *owner) : MMIDObject(id) {
+ _owner = owner;
+ _currentFlags = kNoNotificationFlags;
+ if (_owner)
+ _owner->addNotification(this);
+}
+
+Notification::~Notification() {
+ for (tReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
+ it->receiver->newNotification(NULL);
+
+ if (_owner)
+ _owner->removeNotification(this);
+}
+
+// Selectively set or clear notificiation bits.
+// Wherever mask is 0, leave existing bits untouched.
+// Wherever mask is 1, set bit equivalent to flags.
+void Notification::notifyMe(NotificationReceiver *receiver, tNotificationFlags flags, tNotificationFlags mask) {
+ for (tReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++) {
+ if (it->receiver == receiver) {
+ it->mask = (it->mask & ~mask) | (flags & mask);
+ receiver->newNotification(this);
+ return;
+ }
+ }
+
+ tReceiverEntry newEntry;
+ newEntry.receiver = receiver;
+ newEntry.mask = flags;
+ _receivers.push_back(newEntry);
+
+ receiver->newNotification(this);
+}
+
+void Notification::cancelNotification(NotificationReceiver *receiver) {
+ for (tReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
+ if (it->receiver == receiver)
+ _receivers.erase(it);
+}
+
+void Notification::setNotificationFlags(tNotificationFlags flags, tNotificationFlags mask) {
+ _currentFlags = (_currentFlags & ~mask) | flags;
+}
+
+void Notification::checkReceivers() {
+ tNotificationFlags currentFlags = _currentFlags;
+ _currentFlags = kNoNotificationFlags;
+
+ for (tReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
+ if (it->mask & currentFlags)
+ it->receiver->receiveNotification(this, currentFlags);
+}
+
+// Receiver entries are equal if their receivers are equal.
+
+int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
+ return entry1.receiver == entry2.receiver;
+}
+
+int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
+ return entry1.receiver != entry2.receiver;
+}
+
+NotificationReceiver::NotificationReceiver() {
+ _notification = NULL;
+}
+
+NotificationReceiver::~NotificationReceiver() {
+ if (_notification)
+ _notification->cancelNotification(this);
+}
+
+void NotificationReceiver::receiveNotification(Notification *, const tNotificationFlags) {
+}
+
+void NotificationReceiver::newNotification(Notification *notification) {
+ _notification = notification;
+}
+
+typedef tNotificationList::iterator tNotificationIterator;
+
+NotificationManager::NotificationManager() {
+}
+
+NotificationManager::~NotificationManager() {
+ detachNotifications();
+}
+
+void NotificationManager::addNotification(Notification *notification) {
+ _notifications.push_back(notification);
+}
+
+void NotificationManager::removeNotification(Notification *notification) {
+ for (tNotificationIterator it = _notifications.begin(); it != _notifications.end(); it++)
+ if ((*it) == notification)
+ _notifications.erase(it);
+}
+
+void NotificationManager::detachNotifications() {
+ for (tNotificationIterator it = _notifications.begin(); it != _notifications.end(); it++)
+ (*it)->_owner = 0;
+}
+
+void NotificationManager::checkNotifications() {
+ for (tNotificationIterator it = _notifications.begin(); it != _notifications.end(); it++)
+ if ((*it)->_currentFlags != kNoNotificationFlags)
+ (*it)->checkReceivers();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotification.h b/engines/pegasus/notification.h
index 2c6ddddcd2..d276f456ad 100755
--- a/engines/pegasus/MMShell/Notification/MMNotification.h
+++ b/engines/pegasus/notification.h
@@ -23,8 +23,8 @@
*
*/
-#ifndef PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATION_H
-#define PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATION_H
+#ifndef PEGASUS_NOTIFICATION_H
+#define PEGASUS_NOTIFICATION_H
#include "common/list.h"
@@ -33,12 +33,12 @@
namespace Pegasus {
-class MMNotificationManager;
-class MMNotificationReceiver;
+class NotificationManager;
+class NotificationReceiver;
struct tReceiverEntry {
- MMNotificationReceiver *fReceiver;
- tNotificationFlags fMask;
+ NotificationReceiver *receiver;
+ tNotificationFlags mask;
};
int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry1);
@@ -50,12 +50,12 @@ typedef Common::List<tReceiverEntry> tReceiverList;
A notification can have 32 flags associated with it, which can be user-defined.
*/
-class MMNotification : public MMIDObject {
-friend class MMNotificationManager;
+class Notification : public MMIDObject {
+friend class NotificationManager;
public:
- MMNotification(const tNotificationID id, MMNotificationManager *owner);
- virtual ~MMNotification();
+ Notification(const tNotificationID id, NotificationManager *owner);
+ virtual ~Notification();
// NotifyMe will have this receiver notified when any of the specified notification
// flags are set.
@@ -64,20 +64,57 @@ public:
// Can selectively set or clear notification bits by using the flags and mask argument.
- void NotifyMe(MMNotificationReceiver*, tNotificationFlags flags, tNotificationFlags mask);
- void CancelNotification(MMNotificationReceiver *receiver);
+ void notifyMe(NotificationReceiver*, tNotificationFlags flags, tNotificationFlags mask);
+ void cancelNotification(NotificationReceiver *receiver);
- void SetNotificationFlags(tNotificationFlags flags, tNotificationFlags mask);
- tNotificationFlags GetNotificationFlags() { return fCurrentFlags; }
+ void setNotificationFlags(tNotificationFlags flags, tNotificationFlags mask);
+ tNotificationFlags getNotificationFlags() { return _currentFlags; }
- void ClearNotificationFlags() { SetNotificationFlags(0, ~(tNotificationFlags)0); }
+ void clearNotificationFlags() { setNotificationFlags(0, ~(tNotificationFlags)0); }
protected:
- void CheckReceivers();
+ void checkReceivers();
- MMNotificationManager *fOwner;
- tReceiverList fReceivers;
- tNotificationFlags fCurrentFlags;
+ NotificationManager *_owner;
+ tReceiverList _receivers;
+ tNotificationFlags _currentFlags;
+};
+
+class NotificationReceiver {
+friend class Notification;
+
+public:
+ NotificationReceiver();
+ virtual ~NotificationReceiver();
+
+protected:
+ // ReceiveNotification is called automatically whenever a notification that this
+ // receiver depends on has its flags set
+
+ virtual void receiveNotification(Notification *, const tNotificationFlags);
+ virtual void newNotification(Notification *notification);
+
+private:
+ Notification *_notification;
+};
+
+typedef Common::List<Notification *> tNotificationList;
+
+class NotificationManager : public NotificationReceiver {
+friend class Notification;
+
+public:
+ NotificationManager();
+ virtual ~NotificationManager();
+
+ void checkNotifications();
+
+protected:
+ void addNotification(Notification *notification);
+ void removeNotification(Notification *notification);
+ void detachNotifications();
+
+ tNotificationList _notifications;
};
} // End of namespace Pegasus