Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <expected>
5#include <filesystem>
6#include <string>
7
8namespace mm::core {
9
19std::filesystem::path exeDir();
20
35std::filesystem::path userCacheDir();
36
48std::string errnoMessage(int err);
49
54void openInBrowser(const std::string& url);
55
63 public:
64 SingleInstanceLock() = default;
65 SingleInstanceLock(SingleInstanceLock&& other) noexcept;
70
71 private:
72 explicit SingleInstanceLock(std::intptr_t handle) : handle_(handle) {}
73 friend std::expected<SingleInstanceLock, std::string> acquireSingleInstanceLock();
74
75 static constexpr std::intptr_t kInvalid = -1;
76 std::intptr_t handle_ = kInvalid;
77};
78
91std::expected<SingleInstanceLock, std::string> acquireSingleInstanceLock();
92
93} // namespace mm::core
RAII holder of the process-wide single-instance lock.
Definition platform.h:62
~SingleInstanceLock()
Definition platform.cc:115
SingleInstanceLock(const SingleInstanceLock &)=delete
friend std::expected< SingleInstanceLock, std::string > acquireSingleInstanceLock()
Acquire the process-wide lock that permits only one running Motion Master.
Definition platform.cc:126
SingleInstanceLock & operator=(const SingleInstanceLock &)=delete
SingleInstanceLock & operator=(SingleInstanceLock &&other) noexcept
Definition platform.cc:109
Definition http_server.h:25
std::string errnoMessage(int err)
Describe an errno value, safely from any thread.
Definition platform.cc:86
std::expected< SingleInstanceLock, std::string > acquireSingleInstanceLock()
Acquire the process-wide lock that permits only one running Motion Master.
Definition platform.cc:126
std::filesystem::path userCacheDir()
Return Motion Master's per-user cache directory.
Definition platform.cc:65
std::filesystem::path exeDir()
Return the directory that contains the running executable.
Definition platform.cc:29
void openInBrowser(const std::string &url)
Open the given URL in the system default browser.
Definition platform.cc:88