OpenCPN Partial API docs
Loading...
Searching...
No Matches
notification_manager.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2025 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
19
25#ifndef _NOTIFICATION_MANAGER_H__
26#define _NOTIFICATION_MANAGER_H__
27
28#include <wx/timer.h>
29#include "notification.h"
30#include "observable_evtvar.h"
31
34public:
35 static NotificationManager& GetInstance();
36
38 NotificationManager& operator=(const NotificationManager&) = delete;
39
40 std::string AddNotification(std::shared_ptr<Notification> _notification);
41
49 std::string AddNotification(NotificationSeverity _severity,
50 const std::string& _message,
51 int timeout_secs = -1);
57 bool AcknowledgeNotification(const std::string& guid);
58
60 NotificationSeverity GetMaxSeverity();
61
63 const std::vector<std::shared_ptr<Notification>>& GetNotifications() const {
64 return active_notifications;
65 }
66
67 size_t GetNotificationCount() const { return active_notifications.size(); }
68
71
72private:
74
75 void OnTimer(wxTimerEvent& event);
76
77 std::vector<std::shared_ptr<Notification>> active_notifications;
78 wxTimer m_timeout_timer;
79};
80
81#endif
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
The global list of user notifications, a singleton.
const std::vector< std::shared_ptr< Notification > > & GetNotifications() const
Return current active notifications.
bool AcknowledgeNotification(const std::string &guid)
User ack on a notification which eventually will remove it.
EventVar evt_notificationlist_change
Notified without data when a notification is added or removed.
NotificationSeverity GetMaxSeverity()
Return max severity among current active notifications.
Class Notification.