LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
UiServices.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "IErrorPresenter.hpp"
5
6#include <memory>
7#include <mutex>
8
9namespace ui {
10
15public:
17 {
18 static UiServices instance;
19 return instance;
20 }
21
22 UiServices(const UiServices&) = delete;
23 UiServices& operator=(const UiServices&) = delete;
24
25 void SetErrorPresenter(std::shared_ptr<IErrorPresenter> presenter)
26 {
27 std::lock_guard<std::mutex> lock(m_mutex);
28 if (presenter) {
29 m_errorPresenter = std::move(presenter);
30 } else {
31 m_errorPresenter = std::make_shared<NoopErrorPresenter>();
32 }
33 }
34
35 std::shared_ptr<IErrorPresenter> GetErrorPresenter() const
36 {
37 std::lock_guard<std::mutex> lock(m_mutex);
38 return m_errorPresenter;
39 }
40
41private:
43 : m_errorPresenter(std::make_shared<NoopErrorPresenter>())
44 {
45 }
46
47 mutable std::mutex m_mutex;
48 std::shared_ptr<IErrorPresenter> m_errorPresenter;
49};
50
51} // namespace ui
Logger-backed fallback when no concrete UI presenter is registered.
Definition NoopErrorPresenter.hpp:13
Central registry for UI-facing service abstractions.
Definition UiServices.hpp:14
std::mutex m_mutex
Definition UiServices.hpp:47
UiServices(const UiServices &)=delete
void SetErrorPresenter(std::shared_ptr< IErrorPresenter > presenter)
Definition UiServices.hpp:25
UiServices & operator=(const UiServices &)=delete
std::shared_ptr< IErrorPresenter > m_errorPresenter
Definition UiServices.hpp:48
static UiServices & Instance()
Definition UiServices.hpp:16
UiServices()
Definition UiServices.hpp:42
std::shared_ptr< IErrorPresenter > GetErrorPresenter() const
Definition UiServices.hpp:35
Definition IErrorPresenter.hpp:5