33namespace fs = std::filesystem;
36using ns_db::ns_portal::ns_daemon::Mode;
40 fs::path path_dir_log;
41 Logs(fs::path
const& path_dir_log)
42 : path_dir_log(path_dir_log)
50 fs::path m_path_dir_fifo;
51 fs::path m_path_fifo_daemon;
52 fs::path m_path_file_log;
57 explicit Dispatcher(pid_t pid, Mode mode, fs::path
const& path_dir_app,
Logs const& logs);
59 [[maybe_unused]] fs::path get_path_dir_fifo()
const {
return m_path_dir_fifo; }
60 [[maybe_unused]] fs::path get_path_fifo_daemon()
const {
return m_path_fifo_daemon; }
61 [[maybe_unused]] fs::path get_path_file_log()
const {
return m_path_file_log; }
70inline Dispatcher::Dispatcher()
73 , m_path_fifo_daemon()
84inline Dispatcher::Dispatcher(pid_t pid, Mode mode, fs::path
const& path_dir_app,
Logs const& logs)
86 , m_path_dir_fifo(
ns_fs::placeholders_replace(path_dir_app /
"instance" /
"{}" /
"portal" /
"dispatcher" /
"fifo", pid))
87 , m_path_fifo_daemon(
ns_fs::placeholders_replace(path_dir_app /
"instance" /
"{}" /
"portal" /
"daemon" /
"{}.fifo", pid, mode.lower()))
88 , m_path_file_log(logs.path_dir_log / mode.lower() / std::format(
"{}.log", pid))
90 fs::create_directories(m_path_file_log.parent_path());
103 return_if(str_raw_json.empty(), Error(
"D::Empty json data"));
107 dispatcher.m_path_dir_fifo = Pop(db(
"path_dir_fifo").
template value<std::string>());
109 dispatcher.m_path_fifo_daemon = Pop(db(
"path_fifo_daemon").
template value<std::string>());
111 dispatcher.m_path_file_log = Pop(db(
"path_file_log").
template value<std::string>());
124 db(
"path_dir_fifo") = dispatcher.get_path_dir_fifo().string();
125 db(
"path_fifo_daemon") = dispatcher.get_path_fifo_daemon().string();
126 db(
"path_file_log") = dispatcher.get_path_file_log().string();
A type-safe wrapper around nlohmann::json for database operations.
friend Value< Dispatcher > deserialize(std::string_view str_raw_json) noexcept
Deserializes JSON string into a Binds object.
friend Value< std::string > serialize(Dispatcher const &dispatcher) noexcept
Serializes a Dispatcher class into a json string.
Defines a class that manages FlatImage's portal configuration.
A database that interfaces with nlohmann json.
Enhanced error handling framework built on std::expected.
Portal command dispatcher configuration.
Value< Dispatcher > deserialize(std::string_view str_raw_json) noexcept
Deserializes a json string into a Dispatcher class.
Value< std::string > serialize(Dispatcher const &dispatcher) noexcept
Serializes a Dispatcher class into a json string.
Value< Db > from_string(S &&s)
Parses a JSON string and creates a Db object.
Enhanced filesystem utilities wrapping std::filesystem.
Enhanced expected type with integrated logging capabilities.