36std::shared_ptr<INotificationService> NotificationService::instance_ =
nullptr;
43std::shared_ptr<INotificationService> NotificationService::snapshotInstance()
45 std::lock_guard<std::mutex> lock(g_notificationInstanceMutex);
56 std::lock_guard<std::mutex> lock(g_notificationInstanceMutex);
62 std::lock_guard<std::mutex> lock(g_notificationInstanceMutex);
63 instance_ = std::move(service);
68 if (
auto inst = snapshotInstance())
70 inst->info(message, duration);
76 if (
auto inst = snapshotInstance())
78 inst->success(message, duration);
84 if (
auto inst = snapshotInstance())
86 inst->warning(message, duration);
92 if (
auto inst = snapshotInstance())
94 inst->error(message, duration);
static void setInstance(std::shared_ptr< INotificationService > service)
Set the notification service implementation UI layer calls this at startup with its implementation.
static void success(const std::string &message, float duration=3.0f)
static void error(const std::string &message, float duration=5.0f)
static std::shared_ptr< INotificationService > instance()
Get the current notification service instance.
static void warning(const std::string &message, float duration=5.0f)
static void info(const std::string &message, float duration=3.0f)
Convenience methods that safely handle null instance.
std::mutex g_notificationInstanceMutex