MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
System.cpp
Go to the documentation of this file.
1#include "System.hpp"
2
4
5#ifdef MAYAFLUX_PLATFORM_LINUX
7#elif defined(MAYAFLUX_PLATFORM_WINDOWS)
9#elif defined(MAYAFLUX_PLATFORM_MACOS)
11#endif
12
14
16
17namespace {
18 bool g_initialized {};
19 std::unique_ptr<Core::SystemBackend> g_backend;
20}
21
23{
24 return g_backend.get();
25}
26
28{
29 if (g_initialized) {
31 "Portal::System already initialized");
32 return true;
33 }
34
36 "Initializing Portal::System...");
37
38#ifdef MAYAFLUX_PLATFORM_LINUX
39 g_backend = std::make_unique<Core::DBusBackend>();
40#elif defined(MAYAFLUX_PLATFORM_WINDOWS)
41 g_backend = std::make_unique<Core::COMBackend>();
42#elif defined(MAYAFLUX_PLATFORM_MACOS)
43 g_backend = std::make_unique<Core::NSBackend>();
44#endif
45
46 if (!g_backend || !g_backend->initialize()) {
48 "Portal::System: backend initialization failed");
49 g_backend.reset();
50 return false;
51 }
52
53 g_initialized = true;
55 "Portal::System initialized");
56 return true;
57}
58
59void stop()
60{
61 if (!g_initialized) {
62 return;
63 }
64
66 "Portal::System stopped");
67}
68
70{
71 if (!g_initialized) {
72 return;
73 }
74
75 if (g_backend) {
76 g_backend->shutdown();
77 g_backend.reset();
78 }
79
80 g_initialized = false;
82 "Portal::System shutdown complete");
83}
84
86{
87 return g_initialized;
88}
89
90} // namespace MayaFlux::Portal::System
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
Abstract interface for native OS service backends.
@ API
API calls from external code.
@ Portal
High-level user-facing API layer.
bool initialize()
Initialize Portal::System.
Definition System.cpp:27
bool is_initialized()
Return true if Portal::System has been initialized.
Definition System.cpp:85
void shutdown()
Shutdown Portal::System and release all resources.
Definition System.cpp:69
Core::SystemBackend * get_backend()
Access the active platform backend.
Definition System.cpp:22
void stop()
Stop active Portal::System operations.
Definition System.cpp:59