From 985c182d281b46a1e8682081923a969f860a2af6 Mon Sep 17 00:00:00 2001 From: Max Qian Date: Thu, 2 May 2024 02:40:00 +0800 Subject: [PATCH 01/28] update not finished --- CMakeLists.txt | 1 + src/App.cpp | 4 +- src/addon/manager.cpp | 212 ++++++------ src/addon/manager.hpp | 14 +- src/atom/algorithm/fnmatch.cpp | 207 ++++++++++++ src/atom/algorithm/fnmatch.hpp | 88 +++++ src/atom/error/_script.hpp | 1 + src/atom/log/atomlog.cpp | 187 +++++++++++ src/atom/log/atomlog.hpp | 299 +++++++++++++++++ src/atom/log/atomlog.inl | 58 ++++ src/atom/system/CMakeLists.txt | 8 + src/atom/system/_component.cpp | 242 -------------- src/atom/system/_component.hpp | 47 --- src/atom/system/_pybind.cpp | 6 +- src/atom/system/_script.hpp | 2 +- src/atom/system/command.cpp | 4 +- src/atom/system/command.hpp | 4 +- src/atom/system/crash.cpp | 4 +- src/atom/system/crash.hpp | 4 +- src/atom/system/crash_quotes.cpp | 4 +- src/atom/system/crash_quotes.hpp | 4 +- src/atom/system/lregistry.cpp | 4 +- src/atom/system/lregistry.hpp | 4 +- src/atom/system/module/battery.cpp | 4 +- src/atom/system/module/battery.hpp | 4 +- src/atom/system/module/cpu.cpp | 4 +- src/atom/system/module/cpu.hpp | 4 +- src/atom/system/module/disk.cpp | 4 +- src/atom/system/module/disk.hpp | 4 +- src/atom/system/module/gpu.cpp | 7 +- src/atom/system/module/gpu.hpp | 4 +- src/atom/system/module/memory.cpp | 4 +- src/atom/system/module/memory.hpp | 4 +- src/atom/system/module/os.cpp | 4 +- src/atom/system/module/os.hpp | 4 +- src/atom/system/module/wifi.cpp | 2 +- src/atom/system/module/wifi.hpp | 4 +- src/atom/system/os.cpp | 41 ++- src/atom/system/os.hpp | 6 +- src/atom/system/pidwatcher.cpp | 4 +- src/atom/system/pidwatcher.hpp | 4 +- src/atom/system/process.cpp | 4 +- src/atom/system/process.hpp | 4 +- src/atom/system/stat.cpp | 126 ++++++++ src/atom/system/stat.hpp | 120 +++++++ src/atom/system/storage.cpp | 6 +- src/atom/system/storage.hpp | 4 +- src/atom/system/system.cpp | 4 +- src/atom/system/system.hpp | 4 +- src/atom/system/user.cpp | 4 +- src/atom/system/user.hpp | 4 +- src/atom/type/flat_multimap.hpp | 303 ++++++++++++++++++ src/atom/web/CMakeLists.txt | 2 + src/atom/web/address.cpp | 4 +- src/atom/web/address.hpp | 4 +- src/atom/web/curl.cpp | 4 +- src/atom/web/curl.hpp | 4 +- src/atom/web/downloader.cpp | 4 +- src/atom/web/downloader.hpp | 4 +- src/atom/web/httpclient.cpp | 4 +- src/atom/web/httpclient.hpp | 4 +- src/atom/web/httplite.cpp | 4 +- src/atom/web/httplite.hpp | 4 +- src/atom/web/httpparser.cpp | 7 +- src/atom/web/httpparser.hpp | 9 +- src/atom/web/time.cpp | 6 +- src/atom/web/time.hpp | 6 +- src/atom/web/utils.cpp | 8 +- src/atom/web/utils.hpp | 4 +- src/debug/terminal.cpp | 107 +++++-- src/debug/terminal.hpp | 55 ++-- src/device/server/hydrogen.cpp | 12 +- src/modules/CMakeLists.txt | 12 + src/modules/atom.system/CMakeLists.txt | 73 +++++ src/modules/atom.system/_component.cpp | 215 +++++++++++++ src/modules/atom.system/_component.hpp | 68 ++++ src/modules/atom.system/_main.cpp | 29 ++ src/modules/atom.system/package.json | 34 ++ src/preload.cpp | 2 +- src/script/custom/os.cpp | 2 +- src/script/custom/sys.cpp | 64 ++-- .../controller/AsyncProcessController.hpp | 6 +- .../controller/AsyncSystemController.hpp | 50 +-- src/server/data/SystemCustom.hpp | 16 +- 84 files changed, 2279 insertions(+), 651 deletions(-) create mode 100644 src/atom/algorithm/fnmatch.cpp create mode 100644 src/atom/algorithm/fnmatch.hpp create mode 100644 src/atom/log/atomlog.cpp create mode 100644 src/atom/log/atomlog.hpp create mode 100644 src/atom/log/atomlog.inl delete mode 100644 src/atom/system/_component.cpp delete mode 100644 src/atom/system/_component.hpp create mode 100644 src/atom/system/stat.cpp create mode 100644 src/atom/system/stat.hpp create mode 100644 src/atom/type/flat_multimap.hpp create mode 100644 src/modules/CMakeLists.txt create mode 100644 src/modules/atom.system/CMakeLists.txt create mode 100644 src/modules/atom.system/_component.cpp create mode 100644 src/modules/atom.system/_component.hpp create mode 100644 src/modules/atom.system/_main.cpp create mode 100644 src/modules/atom.system/package.json diff --git a/CMakeLists.txt b/CMakeLists.txt index a83d51fb..c3f088d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,7 @@ add_subdirectory(driver) add_subdirectory(${lithium_src_dir}/carbon) add_subdirectory(${lithium_src_dir}/config) add_subdirectory(${lithium_src_dir}/server) +add_subdirectory(${lithium_src_dir}/modules) ################################################################################# # diff --git a/src/App.cpp b/src/App.cpp index eaf921a5..801b0460 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -60,7 +60,7 @@ void setupLogFile() { loguru::Verbosity_MAX); loguru::set_fatal_handler([](const loguru::Message &message) { - Atom::System::saveCrashLog(std::string(message.prefix) + + atom::system::saveCrashLog(std::string(message.prefix) + message.message); }); } @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) { } catch (const std::bad_any_cast &e) { LOG_F(ERROR, "Invalid args format! Error: {}", e.what()); - Atom::System::saveCrashLog(e.what()); + atom::system::saveCrashLog(e.what()); return 1; } diff --git a/src/addon/manager.cpp b/src/addon/manager.cpp index dd054e99..8299644b 100644 --- a/src/addon/manager.cpp +++ b/src/addon/manager.cpp @@ -21,6 +21,7 @@ Description: Component Manager (the core of the plugin system) #include "sandbox.hpp" #include "sort.hpp" +#include "atom/error/exception.hpp" #include "atom/io/io.hpp" #include "atom/log/loguru.hpp" #include "atom/server/global_ptr.hpp" @@ -55,11 +56,6 @@ ComponentManager::ComponentManager() : m_Sandbox(nullptr), m_Compiler(nullptr) { GetWeakPtr(constants::LITHIUM_ADDON_MANAGER); CHECK_WEAK_PTR_EXPIRED(m_AddonManager, "load addon manager from gpm: lithium.addon.addon"); - - // m_ComponentFinder = std::make_unique( - // m_Env.lock()->getEnv("LITHIUM_ADDON_PATH", "./modules"), checkFunc); - // NOTE: AddonFinder is not supported yet - // Initialize sandbox and compiler, these are not shared objects m_Sandbox = std::make_unique(); m_Compiler = std::make_unique(); @@ -75,7 +71,6 @@ ComponentManager::~ComponentManager() { m_ModuleLoader.reset(); m_Env.reset(); m_AddonManager.reset(); - // m_ComponentFinder.reset(); m_Sandbox.reset(); m_Compiler.reset(); } @@ -83,24 +78,26 @@ ComponentManager::~ComponentManager() { bool ComponentManager::Initialize() { // Check if the module path is valid or reset by the user // Default path is ./modules - // TODO: Windows support const std::string &module_path = m_Env.lock()->getEnv( constants::ENV_VAR_MODULE_PATH, constants::MODULE_FOLDER); - // Get all of the available addon path - /* - /if (!m_ComponentFinder->traverseDir(std::filesystem::path(module_path))) { - LOG_F(ERROR, "Failed to traversing module path"); - return false; - } - */ + m_module_path = m_Env.lock()->getEnv(constants::ENV_VAR_MODULE_PATH, + constants::MODULE_FOLDER); // make a loading list of modules - std::vector qualified_subdirs = + const std::vector &qualified_subdirs = resolveDependencies(getQualifiedSubDirs(module_path)); if (qualified_subdirs.empty()) { - LOG_F(WARNING, "No modules found"); + LOG_F(INFO, "No modules found, just skip loading modules"); return true; } + LOG_F(INFO, "Loading modules from: {}", m_module_path); + // List all of the available modules folders +#if ENABLE_DEBUG + LOG_F(INFO, "Available modules:"); + for (const auto &dir : qualified_subdirs) { + LOG_F(INFO, "{}", dir); + } +#endif for (const auto &dir : qualified_subdirs) { std::filesystem::path path = std::filesystem::path(module_path) / dir; @@ -109,6 +106,7 @@ bool ComponentManager::Initialize() { LOG_F(ERROR, "Failed to load module: {}", path.string()); continue; } + // Get addon's package.json const json &addon_info = m_AddonManager.lock()->getModule(dir); if (!addon_info.is_object() || !addon_info.contains("name") || !addon_info["name"].is_string()) { @@ -116,77 +114,50 @@ bool ComponentManager::Initialize() { continue; } auto addon_name = addon_info["name"].get(); + LOG_F(INFO, "Start loading addon: {}", addon_name); // Check if the addon info is valid - if (!addon_info.contains("modules") || addon_info.is_null()) { - LOG_F(ERROR, "Failed to load module: {}", path.string()); - LOG_F(ERROR, "Missing modules field in addon info"); + if (!addon_info.contains("modules")) { + LOG_F(ERROR, + "Failed to load module {}: Missing modules field in module " + "info", + path.string()); + m_AddonManager.lock()->removeModule(dir); + continue; + } + if (addon_info["modules"].is_null() || + !addon_info["modules"].is_array()) { + LOG_F(ERROR, "Failed to load module {}: Modules field is null", + path.string()); m_AddonManager.lock()->removeModule(dir); continue; } // loading - for (const auto &module_info : + for (const auto &component_info : addon_info["modules"].get()) { - if (module_info.is_null() || !module_info.contains("name") || - !module_info.contains("entry")) { - LOG_F(ERROR, "Failed to load module: {}/{}", path.string(), - module_info.dump()); + if (component_info.is_null() || !component_info.contains("name") || + !component_info.contains("entry") || + !component_info["name"].is_string() || + !component_info["entry"].is_string()) { + LOG_F(ERROR, + "Failed to load module {}/{}: Invalid component info", + path.string(), component_info.dump()); continue; } - auto module_name = - addon_name + "." + module_info["name"].get(); - std::filesystem::path module_path = - path / (module_info["name"].get() + - std::string(constants::LIB_EXTENSION)); - - DLOG_F(INFO, "Loading module: {}", module_path.string()); -#ifdef _WIN32 - // This is to pass file name check - auto module_path_str = - atom::utils::replaceString(module_path.string(), "/", "\\"); -#else - auto module_path_str = - atom::utils::replaceString(module_path.string(), "\\", "/"); -#endif - - // This step is to load the dynamic library - if (!m_ModuleLoader.lock()->LoadModule(module_path_str, - module_name)) { - LOG_F(ERROR, "Failed to load module: {}", module_path_str); - continue; - } - DLOG_F(INFO, "Loaded module: {}/{}", path.string(), - module_info.dump()); - auto component_entry = module_info["entry"].get(); - if (component_entry.empty()) { - LOG_F(ERROR, "Failed to load module: {}/{}", path.string(), - module_name); - continue; - } - auto component_identifier = - addon_name + module_name + component_entry; - if (auto component = m_ModuleLoader.lock()->GetInstance( - module_name, {}, component_entry); - component) { - LOG_F(INFO, "Loaded shared component: {}", - component_identifier); - try { - if (component->initialize()) { - m_Components[addon_name + module_name] = component; - LOG_F(INFO, "Loaded shared component: {}", - component_identifier); - } else { - LOG_F(ERROR, - "Failed to initialize shared component: {}", - component_identifier); - } - } catch (const std::exception &e) { - LOG_F(ERROR, "Failed to initialize shared component: {}", - component_identifier); - } - - } else { - LOG_F(ERROR, "Failed to load shared component: {}", - component_identifier); + auto component_name = component_info["name"].get(); + auto entry = component_info["entry"].get(); + auto dependencies = component_info.contains("dependencies") + ? component_info["dependencies"] + .get>() + : std::vector(); + auto module_path = + path / (component_name + std::string(constants::LIB_EXTENSION)); + if (!loadSharedComponent(component_name, addon_name, + module_path.string(), entry, + dependencies)) { + LOG_F(ERROR, "Failed to load module {}/{}", path.string(), + component_name); + // Max: We will directly throw a exception here, just like what Minecraft does + THROW_EXCEPTION("Failed to load module", component_name); } } } @@ -269,10 +240,13 @@ bool ComponentManager::loadComponent(ComponentType component_type, return false; } if (it->second->m_component_type == "shared") { + /* if (!loadSharedComponent(component_name)) { LOG_F(ERROR, "Failed to load shared component: {}", component_name); return false; } + */ + } else if (it->second->m_component_type == "alone") { } else if (it->second->m_component_type == "executable") { } @@ -413,42 +387,70 @@ std::shared_ptr ComponentManager::getComponent( return nullptr; } -bool ComponentManager::loadSharedComponent(const std::string &component_name) { - // Classis parameter check - if (component_name.empty()) { - LOG_F(ERROR, "Component name is empty"); - return false; - } - if (m_Components.find(component_name) != m_Components.end()) { - LOG_F(ERROR, "Component {} has been loaded", component_name); +bool ComponentManager::loadSharedComponent( + const std::string &component_name, const std::string &addon_name, + const std::string &module_path, const std::string &entry, + const std::vector &dependencies) { + auto component_full_name = addon_name + "." + component_name; + + DLOG_F(INFO, "Loading module: {}", component_full_name); +#ifdef _WIN32 + // This is to pass file name check + auto module_path_str = atom::utils::replaceString(module_path, "/", "\\"); +#else + auto module_path_str = atom::utils::replaceString(module_path, "\\", "/"); +#endif + + // This step is to load the dynamic library + if (!m_ModuleLoader.lock()->LoadModule(module_path_str, + component_full_name)) { + LOG_F(ERROR, "Failed to load module: {}", module_path_str); return false; } - // Load the component entry from the component entries - auto it = m_ComponentEntries.find(component_name); - if (it == m_ComponentEntries.end()) { - LOG_F(ERROR, "Component {} does not has an entry", component_name); + if (entry.empty()) { + LOG_F(ERROR, "Failed to load module: {}/{}", module_path, + component_name); return false; } - // There we need some json parameters support for better get the component - // instance - if (std::shared_ptr component = - m_ModuleLoader.lock()->GetInstance( - it->second->m_name, {}, it->second->m_func_name); + // get the component shared_ptr from dynamic library + if (auto component = m_ModuleLoader.lock()->GetInstance( + component_full_name, {}, entry); component) { + LOG_F(INFO, "Loaded shared component: {}", component_full_name); + // Inject all of the component dependencies + // Remember that the dependencies must be injected before + // initialization + try { + for (const auto &dependency : dependencies) { + // Check if the dependency is a string + if (!dependency.empty()) { + component->addOtherComponent( + dependency, GetWeakPtr(dependency)); + } + { LOG_F(WARNING, "Empty dependency detected"); } + } + } catch (const json::exception &e) { + LOG_F(ERROR, "Failed to load shared component: {} {}", + component_full_name, e.what()); + return false; + } + try { // Initialize the component - component->initialize(); + if (component->initialize()) { + m_Components[component_full_name] = component; + // Inject it into GSPM + AddPtr(component_full_name, component); + LOG_F(INFO, "Loaded shared component: {}", component_full_name); + return true; + } } catch (const std::exception &e) { - LOG_F(ERROR, "Failed to initialize component: {}", e.what()); - return false; } - m_Components[component_name] = component; - } else { - LOG_F(ERROR, "Failed to load module: {}'s library", component_name); - return false; + LOG_F(ERROR, "Failed to initialize shared component: {}", + component_full_name); } - DLOG_F(INFO, "Successfully loaded shared component: {}", component_name); - return true; + LOG_F(ERROR, "Failed to load shared component: {}", component_full_name); + return false; } bool ComponentManager::unloadSharedComponent(const json ¶ms) { diff --git a/src/addon/manager.hpp b/src/addon/manager.hpp index a059d121..96a04782 100644 --- a/src/addon/manager.hpp +++ b/src/addon/manager.hpp @@ -234,7 +234,11 @@ class ComponentManager { * @warning This method will alse load the component if it is still in use * @warning Also, will cause Segmentation fault */ - bool loadSharedComponent(const std::string& component_name); + bool loadSharedComponent(const std::string& component_name, + const std::string& addon_name, + const std::string& module_path, + const std::string& entry, + const std::vector& dependencies); bool unloadSharedComponent(const json& params); bool reloadSharedComponent(const json& params); @@ -278,6 +282,12 @@ class ComponentManager { // Max: Why not just use a single map of std::shared_ptr? // Maybe it is because the dynamic_cast will be slow // And we are surely about what the component is - std::unordered_map> m_Components; +#if ENABLE_FASTHASH + emhash8::HashMap> m_Components; +#else + std::unordered_map> m_Components; +#endif + + std::string m_module_path; }; } // namespace lithium diff --git a/src/atom/algorithm/fnmatch.cpp b/src/atom/algorithm/fnmatch.cpp new file mode 100644 index 00000000..be6b5efb --- /dev/null +++ b/src/atom/algorithm/fnmatch.cpp @@ -0,0 +1,207 @@ +/* + * fnmatch.cpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2024-5-2 + +Description: Python Like fnmatch for C++ + +**************************************************/ + +#include "fnmatch.hpp" + +#include +#include + +#ifdef _WIN32 +#include +#else +#include +#endif + +namespace atom::algorithm { + +constexpr int FNM_NOESCAPE = 0x01; +constexpr int FNM_PATHNAME = 0x02; +constexpr int FNM_PERIOD = 0x04; +constexpr int FNM_CASEFOLD = 0x08; + +bool fnmatch(std::string_view pattern, std::string_view string, int flags) { +#ifdef _WIN32 + // Windows doesn't have a built-in fnmatch function, so we need to implement + // it ourselves + auto p = pattern.begin(); + auto s = string.begin(); + + while (p != pattern.end() && s != string.end()) { + switch (*p) { + case '?': + ++s; + break; + case '*': + if (++p == pattern.end()) { + return true; + } + while (s != string.end()) { + if (fnmatch({p, pattern.end()}, {s, string.end()}, flags)) { + return true; + } + ++s; + } + return false; + case '[': { + if (++p == pattern.end()) { + return false; + } + bool invert = false; + if (*p == '!') { + invert = true; + ++p; + } + bool matched = false; + char last_char = 0; + while (p != pattern.end() && *p != ']') { + if (*p == '-' && last_char != 0 && p + 1 != pattern.end() && + *(p + 1) != ']') { + ++p; + if (*s >= last_char && *s <= *p) { + matched = true; + break; + } + } else { + if (*s == *p) { + matched = true; + break; + } + last_char = *p; + } + ++p; + } + if (invert) { + matched = !matched; + } + if (!matched) { + return false; + } + ++s; + break; + } + case '\\': + if (!(flags & FNM_NOESCAPE) && ++p == pattern.end()) { + return false; + } + [[fallthrough]]; + default: + if ((flags & FNM_CASEFOLD) + ? (std::tolower(*p) != std::tolower(*s)) + : (*p != *s)) { + return false; + } + ++s; + break; + } + ++p; + } + + if (p == pattern.end() && s == string.end()) { + return true; + } + if (p != pattern.end() && *p == '*') { + ++p; + } + return p == pattern.end() && s == string.end(); +#else + // On POSIX systems, we can use the built-in fnmatch function + return ::fnmatch(pattern.data(), string.data(), flags) == 0; +#endif +} + +bool filter(const std::vector& names, std::string_view pattern, + int flags) { + return std::any_of( + names.begin(), names.end(), + [&](const std::string& name) { return fnmatch(pattern, name, flags); }); +} + +std::vector filter(const std::vector& names, + const std::vector& patterns, + int flags) { + std::vector result; + for (const auto& name : names) { + if (std::any_of(patterns.begin(), patterns.end(), + [&](std::string_view pattern) { + return fnmatch(pattern, name, flags); + })) { + result.push_back(name); + } + } + return result; +} + +bool translate(std::string_view pattern, std::string& result, int flags) { + result.clear(); + for (auto it = pattern.begin(); it != pattern.end(); ++it) { + switch (*it) { + case '*': + result += ".*"; + break; + case '?': + result += '.'; + break; + case '[': { + result += '['; + if (++it == pattern.end()) { + return false; + } + if (*it == '!') { + result += '^'; + ++it; + } + bool first = true; + char last_char = 0; + while (it != pattern.end() && *it != ']') { + if (!first && *it == '-' && last_char != 0 && + it + 1 != pattern.end() && *(it + 1) != ']') { + result += last_char; + result += '-'; + ++it; + result += *it; + } else { + if (flags & FNM_NOESCAPE && *it == '\\' && + ++it == pattern.end()) { + return false; + } + result += *it; + last_char = *it; + } + first = false; + ++it; + } + result += ']'; + break; + } + case '\\': + if (!(flags & FNM_NOESCAPE) && ++it == pattern.end()) { + return false; + } + [[fallthrough]]; + default: + if (flags & FNM_CASEFOLD && std::isalpha(*it)) { + result += '['; + result += std::tolower(*it); + result += std::toupper(*it); + result += ']'; + } else { + result += *it; + } + break; + } + } + return true; +} + +} // namespace atom::algorithm diff --git a/src/atom/algorithm/fnmatch.hpp b/src/atom/algorithm/fnmatch.hpp new file mode 100644 index 00000000..69405312 --- /dev/null +++ b/src/atom/algorithm/fnmatch.hpp @@ -0,0 +1,88 @@ +/* + * fnmatch.hpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2024-5-2 + +Description: Python Like fnmatch for C++ + +**************************************************/ + +#ifndef ATOM_SYSTEM_FNMATCH_HPP +#define ATOM_SYSTEM_FNMATCH_HPP + +#include +#include +#include + +namespace atom::algorithm { +/** + * @brief Matches a string against a specified pattern. + * + * This function compares the given `string` against the specified `pattern` + * using shell-style pattern matching. The `flags` parameter can be used to + * modify the behavior of the matching process. + * + * @param pattern The pattern to match against. + * @param string The string to match. + * @param flags Optional flags to modify the matching behavior (default is 0). + * @return True if the `string` matches the `pattern`, false otherwise. + */ +bool fnmatch(std::string_view pattern, std::string_view string, int flags = 0); + +/** + * @brief Filters a vector of strings based on a specified pattern. + * + * This function filters the given vector of `names` based on the specified + * `pattern` using shell-style pattern matching. The `flags` parameter can be + * used to modify the filtering behavior. + * + * @param names The vector of strings to filter. + * @param pattern The pattern to filter with. + * @param flags Optional flags to modify the filtering behavior (default is 0). + * @return True if any element of `names` matches the `pattern`, false + * otherwise. + */ +bool filter(const std::vector& names, std::string_view pattern, + int flags = 0); + +/** + * @brief Filters a vector of strings based on multiple patterns. + * + * This function filters the given vector of `names` based on the specified + * `patterns` using shell-style pattern matching. The `flags` parameter can be + * used to modify the filtering behavior. + * + * @param names The vector of strings to filter. + * @param patterns The vector of patterns to filter with. + * @param flags Optional flags to modify the filtering behavior (default is 0). + * @return A vector containing strings from `names` that match any pattern in + * `patterns`. + */ +std::vector filter(const std::vector& names, + const std::vector& patterns, + int flags = 0); + +/** + * @brief Translates a pattern into a different representation. + * + * This function translates the specified `pattern` into a different + * representation and stores the result in the `result` parameter. The `flags` + * parameter can be used to modify the translation behavior. + * + * @param pattern The pattern to translate. + * @param result A reference to a string where the translated pattern will be + * stored. + * @param flags Optional flags to modify the translation behavior (default is + * 0). + * @return True if the translation was successful, false otherwise. + */ +bool translate(std::string_view pattern, std::string& result, int flags = 0); + +} // namespace atom::algorithm + +#endif // ATOM_SYSTEM_FNMATCH_HPP \ No newline at end of file diff --git a/src/atom/error/_script.hpp b/src/atom/error/_script.hpp index 19693e77..aea9dc23 100644 --- a/src/atom/error/_script.hpp +++ b/src/atom/error/_script.hpp @@ -63,6 +63,7 @@ Carbon::ModulePtr bootstrap( case LIError::UnLoadError: return "UnLoadError"; } + return "Unknown"; })); m->add(Carbon::type_conversion( [](const std::string &str) { diff --git a/src/atom/log/atomlog.cpp b/src/atom/log/atomlog.cpp new file mode 100644 index 00000000..34213053 --- /dev/null +++ b/src/atom/log/atomlog.cpp @@ -0,0 +1,187 @@ +/* + * atomlog.cpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2023-11-10 + +Description: Logger for Atom + +**************************************************/ + +#include "atomlog.hpp" + +namespace atom::log { +Logger::Logger(const fs::path& file_name, LogLevel min_level, + size_t max_file_size, int max_files) + : file_name(file_name), + min_level(min_level), + max_file_size(max_file_size), + max_files(max_files), + worker([this] { run(); }) { + rotateLogFile(); +} + +Logger::~Logger() { + { + std::lock_guard lock(queue_mutex); + finished = true; + } + cv.notify_one(); + if (log_file.is_open()) { + log_file.close(); + } +} + +void Logger::setThreadName(const std::string& name) { + std::lock_guard lock(queue_mutex); + thread_names[std::this_thread::get_id()] = name; +} + +void Logger::setLevel(LogLevel level) { min_level = level; } + +void Logger::setPattern(const std::string& pattern) { this->pattern = pattern; } + +void Logger::registerSink(const std::shared_ptr& logger) { + sinks.push_back(logger); +} + +void Logger::removeSink(const std::shared_ptr& logger) { + sinks.erase(std::remove(sinks.begin(), sinks.end(), logger), sinks.end()); +} + +void Logger::clearSinks() { sinks.clear(); } + +std::string Logger::getThreadName() { + auto id = std::this_thread::get_id(); + if (thread_names.find(id) != thread_names.end()) { + return thread_names[id]; + } + return std::to_string(std::hash{}(id)); +} + +std::string Logger::logLevelToString(LogLevel level) { + switch (level) { + case LogLevel::TRACE: + return "TRACE"; + case LogLevel::DEBUG: + return "DEBUG"; + case LogLevel::INFO: + return "INFO"; + case LogLevel::WARN: + return "WARN"; + case LogLevel::ERROR: + return "ERROR"; + case LogLevel::CRITICAL: + return "CRITICAL"; + default: + return "UNKNOWN"; + } +} + +std::string Logger::formatMessage(LogLevel level, const std::string& msg) { + auto now = std::chrono::system_clock::now(); + auto time_t_now = std::chrono::system_clock::to_time_t(now); + auto tm_now = fmt::localtime(time_t_now); + auto thread_name = getThreadName(); + return fmt::format( + fmt::runtime(pattern), fmt::arg("Y", tm_now.tm_year + 1900), + fmt::arg("m", tm_now.tm_mon + 1), fmt::arg("d", tm_now.tm_mday), + fmt::arg("H", tm_now.tm_hour), fmt::arg("M", tm_now.tm_min), + fmt::arg("S", tm_now.tm_sec), + fmt::arg("e", std::chrono::duration_cast( + now.time_since_epoch()) + .count() % + 1000), + fmt::arg("l", logLevelToString(level)), fmt::arg("t", thread_name), + fmt::arg("v", msg)); +} + +void Logger::log(LogLevel level, const std::string& msg) { + if (level < min_level) { + return; + } + + auto formatted_msg = formatMessage(level, msg); + + { + std::lock_guard lock(queue_mutex); + log_queue.push(formatted_msg); + } + cv.notify_one(); + + for (const auto& sink : sinks) { + sink->log(level, msg); + } +} + +void Logger::run() { + std::string msg; + while (true) { + { + std::unique_lock lock(queue_mutex); + cv.wait(lock, [this] { return !log_queue.empty() || finished; }); + + if (finished && log_queue.empty()) { + break; + } + + msg = log_queue.front(); + log_queue.pop(); + } // Release lock before I/O operation + + log_file << msg << std::endl; + + if (log_file.tellp() >= static_cast(max_file_size)) { + rotateLogFile(); + } + } +} + +void Logger::rotateLogFile() { + std::lock_guard lock(queue_mutex); // Lock during rotation + if (log_file.is_open()) { + log_file.close(); + } + + if (max_files > 0) { + auto extension = file_name.extension(); + auto stem = file_name.stem(); + + for (int i = max_files - 1; i > 0; --i) { + auto src = + file_name.parent_path() / + (stem.string() + "." + std::to_string(i) + extension.string()); + auto dst = file_name.parent_path() / + (stem.string() + "." + std::to_string(i + 1) + + extension.string()); + + if (fs::exists(src)) { + if (fs::exists(dst)) { + fs::remove(dst); + } + fs::rename(src, dst); + } + } + + auto dst = file_name.parent_path() / + (stem.string() + ".1" + extension.string()); + if (fs::exists(file_name)) { + if (fs::exists(dst)) { + fs::remove(dst); + } + fs::rename(file_name, dst); + } + } + + log_file.open(file_name, std::ios::out | std::ios::app); + if (!log_file.is_open()) { + throw std::runtime_error("Failed to open log file: " + + file_name.string()); + } +} + +} // namespace atom::log \ No newline at end of file diff --git a/src/atom/log/atomlog.hpp b/src/atom/log/atomlog.hpp new file mode 100644 index 00000000..b8fca7ef --- /dev/null +++ b/src/atom/log/atomlog.hpp @@ -0,0 +1,299 @@ +/* + * atomlog.hpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2023-11-10 + +Description: Logger for Atom + +**************************************************/ + +#ifndef ATOM_LOG_ATOMLOG_HPP +#define ATOM_LOG_ATOMLOG_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace fs = std::filesystem; + +namespace atom::log { + +enum class LogLevel { + TRACE, + DEBUG, + INFO, + WARN, + ERROR, + CRITICAL, + OFF // Used to disable logging +}; + +/** + * @brief The Logger class provides functionality for logging messages to a file + * with different log levels and patterns. + * + * The Logger class allows logging messages to a file with various log levels + * such as TRACE, DEBUG, INFO, WARNING, ERROR, and CRITICAL. It supports logging + * messages with different formats and rotating log files when the file size + * exceeds a certain threshold. Additionally, it provides options to set log + * level, log pattern, thread name, and register sinks for logging to multiple + * destinations. + */ +class Logger { +public: + /** + * @brief Constructs a Logger object. + * + * Initializes the Logger with the specified file name, minimum log level, + * maximum file size, and maximum number of log files. + * + * @param file_name The path to the log file. + * @param min_level The minimum log level to be logged. + * @param max_file_size The maximum size of the log file in bytes before + * rotation. + * @param max_files The maximum number of log files to retain during + * rotation. + */ + explicit Logger(const fs::path& file_name, + LogLevel min_level = LogLevel::TRACE, + size_t max_file_size = 1048576, int max_files = 10); + + /** + * @brief Destroys the Logger object. + * + * Closes the log file and stops the logger thread. + */ + ~Logger(); + + /** + * @brief Prevents copying of Logger objects. + */ + Logger(const Logger&) = delete; + Logger& operator=(const Logger&) = delete; + + /** + * @brief Logs a message with the TRACE log level. + * + * Logs a message with the TRACE log level and format. Supports variadic + * arguments for message formatting. + * + * @tparam Args Variadic template for message arguments. + * @param format The format string of the message. + * @param args The arguments for message formatting. + */ + template + void trace(const std::string& format, Args&&... args); + + /** + * @brief Logs a message with the DEBUG log level. + * + * Logs a message with the DEBUG log level and format. Supports variadic + * arguments for message formatting. + * + * @tparam Args Variadic template for message arguments. + * @param format The format string of the message. + * @param args The arguments for message formatting. + */ + template + void debug(const std::string& format, Args&&... args); + + /** + * @brief Logs a message with the INFO log level. + * + * Logs a message with the INFO log level and format. Supports variadic + * arguments for message formatting. + * + * @tparam Args Variadic template for message arguments. + * @param format The format string of the message. + * @param args The arguments for message formatting. + */ + template + void info(const std::string& format, Args&&... args); + + /** + * @brief Logs a message with the WARN log level. + * + * Logs a message with the WARN log level and format. Supports variadic + * arguments for message formatting. + * + * @tparam Args Variadic template for message arguments. + * @param format The format string of the message. + * @param args The arguments for message formatting. + */ + template + void warn(const std::string& format, Args&&... args); + + /** + * @brief Logs a message with the ERROR log level. + * + * Logs a message with the ERROR log level and format. Supports variadic + * arguments for message formatting. + * + * @tparam Args Variadic template for message arguments. + * @param format The format string of the message. + * @param args The arguments for message formatting. + */ + template + void error(const std::string& format, Args&&... args); + + /** + * @brief Logs a message with the CRITICAL log level. + * + * Logs a message with the CRITICAL log level and format. Supports variadic + * arguments for message formatting. + * + * @tparam Args Variadic template for message arguments. + * @param format The format string of the message. + * @param args The arguments for message formatting. + */ + template + void critical(const std::string& format, Args&&... args); + + /** + * @brief Sets the minimum log level for logging. + * + * Sets the minimum log level for logging messages. Log messages with levels + * below this will not be logged. + * + * @param level The minimum log level. + */ + void setLevel(LogLevel level); + + /** + * @brief Sets the log message pattern. + * + * Sets the pattern for formatting log messages. The pattern may include + * placeholders for various log components. + * + * @param pattern The log message pattern. + */ + void setPattern(const std::string& pattern); + + /** + * @brief Sets the name of the current thread. + * + * Sets the name of the current thread to be included in log messages. + * + * @param name The name of the thread. + */ + void setThreadName(const std::string& name); + + /** + * @brief Registers a sink for logging to another Logger. + * + * Registers another Logger instance as a sink for logging, allowing + * messages to be forwarded to multiple destinations. + * + * @param logger The Logger instance to register as a sink. + */ + void registerSink(const std::shared_ptr& logger); + + /** + * @brief Removes a previously registered sink. + * + * Removes a previously registered Logger instance from the list of sinks. + * + * @param logger The Logger instance to remove from sinks. + */ + void removeSink(const std::shared_ptr& logger); + + /** + * @brief Clears all registered sinks. + * + * Clears all registered Logger instances from the list of sinks. + */ + void clearSinks(); + +private: + fs::path file_name; + std::ofstream log_file; + std::queue log_queue; + std::mutex queue_mutex; + std::condition_variable cv; + bool finished = false; + std::jthread worker; + size_t max_file_size; + int max_files; + LogLevel min_level; + int file_index = 0; + std::unordered_map thread_names; + std::string pattern = "[{Y}-{m}-{d} {H}:{M}:{S}.{e}] [{l}] [{t}] {v}"; + std::vector> sinks; + + /** + * @brief Rotates the log file. + * + * Rotates the log file by renaming it and creating a new empty file. + */ + void rotateLogFile(); + + /** + * @brief Gets the name of the current thread. + * + * Gets the name of the current thread, or a default name if no name has + * been set. + * + * @return The name of the current thread. + */ + std::string getThreadName(); + + /** + * @brief Converts a log level to a string. + * + * Converts a log level to a string representation. + * + * @param level The log level to convert. + * @return The string representation of the log level. + */ + static std::string logLevelToString(LogLevel level); + + /** + * @brief Formats a log message. + * + * Formats a log message with the specified log level and message. + * + * @param level The log level of the message. + * @param msg The message to format. + * @return The formatted log message. + */ + std::string formatMessage(LogLevel level, const std::string& msg); + + /** + * @brief Logs a message. + * + * Logs a message with the specified log level and message. + * + * @param level The log level of the message. + * @param msg The message to log. + */ + void log(LogLevel level, const std::string& msg); + + /** + * @brief The worker thread function. + * + * The worker thread function that processes log messages from the queue. + */ + void run(); +}; + +} // namespace atom::log + +#endif diff --git a/src/atom/log/atomlog.inl b/src/atom/log/atomlog.inl new file mode 100644 index 00000000..3446fd0e --- /dev/null +++ b/src/atom/log/atomlog.inl @@ -0,0 +1,58 @@ +/* + * atomlog.inl + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2023-11-10 + +Description: Logger for Atom + +**************************************************/ + +#ifndef ATOM_LOG_ATOMLOG_INL +#define ATOM_LOG_ATOMLOG_INL + +#include "atomlog.hpp" + +namespace atom::log { +template +void Logger::trace(const std::string& format, Args&&... args) { + log(LogLevel::TRACE, + fmt::format(fmt::runtime(format), std::forward(args)...)); +} + +template +void Logger::debug(const std::string& format, Args&&... args) { + log(LogLevel::DEBUG, + fmt::format(fmt::runtime(format), std::forward(args)...)); +} + +template +void Logger::info(const std::string& format, Args&&... args) { + log(LogLevel::INFO, + fmt::format(fmt::runtime(format), std::forward(args)...)); +} + +template +void Logger::warn(const std::string& format, Args&&... args) { + log(LogLevel::WARN, + fmt::format(fmt::runtime(format), std::forward(args)...)); +} + +template +void Logger::error(const std::string& format, Args&&... args) { + log(LogLevel::ERROR, + fmt::format(fmt::runtime(format), std::forward(args)...)); +} + +template +void Logger::critical(const std::string& format, Args&&... args) { + log(LogLevel::CRITICAL, + fmt::format(fmt::runtime(format), std::forward(args)...)); +} +} // namespace atom::log + +#endif \ No newline at end of file diff --git a/src/atom/system/CMakeLists.txt b/src/atom/system/CMakeLists.txt index b9bac6c4..0189d96c 100644 --- a/src/atom/system/CMakeLists.txt +++ b/src/atom/system/CMakeLists.txt @@ -23,7 +23,9 @@ set(${PROJECT_NAME}_SOURCES crash_quotes.cpp crash.cpp lregistry.cpp + os.cpp pidwatcher.cpp + platform.cpp process.cpp register.cpp storage.cpp @@ -32,6 +34,7 @@ set(${PROJECT_NAME}_SOURCES module/cpu.cpp module/disk.cpp + module/gpu.cpp module/memory.cpp module/battery.cpp module/wifi.cpp @@ -43,7 +46,9 @@ set(${PROJECT_NAME}_HEADERS command.hpp crash_quotes.hpp crash.hpp + os.hpp pidwatcher.hpp + platform.hpp process.hpp register.hpp storage.hpp @@ -52,8 +57,11 @@ set(${PROJECT_NAME}_HEADERS module/cpu.hpp module/disk.hpp + module/gpu.hpp module/memory.hpp module/battery.hpp + module/wifi.hpp + module/os.hpp ) # Private Headers diff --git a/src/atom/system/_component.cpp b/src/atom/system/_component.cpp deleted file mode 100644 index 4d30faa3..00000000 --- a/src/atom/system/_component.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - * _component.cpp - * - * Copyright (C) 2023-2024 Max Qian - */ - -/************************************************* - -Date: 2024-4-13 - -Description: Component of Atom-System - -**************************************************/ - -#include "_component.hpp" - -#include "atom/log/loguru.hpp" -#include "atom/type/json.hpp" -using json = nlohmann::json; - -#include "module/battery.hpp" -#include "module/cpu.hpp" -#include "module/disk.hpp" -#include "module/gpu.hpp" -#include "module/memory.hpp" -#include "module/os.hpp" -#include "module/wifi.hpp" - -#include "_constant.hpp" - -#define ATOM_SYSTEM_NO_ARGS \ - if (!m_params.is_null()) { \ - LOG_F(ERROR, "SystemComponent::{}: Invalid params", __func__); \ - return createErrorResponse(__func__, \ - {"error", Constants::INVALID_PARAMETER}, \ - "no argument should be found"); \ - } - -#define GET_CPU_INFO(name, func) \ - auto name = func(); \ - if (name < 0 || name > 100) { \ - LOG_F(ERROR, "SystemComponent::getCPUInfo: Failed to get {}", #name); \ - return createErrorResponse(__func__, \ - {"error", "failed to get " #name}, \ - Constants::SYSTEM_ERROR); \ - } - -#define GET_CPU_INFO_S(name, func) \ - auto name = func(); \ - if (name.empty()) { \ - LOG_F(ERROR, "SystemComponent::getCPUInfo: Failed to get {}", #name); \ - return createErrorResponse(__func__, \ - {"error", "failed to get " #name}, \ - Constants::SYSTEM_ERROR); \ - } - -#define GET_MEMORY_INFO(name, func) \ - auto name = func(); \ - if (name < 0) { \ - LOG_F(ERROR, "SystemComponent::getMemoryInfo: Failed to get {}", \ - #name); \ - return createErrorResponse(__func__, \ - {"error", "failed to get " #name}, \ - Constants::SYSTEM_ERROR); \ - } - -SystemComponent::SystemComponent(const std::string &name) - : SharedComponent(name) { - DLOG_F(INFO, "SystemComponent::SystemComponent"); - - registerFunc("getCPUInfo", &SystemComponent::getCPUInfo, this); - registerFunc("getMemoryInfo", &SystemComponent::getMemoryInfo, this); - registerFunc("getDiskInfo", &SystemComponent::getDiskInfo, this); - registerFunc("getNetworkInfo", &SystemComponent::getNetworkInfo, this); - registerFunc("getBatteryInfo", &SystemComponent::getBatteryInfo, this); - registerFunc("getGPUInfo", &SystemComponent::getGPUInfo, this); - registerFunc("getOSInfo", &SystemComponent::getOSInfo, this); - - registerVariable("cpuUsage", "", "The CPU usage"); - registerVariable("cpuTemperature", "", "The CPU temperature"); - registerVariable("cpuModel", "", "The CPU model"); - registerVariable("cpuFrequency", "", "The CPU frequency"); - registerVariable("numberOfPhysicalPackages", "", - "The number of physical " - "packages"); - registerVariable("numberOfPhysicalCPUs", "", "The number of physical CPUs"); - registerVariable("processorIdentifier", "", "The processor identifier"); - registerVariable("processorFrequency", "", "The processor frequency"); - - registerVariable("memoryUsage", "", "The memory usage"); - registerVariable("memoryTotal", "", "The total memory"); - registerVariable("memoryMax", "", "The maximum memory"); - registerVariable("memoryUsed", "", "The used memory"); - registerVariable("memoryAvailable", "", "The available memory"); - registerVariable("memorySwapTotal", "", "The total swap memory"); - - registerVariable("diskUsage", "", "The disk usage"); - registerVariable("diskTotal", "", "The total disk"); - registerVariable("diskAvailable", "", "The available disk"); - registerVariable("diskUsed", "", "The used disk"); - - registerVariable("networkWifi", "", "The wifi network"); - registerVariable("networkWired", "", "The wired network"); - registerVariable("networkHotspot", "", "The hotspot network"); -} - -SystemComponent::~SystemComponent() { - DLOG_F(INFO, "SystemComponent::~SystemComponent"); -} - -bool SystemComponent::initialize() { return true; } - -bool SystemComponent::destroy() { return true; } - -json SystemComponent::getCPUInfo(const json &m_params) { - DLOG_F(INFO, "SystemComponent::getCPUInfo"); - - ATOM_SYSTEM_NO_ARGS; - - GET_CPU_INFO(current_cpu_usage, Atom::System::getCurrentCpuUsage); - GET_CPU_INFO(current_cpu_temperature, - Atom::System::getCurrentCpuTemperature); - GET_CPU_INFO_S(cpu_model, Atom::System::getCPUModel); - GET_CPU_INFO_S(processor_identifier, Atom::System::getProcessorIdentifier); - GET_CPU_INFO(processor_frequency, Atom::System::getProcessorFrequency); - GET_CPU_INFO(number_of_physical_packages, - Atom::System::getNumberOfPhysicalPackages); - GET_CPU_INFO(number_of_physical_cpus, - Atom::System::getNumberOfPhysicalCPUs); - - return createSuccessResponse( - __func__, { - {"currentCpuUsage", current_cpu_usage}, - {"currentCpuTemperature", current_cpu_temperature}, - {"cpuModel", cpu_model}, - {"processorIdentifier", processor_identifier}, - {"processorFrequency", processor_frequency}, - {"numberOfPhysicalPackages", number_of_physical_packages}, - {"numberOfPhysicalCPUs", number_of_physical_cpus}, - }); -} - -json SystemComponent::getMemoryInfo(const json &m_params) { - DLOG_F(INFO, "SystemComponent::getMemoryInfo"); - ATOM_SYSTEM_NO_ARGS; - - GET_MEMORY_INFO(current_memory_usage, Atom::System::getMemoryUsage); - GET_MEMORY_INFO(total_memory_size, Atom::System::getTotalMemorySize); - GET_MEMORY_INFO(available_memory_size, - Atom::System::getAvailableMemorySize); - GET_MEMORY_INFO(virtual_memory_max, Atom::System::getVirtualMemoryMax); - GET_MEMORY_INFO(virtual_memory_used, Atom::System::getVirtualMemoryUsed); - GET_MEMORY_INFO(swap_memory_used, Atom::System::getSwapMemoryUsed); - GET_MEMORY_INFO(swap_memory_total, Atom::System::getSwapMemoryTotal); - - return createSuccessResponse( - __func__, { - {"currentMemoryUsage", current_memory_usage}, - {"totalMemorySize", total_memory_size}, - {"availableMemorySize", available_memory_size}, - {"virtualMemoryMax", virtual_memory_max}, - {"virtualMemoryUsed", virtual_memory_used}, - {"swapMemoryUsed", swap_memory_used}, - {"swapMemoryTotal", swap_memory_total}, - }); -} - -json SystemComponent::getDiskInfo(const json &m_params) { - DLOG_F(INFO, "SystemComponent::getDiskInfo"); - ATOM_SYSTEM_NO_ARGS; - auto disks_usage = Atom::System::getDiskUsage(); - if (disks_usage.size() == 0) { - LOG_F(ERROR, "SystemComponent::getDiskInfo: Failed to get disk info"); - return createErrorResponse(__func__, - {"error", "failed to get disk info"}, - Constants::SYSTEM_ERROR); - } - json res; - for (auto &disk : disks_usage) { - res.push_back({{"drive", disk.first}, {"usage", disk.second}}); - } - return createSuccessResponse(__func__, res); -} - -json SystemComponent::getBatteryInfo(const json &m_params) { - DLOG_F(INFO, "SystemComponent::getBatteryInfo"); - ATOM_SYSTEM_NO_ARGS; - auto battery_info = Atom::System::getBatteryInfo(); - if (battery_info.isBatteryPresent == false) { - LOG_F(ERROR, - "SystemComponent::getBatteryInfo: Failed to get battery info"); - return createErrorResponse(__func__, - {"error", "failed to get battery info"}, - Constants::SYSTEM_ERROR); - } - return createSuccessResponse( - __func__, {{"energyNow", battery_info.energyNow}, - {"energyDesign", battery_info.energyDesign}, - {"currentNow", battery_info.currentNow}, - {"batteryLifeTime", battery_info.batteryLifeTime}, - {"batteryFullLifeTime", battery_info.batteryFullLifeTime}, - {"batteryLifePercent", battery_info.batteryLifePercent}, - {"energyFull", battery_info.energyFull}, - {"voltageNow", battery_info.voltageNow}, - {"isBatteryPresent", battery_info.isBatteryPresent}, - {"isCharging", battery_info.isCharging}}); -} - -json SystemComponent::getNetworkInfo(const json &m_params) { - DLOG_F(INFO, "SystemComponent::getNetworkInfo"); - ATOM_SYSTEM_NO_ARGS; - auto wifi = Atom::System::getCurrentWifi(); - auto wired = Atom::System::getCurrentWiredNetwork(); - auto hotspot = Atom::System::isHotspotConnected(); - return createSuccessResponse( - __func__, {{"wifi", wifi}, {"wired", wired}, {"hotspot", hotspot}}); -} - -json SystemComponent::getGPUInfo(const json &m_params) { - DLOG_F(INFO, "SystemComponent::getGPUInfo"); - ATOM_SYSTEM_NO_ARGS; - auto gpu_info = Atom::System::getGPUInfo(); - if (gpu_info.empty()) { - LOG_F(ERROR, "SystemComponent::getGPUInfo: Failed to get GPU info"); - return createErrorResponse(__func__, - {"error", "failed to get GPU info"}, - Constants::SYSTEM_ERROR); - } - return createSuccessResponse(__func__, {"gpu1", gpu_info}); -} - -json SystemComponent::getOSInfo(const json &m_params) { - DLOG_F(INFO, "SystemComponent::getOSInfo"); - ATOM_SYSTEM_NO_ARGS; - auto os_info = Atom::System::getOperatingSystemInfo(); - return createSuccessResponse(__func__, - {{"osName", os_info.osName}, - {"osVersion", os_info.osVersion}, - {"kernelVersion", os_info.kernelVersion}, - {"architecture", os_info.architecture}, - {"compiler", os_info.compiler}}); -} \ No newline at end of file diff --git a/src/atom/system/_component.hpp b/src/atom/system/_component.hpp deleted file mode 100644 index 85471ef6..00000000 --- a/src/atom/system/_component.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * _component.hpp - * - * Copyright (C) 2023-2024 Max Qian - */ - -/************************************************* - -Date: 2024-4-13 - -Description: Component of Atom-System - -**************************************************/ - -#ifndef ATOM_SYSTEM_COMPONENT_HPP -#define ATOM_SYSTEM_COMPONENT_HPP - -#include "atom/components/templates/shared_component.hpp" - -class SystemComponent : public SharedComponent -{ -public: - explicit SystemComponent(const std::string &name); - ~SystemComponent(); - - // ------------------------------------------------------------------- - // Common methods - // ------------------------------------------------------------------- - - bool initialize() override; - bool destroy() override; - - // ------------------------------------------------------------------- - // System methods - // ------------------------------------------------------------------- - - json getCPUInfo(const json &m_params); - json getMemoryInfo(const json &m_params); - json getDiskInfo(const json &m_params); - json getNetworkInfo(const json &m_params); - json getGPUInfo(const json &m_params); - json getBatteryInfo(const json &m_params); - json getOSInfo(const json &m_params); - -}; - -#endif diff --git a/src/atom/system/_pybind.cpp b/src/atom/system/_pybind.cpp index ed16e1e3..e4029b6c 100644 --- a/src/atom/system/_pybind.cpp +++ b/src/atom/system/_pybind.cpp @@ -30,7 +30,7 @@ Description: Python Binding of Atom-System Module namespace py = pybind11; -using namespace Atom::System; +using namespace atom::system; PYBIND11_MODULE(atom_system, m) { pybind11::class_(m, "BatteryInfo") @@ -145,9 +145,9 @@ PYBIND11_MODULE(atom_system, m) { m.def("jwalk", &jwalk); m.def("fwalk", &fwalk); m.def("Environ", &Environ); - m.def("ctermid", &Atom::System::ctermid); + m.def("ctermid", &atom::system::ctermid); m.def("getpriority", &getpriority); - m.def("getlogin", &Atom::System::getlogin); + m.def("getlogin", &atom::system::getlogin); m.def("uname", &uname); py::class_(m, "PidWatcher") diff --git a/src/atom/system/_script.hpp b/src/atom/system/_script.hpp index 3e1180b5..29087fef 100644 --- a/src/atom/system/_script.hpp +++ b/src/atom/system/_script.hpp @@ -37,7 +37,7 @@ Description: Carbon binding for Atom-System #include "system.hpp" #include "user.hpp" -using namespace Atom::System; +using namespace atom::system; namespace Atom::_Script::System { /** diff --git a/src/atom/system/command.cpp b/src/atom/system/command.cpp index e527149b..9b4bde69 100644 --- a/src/atom/system/command.cpp +++ b/src/atom/system/command.cpp @@ -36,7 +36,7 @@ Description: Simple wrapper for executing commands. #define UNSETENV(name) unsetenv(name) #endif -namespace Atom::System { +namespace atom::system { std::string executeCommand( const std::string &command, bool openTerminal, std::function processLine) { @@ -280,4 +280,4 @@ std::pair executeCommandWithStatus( return {output.str(), status}; } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/command.hpp b/src/atom/system/command.hpp index 4953e51c..12390419 100644 --- a/src/atom/system/command.hpp +++ b/src/atom/system/command.hpp @@ -25,7 +25,7 @@ Description: Simple wrapper for executing commands. #include #endif -namespace Atom::System { +namespace atom::system { #ifdef _WIN32 struct ProcessHandle { HANDLE handle; @@ -111,6 +111,6 @@ void killProcess(const ProcessHandle &handle); */ [[nodiscard]] std::pair executeCommandWithStatus( const std::string &command); -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/system/crash.cpp b/src/atom/system/crash.cpp index 0a2fc62e..67a335ed 100644 --- a/src/atom/system/crash.cpp +++ b/src/atom/system/crash.cpp @@ -48,7 +48,7 @@ Description: Crash Report #include "atom/error/exception.hpp" #include "atom/utils/string.hpp" -namespace Atom::System { +namespace atom::system { // 获取系统信息 std::string getSystemInfo() { std::stringstream ss; @@ -588,4 +588,4 @@ void saveCrashLog(const std::string &error_msg) { LOG_F(ERROR, "Failed to write crash report: {}", e.what()); } } -} // namespace Atom::System \ No newline at end of file +} // namespace atom::system \ No newline at end of file diff --git a/src/atom/system/crash.hpp b/src/atom/system/crash.hpp index 5c016a54..ee72a2df 100644 --- a/src/atom/system/crash.hpp +++ b/src/atom/system/crash.hpp @@ -17,7 +17,7 @@ Description: Crash Report #include -namespace Atom::System { +namespace atom::system { /** * @brief 保存崩溃日志 * @param error_msg 崩溃日志详细信息 @@ -36,6 +36,6 @@ namespace Atom::System { * otherwise calling this function will have no effect. */ void saveCrashLog(const std::string &error_msg); -} // namespace Atom::System +} // namespace atom::system #endif diff --git a/src/atom/system/crash_quotes.cpp b/src/atom/system/crash_quotes.cpp index 289a412d..6570c95b 100644 --- a/src/atom/system/crash_quotes.cpp +++ b/src/atom/system/crash_quotes.cpp @@ -20,7 +20,7 @@ Description: Quote manager for crash report. #include "atom/error/exception.hpp" -namespace Atom::System { +namespace atom::system { Quote::Quote(const std::string &text, const std::string &author) : text(text), author(author) {} @@ -111,7 +111,7 @@ std::string QuoteManager::getRandomQuote() const { std::uniform_int_distribution<> dis(0, quotes.size() - 1); return quotes[dis(gen)].getText() + " - " + quotes[dis(gen)].getAuthor(); } -} // namespace Atom::System +} // namespace atom::system /* int main() diff --git a/src/atom/system/crash_quotes.hpp b/src/atom/system/crash_quotes.hpp index 6aa0f99e..9b09956a 100644 --- a/src/atom/system/crash_quotes.hpp +++ b/src/atom/system/crash_quotes.hpp @@ -18,7 +18,7 @@ Description: Quote manager for crash report. #include #include -namespace Atom::System { +namespace atom::system { /** * @brief Represents a quote with its text and author. */ @@ -127,6 +127,6 @@ class QuoteManager { private: std::vector quotes; }; -} // namespace Atom::System +} // namespace atom::system #endif diff --git a/src/atom/system/lregistry.cpp b/src/atom/system/lregistry.cpp index f8fc41d5..81c40864 100644 --- a/src/atom/system/lregistry.cpp +++ b/src/atom/system/lregistry.cpp @@ -20,7 +20,7 @@ Description: A self-contained registry manager. #include "atom/log/loguru.hpp" -namespace Atom::System { +namespace atom::system { class Registry::RegistryImpl { public: @@ -173,4 +173,4 @@ void Registry::RegistryImpl::notifyEvent(const std::string& eventType, DLOG_F(INFO, "Event: {} occurred for key: {}", eventType, keyName); } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/lregistry.hpp b/src/atom/system/lregistry.hpp index e65ea895..ab10ae78 100644 --- a/src/atom/system/lregistry.hpp +++ b/src/atom/system/lregistry.hpp @@ -19,7 +19,7 @@ Description: A self-contained registry manager. #include #include -namespace Atom::System { +namespace atom::system { /** * @brief The Registry class handles registry operations. */ @@ -117,6 +117,6 @@ class Registry { std::unique_ptr pImpl; // Pointer to the implementation class }; -} // namespace Atom::System +} // namespace atom::system #endif diff --git a/src/atom/system/module/battery.cpp b/src/atom/system/module/battery.cpp index f9af7576..ee661f34 100644 --- a/src/atom/system/module/battery.cpp +++ b/src/atom/system/module/battery.cpp @@ -32,7 +32,7 @@ Description: System Information Module - Battery #endif -namespace Atom::System { +namespace atom::system { BatteryInfo getBatteryInfo() { BatteryInfo info; @@ -142,4 +142,4 @@ BatteryInfo getBatteryInfo() { #endif return info; } -} // namespace Atom::System \ No newline at end of file +} // namespace atom::system \ No newline at end of file diff --git a/src/atom/system/module/battery.hpp b/src/atom/system/module/battery.hpp index 2806f38b..957d2bc9 100644 --- a/src/atom/system/module/battery.hpp +++ b/src/atom/system/module/battery.hpp @@ -15,7 +15,7 @@ Description: System Information Module - Battery #ifndef ATOM_SYSTEM_MODULE_BATTERY_HPP #define ATOM_SYSTEM_MODULE_BATTERY_HPP -namespace Atom::System { +namespace atom::system { /** * @brief Battery information. * 电池信息 @@ -34,5 +34,5 @@ struct BatteryInfo { }; BatteryInfo getBatteryInfo(); -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/system/module/cpu.cpp b/src/atom/system/module/cpu.cpp index 2d685890..62712be7 100644 --- a/src/atom/system/module/cpu.cpp +++ b/src/atom/system/module/cpu.cpp @@ -51,7 +51,7 @@ namespace fs = std::filesystem; #include "atom/log/loguru.hpp" -namespace Atom::System { +namespace atom::system { float getCurrentCpuUsage() { float cpu_usage = 0.0; @@ -416,4 +416,4 @@ int getNumberOfPhysicalCPUs() { return numberOfCPUs; } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/module/cpu.hpp b/src/atom/system/module/cpu.hpp index b851fd37..aeffb880 100644 --- a/src/atom/system/module/cpu.hpp +++ b/src/atom/system/module/cpu.hpp @@ -17,7 +17,7 @@ Description: System Information Module - CPU #include -namespace Atom::System { +namespace atom::system { /** * @brief Get the CPU usage percentage. * 获取 CPU 使用率百分比 @@ -81,6 +81,6 @@ int getNumberOfPhysicalPackages(); */ int getNumberOfPhysicalCPUs(); -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/system/module/disk.cpp b/src/atom/system/module/disk.cpp index 94ae134a..76c1a0df 100644 --- a/src/atom/system/module/disk.cpp +++ b/src/atom/system/module/disk.cpp @@ -49,7 +49,7 @@ Description: System Information Module - Disk #include #endif -namespace Atom::System { +namespace atom::system { std::vector> getDiskUsage() { std::vector> disk_usage; @@ -249,4 +249,4 @@ double calculateDiskUsagePercentage(unsigned long totalSpace, totalSpace) * 100.0; } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/module/disk.hpp b/src/atom/system/module/disk.hpp index 91942f17..488cf521 100644 --- a/src/atom/system/module/disk.hpp +++ b/src/atom/system/module/disk.hpp @@ -18,7 +18,7 @@ Description: System Information Module - Disk #include #include -namespace Atom::System { +namespace atom::system { /** * @brief Get the disk usage for all disks. * 获取所有磁盘的使用情况 @@ -67,5 +67,5 @@ namespace Atom::System { [[nodiscard]] double calculateDiskUsagePercentage(unsigned long totalSpace, unsigned long freeSpace); -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/system/module/gpu.cpp b/src/atom/system/module/gpu.cpp index 56130c26..e851fbf0 100644 --- a/src/atom/system/module/gpu.cpp +++ b/src/atom/system/module/gpu.cpp @@ -15,15 +15,14 @@ Description: System Information Module - GPU #include "gpu.hpp" #ifdef _WIN32 +#include #include #include -#include - #elif defined(__linux__) #include #endif -namespace Atom::System { +namespace atom::system { std::string getGPUInfo() { std::string gpuInfo; @@ -76,4 +75,4 @@ std::string getGPUInfo() { return gpuInfo; } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/module/gpu.hpp b/src/atom/system/module/gpu.hpp index dc83a0e0..fa904de9 100644 --- a/src/atom/system/module/gpu.hpp +++ b/src/atom/system/module/gpu.hpp @@ -17,12 +17,12 @@ Description: System Information Module - GPU #include -namespace Atom::System { +namespace atom::system { /** * @brief Get GPU information * @return std::string GPU information */ [[nodiscard]] std::string getGPUInfo(); -} // namespace Atom::System +} // namespace atom::system #endif diff --git a/src/atom/system/module/memory.cpp b/src/atom/system/module/memory.cpp index 8ae03937..9f1f326f 100644 --- a/src/atom/system/module/memory.cpp +++ b/src/atom/system/module/memory.cpp @@ -50,7 +50,7 @@ Description: System Information Module - Memory #endif -namespace Atom::System { +namespace atom::system { float getMemoryUsage() { float memory_usage = 0.0; @@ -339,4 +339,4 @@ unsigned long long getSwapMemoryUsed() { return swapMemoryUsed; } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/module/memory.hpp b/src/atom/system/module/memory.hpp index 7f40f68c..7176ed69 100644 --- a/src/atom/system/module/memory.hpp +++ b/src/atom/system/module/memory.hpp @@ -18,7 +18,7 @@ Description: System Information Module - Memory #include #include -namespace Atom::System { +namespace atom::system { struct MemoryInfo { struct MemorySlot { std::string capacity; @@ -108,6 +108,6 @@ unsigned long long getSwapMemoryTotal(); * 交换内存已用值 */ unsigned long long getSwapMemoryUsed(); -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/system/module/os.cpp b/src/atom/system/module/os.cpp index 85c0b6d0..2b31b825 100644 --- a/src/atom/system/module/os.cpp +++ b/src/atom/system/module/os.cpp @@ -26,7 +26,7 @@ Description: System Information Module - OS Information #include "atom/log/loguru.hpp" -namespace Atom::System { +namespace atom::system { std::string OperatingSystemInfo::toJson() const { std::stringstream ss; ss << "{\n"; @@ -119,4 +119,4 @@ OperatingSystemInfo getOperatingSystemInfo() { return osInfo; } -} // namespace Atom::System \ No newline at end of file +} // namespace atom::system \ No newline at end of file diff --git a/src/atom/system/module/os.hpp b/src/atom/system/module/os.hpp index 3e524e9e..3f67540b 100644 --- a/src/atom/system/module/os.hpp +++ b/src/atom/system/module/os.hpp @@ -17,7 +17,7 @@ Description: System Information Module - OS Information #include -namespace Atom::System { +namespace atom::system { /** * @brief Represents information about the operating system. */ @@ -40,6 +40,6 @@ struct OperatingSystemInfo { */ OperatingSystemInfo getOperatingSystemInfo(); -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/system/module/wifi.cpp b/src/atom/system/module/wifi.cpp index f91645eb..6d89e452 100644 --- a/src/atom/system/module/wifi.cpp +++ b/src/atom/system/module/wifi.cpp @@ -37,7 +37,7 @@ Description: System Information Module - Wifi Information #include "atom/log/loguru.hpp" -namespace Atom::System +namespace atom::system { // 获取当前连接的WIFI std::string getCurrentWifi() { diff --git a/src/atom/system/module/wifi.hpp b/src/atom/system/module/wifi.hpp index df8e88e0..f1a80bec 100644 --- a/src/atom/system/module/wifi.hpp +++ b/src/atom/system/module/wifi.hpp @@ -18,7 +18,7 @@ Description: System Information Module - Wifi Information #include #include -namespace Atom::System { +namespace atom::system { /** * @brief Get current wifi name * @return Current wifi name @@ -42,6 +42,6 @@ namespace Atom::System { * @return Vector of host IP addresses */ std::vector getHostIPs(); -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/system/os.cpp b/src/atom/system/os.cpp index 4fe2fa71..a64f73c8 100644 --- a/src/atom/system/os.cpp +++ b/src/atom/system/os.cpp @@ -15,8 +15,8 @@ Description: Some useful system functions from Python. #include "os.hpp" #include -#include -#include +#include +#include #ifdef _WIN32 #include #include @@ -32,7 +32,7 @@ Description: Some useful system functions from Python. using json = nlohmann::json; -namespace Atom::System { +namespace atom::system { void walk(const fs::path &root) { for (const auto &entry : fs::directory_iterator(root)) { if (fs::is_directory(entry)) { @@ -44,21 +44,44 @@ void walk(const fs::path &root) { } } +json walk(const fs::path &path, bool recursive) { + DLOG_F(INFO, "Walking: {}", path.generic_string()); + if (!fs::exists(path)) { + LOG_F(ERROR, "Path does not exist: {}", path.generic_string()); + return json(); + } + + json folder = {{"path", path.generic_string()}, + {"directories", json::array()}, + {"files", json::array()}}; + + for (const auto &entry : fs::directory_iterator(path)) { + if (fs::is_directory(entry)) { + DLOG_F(INFO, "Directory: {}", entry.path().generic_string()); + folder["directories"].push_back(walk(entry.path(), true)); + } else { + DLOG_F(INFO, "File: {}", entry.path().generic_string()); + folder["files"].push_back(entry.path().generic_string()); + } + } + + return folder; +} + std::string jwalk(const std::string &root) { - DLOG_F(INFO, "Walking: {}", root.generic_string()); - if (!atom::io::isFolderExists(root)) - { + DLOG_F(INFO, "Walking: {}", root); + if (!fs::exists(root)) { LOG_F(ERROR, "Directory not exists: {}", root); return ""; } - json folder = {{"path", root.generic_string()}, + json folder = {{"path", root}, {"directories", json::array()}, {"files", json::array()}}; for (const auto &entry : fs::directory_iterator(root)) { if (fs::is_directory(entry)) { DLOG_F(INFO, "Directory: {}", entry.path().generic_string()); - folder["directories"].push_back(walk(entry)); + folder["directories"].push_back(walk(entry, true)); } else { DLOG_F(INFO, "File: {}", entry.path().generic_string()); folder["files"].push_back(entry.path().generic_string()); @@ -228,4 +251,4 @@ Utsname uname() { return info; } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/os.hpp b/src/atom/system/os.hpp index d2557eaa..cc204bca 100644 --- a/src/atom/system/os.hpp +++ b/src/atom/system/os.hpp @@ -16,11 +16,13 @@ Description: Some useful system functions from Python. #define ATOM_SYSTEM_OS_HPP #include +#include #include +#include namespace fs = std::filesystem; -namespace Atom::System { +namespace atom::system { struct Utsname { std::string sysname; // 操作系统名称 std::string nodename; // 网络中的主机名 @@ -113,6 +115,6 @@ std::string getlogin(); */ Utsname uname(); -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/system/pidwatcher.cpp b/src/atom/system/pidwatcher.cpp index 21730cac..9e537c45 100644 --- a/src/atom/system/pidwatcher.cpp +++ b/src/atom/system/pidwatcher.cpp @@ -33,7 +33,7 @@ namespace fs = std::filesystem; #include "atom/log/loguru.hpp" -namespace Atom::System { +namespace atom::system { PidWatcher::PidWatcher() : running_(false), monitoring_(false) {} PidWatcher::~PidWatcher() { Stop(); } @@ -246,4 +246,4 @@ void PidWatcher::ExitThread() { } } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/pidwatcher.hpp b/src/atom/system/pidwatcher.hpp index ef3e31f1..18447105 100644 --- a/src/atom/system/pidwatcher.hpp +++ b/src/atom/system/pidwatcher.hpp @@ -22,7 +22,7 @@ Description: PID Watcher #include -namespace Atom::System { +namespace atom::system { /** * @brief A class for monitoring processes by their PID. @@ -126,6 +126,6 @@ class PidWatcher { std::condition_variable exit_cv_; ///< Condition variable for process exit. }; -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/system/process.cpp b/src/atom/system/process.cpp index 71f60879..7e9296cc 100644 --- a/src/atom/system/process.cpp +++ b/src/atom/system/process.cpp @@ -34,7 +34,7 @@ Description: Process Manager #include "atom/log/loguru.hpp" -namespace Atom::System { +namespace atom::system { ProcessManager::ProcessManager() { m_maxProcesses = 10; } ProcessManager::ProcessManager(int maxProcess) : m_maxProcesses(maxProcess) {} @@ -405,4 +405,4 @@ Process GetSelfProcessInfo() { return info; } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/process.hpp b/src/atom/system/process.hpp index 0ad6566e..2e67a292 100644 --- a/src/atom/system/process.hpp +++ b/src/atom/system/process.hpp @@ -34,7 +34,7 @@ Description: Process Manager #include #endif -namespace Atom::System { +namespace atom::system { struct Process { pid_t pid; std::string name; @@ -152,6 +152,6 @@ std::vector> GetAllProcesses(); */ Process GetSelfProcessInfo(); -} // namespace Atom::System +} // namespace atom::system #endif diff --git a/src/atom/system/stat.cpp b/src/atom/system/stat.cpp new file mode 100644 index 00000000..7d41f257 --- /dev/null +++ b/src/atom/system/stat.cpp @@ -0,0 +1,126 @@ +/* + * stat.hpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2023-6-17 + +Description: Python like stat for Windows & Linux + +**************************************************/ + +#include "stat.hpp" + +#include +#include +#include + +#ifdef _WIN32 +#include +#else +#include +#endif + +namespace atom::system { +Stat::Stat(const fs::path& path) : path_(path) { update(); } + +void Stat::update() { + [[maybe_unused]] fs::file_status status = fs::status(path_, ec_); + if (ec_) { + throw std::filesystem::filesystem_error("Failed to get file status", + path_, ec_); + } +} + +fs::file_type Stat::type() const { return fs::status(path_).type(); } + +std::uintmax_t Stat::size() const { return fs::file_size(path_); } + +std::time_t Stat::atime() const { + using namespace std::chrono; + auto fileTime = fs::last_write_time(path_); + auto duration = fileTime.time_since_epoch(); + auto sysTime = system_clock::time_point(duration); + return system_clock::to_time_t(sysTime); +} + +std::time_t Stat::mtime() const { + return std::chrono::system_clock::to_time_t( + std::chrono::clock_cast( + fs::last_write_time(path_))); +} + +std::time_t Stat::ctime() const { +#ifdef _WIN32 + WIN32_FILE_ATTRIBUTE_DATA attr; + if (!GetFileAttributesEx(path_.string().c_str(), GetFileExInfoStandard, + &attr)) { + throw std::system_error( + std::error_code(GetLastError(), std::system_category()), + "Failed to get file attributes"); + } + auto fileTime = FILETIME{attr.ftCreationTime}; + auto fileTimeNS = std::chrono::nanoseconds{ + (std::uint64_t(fileTime.dwHighDateTime) << 32) | + fileTime.dwLowDateTime}; + auto sysTime = + std::chrono::time_point(fileTimeNS); + auto sysTimeCast = + std::chrono::time_point_cast( + sysTime); + return std::chrono::system_clock::to_time_t(sysTimeCast); + +#else + struct stat attr; + if (stat(path_.c_str(), &attr) != 0) { + throw std::system_error(std::error_code(errno, std::system_category()), + "Failed to get file attributes"); + } + return attr.st_ctime; +#endif +} + +int Stat::mode() const { +#ifdef _WIN32 + return 0; +#else + struct stat attr; + if (stat(path_.c_str(), &attr) != 0) { + throw std::system_error(std::error_code(errno, std::system_category()), + "Failed to get file attributes"); + } + return attr.st_mode; +#endif +} + +int Stat::uid() const { +#ifdef _WIN32 + return 0; +#else + struct stat attr; + if (stat(path_.c_str(), &attr) != 0) { + throw std::system_error(std::error_code(errno, std::system_category()), + "Failed to get file attributes"); + } + return attr.st_uid; +#endif +} + +int Stat::gid() const { +#ifdef _WIN32 + return 0; +#else + struct stat attr; + if (stat(path_.c_str(), &attr) != 0) { + throw std::system_error(std::error_code(errno, std::system_category()), + "Failed to get file attributes"); + } + return attr.st_gid; +#endif +} + +fs::path Stat::path() const { return path_; } +} // namespace atom::system \ No newline at end of file diff --git a/src/atom/system/stat.hpp b/src/atom/system/stat.hpp new file mode 100644 index 00000000..5c71ea8b --- /dev/null +++ b/src/atom/system/stat.hpp @@ -0,0 +1,120 @@ +/* + * stat.hpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2023-6-17 + +Description: Python like stat for Windows & Linux + +**************************************************/ + +#ifndef ATOM_SYSTEM_STAT_HPP +#define ATOM_SYSTEM_STAT_HPP + +#include +#include +#include + +namespace fs = std::filesystem; + +namespace atom::system +{ +/** + * @brief Class representing file statistics. + * + * This class provides methods to retrieve various attributes of a file, + * such as its type, size, access time, modification time, and so on. + */ +class Stat { +public: + /** + * @brief Constructs a `Stat` object for the specified file path. + * + * @param path The path to the file whose statistics are to be retrieved. + */ + explicit Stat(const fs::path& path); + + /** + * @brief Updates the file statistics. + * + * This method refreshes the statistics for the file specified in the + * constructor. + */ + void update(); + + /** + * @brief Gets the type of the file. + * + * @return The type of the file as an `fs::file_type` enum value. + */ + [[nodiscard]] fs::file_type type() const; + + /** + * @brief Gets the size of the file. + * + * @return The size of the file in bytes. + */ + [[nodiscard]] std::uintmax_t size() const; + + /** + * @brief Gets the last access time of the file. + * + * @return The last access time of the file as a `std::time_t` value. + */ + [[nodiscard]] std::time_t atime() const; + + /** + * @brief Gets the last modification time of the file. + * + * @return The last modification time of the file as a `std::time_t` value. + */ + [[nodiscard]] std::time_t mtime() const; + + /** + * @brief Gets the creation time of the file. + * + * @return The creation time of the file as a `std::time_t` value. + */ + [[nodiscard]] std::time_t ctime() const; + + /** + * @brief Gets the file mode/permissions. + * + * @return The file mode/permissions as an integer value. + */ + [[nodiscard]] int mode() const; + + /** + * @brief Gets the user ID of the file owner. + * + * @return The user ID of the file owner as an integer value. + */ + [[nodiscard]] int uid() const; + + /** + * @brief Gets the group ID of the file owner. + * + * @return The group ID of the file owner as an integer value. + */ + [[nodiscard]] int gid() const; + + /** + * @brief Gets the path of the file. + * + * @return The path of the file as an `fs::path` object. + */ + [[nodiscard]] fs::path path() const; + +private: + fs::path path_; ///< The path to the file. + std::error_code + ec_; ///< The error code for handling errors during file operations. +}; +} + + +#endif // ATOM_SYSTEM_STAT_HPP \ No newline at end of file diff --git a/src/atom/system/storage.cpp b/src/atom/system/storage.cpp index da4fcda1..46063434 100644 --- a/src/atom/system/storage.cpp +++ b/src/atom/system/storage.cpp @@ -32,7 +32,7 @@ Description: Storage Monitor namespace fs = std::filesystem; -namespace Atom::System { +namespace atom::system { void StorageMonitor::registerCallback( std::function callback) { std::lock_guard lock(m_mutex); @@ -123,7 +123,7 @@ void StorageMonitor::listFiles(const std::string &path) { std::cout << std::endl; } #endif -} // namespace Atom::System +} // namespace atom::system #ifdef _WIN32 void monitorUdisk() { @@ -182,7 +182,7 @@ void monitorUdisk() { UnregisterDeviceNotification(hDevNotify); } #else -static void monitorUdisk(Atom::System::StorageMonitor &monitor) { +static void monitorUdisk(atom::system::StorageMonitor &monitor) { struct udev *udev = udev_new(); if (!udev) { LOG_F(ERROR, "Failed to initialize udev"); diff --git a/src/atom/system/storage.hpp b/src/atom/system/storage.hpp index 56fa3b17..4c4c1815 100644 --- a/src/atom/system/storage.hpp +++ b/src/atom/system/storage.hpp @@ -21,7 +21,7 @@ Description: Storage Monitor #include #include -namespace Atom::System { +namespace atom::system { /** * @brief 监控存储空间变化的类。 * @@ -99,6 +99,6 @@ class StorageMonitor { static void monitorUdisk(StorageMonitor &monitor); #endif -} // namespace Atom::System +} // namespace atom::system #endif diff --git a/src/atom/system/system.cpp b/src/atom/system/system.cpp index 3f0d3c86..0eb89b24 100644 --- a/src/atom/system/system.cpp +++ b/src/atom/system/system.cpp @@ -53,7 +53,7 @@ namespace fs = std::filesystem; #include "atom/error/exception.hpp" #include "atom/log/loguru.hpp" -namespace Atom::System { +namespace atom::system { bool checkSoftwareInstalled(const std::string &software_name) { bool is_installed = false; #ifdef _WIN32 @@ -589,4 +589,4 @@ bool getProcessInfoByName(const std::string &processName, return false; } #endif -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/system.hpp b/src/atom/system/system.hpp index 5ff6046e..440cb3e4 100644 --- a/src/atom/system/system.hpp +++ b/src/atom/system/system.hpp @@ -22,7 +22,7 @@ Description: System #include #endif -namespace Atom::System { +namespace atom::system { /** * @brief Process information. * 进程信息 @@ -155,6 +155,6 @@ bool getProcessInfoByID(int processID, ProcessInfo &processInfo); */ bool getProcessInfoByName(const std::string &processName, ProcessInfo &processInfo); -} // namespace Atom::System +} // namespace atom::system #endif diff --git a/src/atom/system/user.cpp b/src/atom/system/user.cpp index d9809200..36636524 100644 --- a/src/atom/system/user.cpp +++ b/src/atom/system/user.cpp @@ -30,7 +30,7 @@ Description: Some system functions to get user information. #include "atom/log/loguru.hpp" -namespace Atom::System { +namespace atom::system { std::vector getUserGroups() { std::vector groups; @@ -255,4 +255,4 @@ std::string getLoginShell() { #endif return loginShell; } -} // namespace Atom::System +} // namespace atom::system diff --git a/src/atom/system/user.hpp b/src/atom/system/user.hpp index 323f450c..48db6be3 100644 --- a/src/atom/system/user.hpp +++ b/src/atom/system/user.hpp @@ -18,7 +18,7 @@ Description: Some system functions to get user information. #include #include -namespace Atom::System { +namespace atom::system { /** * @brief Get user groups. * @return User groups. @@ -60,6 +60,6 @@ namespace Atom::System { * @return Login shell. */ [[nodiscard]] std::string getLoginShell(); -} // namespace Atom::System +} // namespace atom::system #endif \ No newline at end of file diff --git a/src/atom/type/flat_multimap.hpp b/src/atom/type/flat_multimap.hpp new file mode 100644 index 00000000..583dfad9 --- /dev/null +++ b/src/atom/type/flat_multimap.hpp @@ -0,0 +1,303 @@ +/* + * flat_multimap.hpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2024-4-3 + +Description: Flat MultiMap + +**************************************************/ + +#ifndef ATOM_FLAT_MULTIMAP_HPP +#define ATOM_FLAT_MULTIMAP_HPP + +#include +#include +#include +#include +#include +#include + +template > +class flat_multimap { +public: + using key_type = Key; + using mapped_type = T; + using value_type = std::pair; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + using key_compare = Compare; + using reference = value_type&; + using const_reference = const value_type&; + using pointer = value_type*; + using const_pointer = const value_type*; + using iterator = typename std::vector::iterator; + using const_iterator = typename std::vector::const_iterator; + using reverse_iterator = typename std::vector::reverse_iterator; + using const_reverse_iterator = + typename std::vector::const_reverse_iterator; + + flat_multimap() = default; + + explicit flat_multimap(const Compare& comp) : compare_(comp) {} + + template + flat_multimap(InputIt first, InputIt last, const Compare& comp = Compare()) + : compare_(comp), data_(first, last) { + std::sort(data_.begin(), data_.end(), + [this](const auto& lhs, const auto& rhs) { + return compare_(lhs.first, rhs.first); + }); + } + + flat_multimap(std::initializer_list init, + const Compare& comp = Compare()) + : flat_multimap(init.begin(), init.end(), comp) {} + + flat_multimap(const flat_multimap&) = default; + flat_multimap(flat_multimap&&) noexcept = default; + + flat_multimap& operator=(const flat_multimap&) = default; + flat_multimap& operator=(flat_multimap&&) noexcept = default; + + [[nodiscard]] iterator begin() noexcept { return data_.begin(); } + [[nodiscard]] const_iterator begin() const noexcept { + return data_.begin(); + } + [[nodiscard]] const_iterator cbegin() const noexcept { + return data_.cbegin(); + } + + [[nodiscard]] iterator end() noexcept { return data_.end(); } + [[nodiscard]] const_iterator end() const noexcept { return data_.end(); } + [[nodiscard]] const_iterator cend() const noexcept { return data_.cend(); } + + [[nodiscard]] reverse_iterator rbegin() noexcept { return data_.rbegin(); } + [[nodiscard]] const_reverse_iterator rbegin() const noexcept { + return data_.rbegin(); + } + [[nodiscard]] const_reverse_iterator crbegin() const noexcept { + return data_.crbegin(); + } + + [[nodiscard]] reverse_iterator rend() noexcept { return data_.rend(); } + [[nodiscard]] const_reverse_iterator rend() const noexcept { + return data_.rend(); + } + [[nodiscard]] const_reverse_iterator crend() const noexcept { + return data_.crend(); + } + + [[nodiscard]] bool empty() const noexcept { return data_.empty(); } + [[nodiscard]] size_type size() const noexcept { return data_.size(); } + [[nodiscard]] size_type max_size() const noexcept { + return data_.max_size(); + } + + template + iterator emplace(Args&&... args) { + auto pos = std::lower_bound(data_.begin(), data_.end(), + std::forward(args)..., + [this](const auto& lhs, const auto& rhs) { + return compare_(lhs.first, rhs.first); + }); + return data_.emplace(pos, std::forward(args)...); + } + + iterator insert(const value_type& value) { return emplace(value); } + + iterator insert(value_type&& value) { return emplace(std::move(value)); } + + template + void insert(InputIt first, InputIt last) { + data_.insert(data_.end(), first, last); + std::sort(data_.begin(), data_.end(), + [this](const auto& lhs, const auto& rhs) { + return compare_(lhs.first, rhs.first); + }); + } + + void insert(std::initializer_list ilist) { + insert(ilist.begin(), ilist.end()); + } + + template + iterator try_emplace(const key_type& k, Args&&... args) { + auto pos = lower_bound(k); + if (pos != end() && !compare_(k, pos->first)) { + return pos; + } + return emplace(std::piecewise_construct, std::forward_as_tuple(k), + std::forward_as_tuple(std::forward(args)...)); + } + + template + iterator try_emplace(key_type&& k, Args&&... args) { + auto pos = lower_bound(k); + if (pos != end() && !compare_(k, pos->first)) { + return pos; + } + return emplace(std::piecewise_construct, + std::forward_as_tuple(std::move(k)), + std::forward_as_tuple(std::forward(args)...)); + } + + iterator erase(iterator pos) { return data_.erase(pos); } + + iterator erase(const_iterator pos) { return data_.erase(pos); } + + iterator erase(const_iterator first, const_iterator last) { + return data_.erase(first, last); + } + + size_type erase(const key_type& key) { + auto [first, last] = equal_range(key); + auto cnt = std::distance(first, last); + erase(first, last); + return cnt; + } + + void swap(flat_multimap& other) noexcept { + std::swap(data_, other.data_); + std::swap(compare_, other.compare_); + } + + void clear() noexcept { data_.clear(); } + + // TODO: Fix this + template + [[nodiscard]] iterator find(const K& key) { + auto pos = lower_bound(key); + if (pos != end() && !compare_(key, pos->first)) { + return pos; + } + return end(); + } + + template + [[nodiscard]] const_iterator find(const K& key) const { + auto pos = lower_bound(key); + if (pos != end() && !compare_(key, pos->first)) { + return pos; + } + return end(); + } + + template + [[nodiscard]] size_type count(const K& key) const { + auto [first, last] = equal_range(key); + return std::distance(first, last); + } + + template + [[nodiscard]] iterator lower_bound(const K& key) { + return std::lower_bound(begin(), end(), key, + [this](const auto& lhs, const auto& rhs) { + return compare_(lhs.first, rhs); + }); + } + + template + [[nodiscard]] const_iterator lower_bound(const K& key) const { + return std::lower_bound(begin(), end(), key, + [this](const auto& lhs, const auto& rhs) { + return compare_(lhs.first, rhs); + }); + } + + template + [[nodiscard]] iterator upper_bound(const K& key) { + return std::upper_bound(begin(), end(), key, + [this](const auto& lhs, const auto& rhs) { + return compare_(lhs, rhs.first); + }); + } + + template + [[nodiscard]] const_iterator upper_bound(const K& key) const { + return std::upper_bound(begin(), end(), key, + [this](const auto& lhs, const auto& rhs) { + return compare_(lhs, rhs.first); + }); + } + + template + [[nodiscard]] std::pair equal_range(const K& key) { + return std::equal_range(begin(), end(), key, + [this](const value_type& lhs, const K& rhs) { + return compare_(lhs.first, rhs); + }); + } + + template + [[nodiscard]] std::pair equal_range( + const K& key) const { + return std::equal_range(begin(), end(), key, + [this](const value_type& lhs, const K& rhs) { + return compare_(lhs.first, rhs); + }); + } + + [[nodiscard]] key_compare key_comp() const { return compare_; } + + [[nodiscard]] value_type* data() noexcept { return data_.data(); } + + [[nodiscard]] const value_type* data() const noexcept { + return data_.data(); + } + +private: + std::vector data_; + Compare compare_; +}; + +template +bool operator==(const flat_multimap& lhs, + const flat_multimap& rhs) { + return lhs.size() == rhs.size() && + std::equal(lhs.begin(), lhs.end(), rhs.begin()); +} + +template +bool operator!=(const flat_multimap& lhs, + const flat_multimap& rhs) { + return !(lhs == rhs); +} + +template +bool operator<(const flat_multimap& lhs, + const flat_multimap& rhs) { + return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), + rhs.end()); +} + +template +bool operator<=(const flat_multimap& lhs, + const flat_multimap& rhs) { + return !(rhs < lhs); +} + +template +bool operator>(const flat_multimap& lhs, + const flat_multimap& rhs) { + return rhs < lhs; +} + +template +bool operator>=(const flat_multimap& lhs, + const flat_multimap& rhs) { + return !(lhs < rhs); +} + +template +void swap( + flat_multimap& lhs, + flat_multimap& rhs) noexcept(noexcept(lhs.swap(rhs))) { + lhs.swap(rhs); +} + +#endif // ATOM_FLAT_MULTIMAP_HPP \ No newline at end of file diff --git a/src/atom/web/CMakeLists.txt b/src/atom/web/CMakeLists.txt index aef1b56c..c90e7b9e 100644 --- a/src/atom/web/CMakeLists.txt +++ b/src/atom/web/CMakeLists.txt @@ -15,6 +15,7 @@ set(${PROJECT_NAME}_SOURCES downloader.cpp httpclient.cpp httplite.cpp + httpparser.cpp utils.cpp time.cpp ) @@ -25,6 +26,7 @@ set(${PROJECT_NAME}_HEADERS downloader.hpp httpclient.hpp httplite.hpp + httpparser.hpp utils.hpp time.hpp ) diff --git a/src/atom/web/address.cpp b/src/atom/web/address.cpp index 8cf71a9b..88a3056a 100644 --- a/src/atom/web/address.cpp +++ b/src/atom/web/address.cpp @@ -19,7 +19,7 @@ Description: Address class for IPv4, IPv6, and Unix domain sockets. #include #endif -namespace Atom::Web { +namespace atom::web { Address::ptr Address::Create(const std::string &address, uint16_t port) { addrinfo hints, *result = nullptr; memset(&hints, 0, sizeof(addrinfo)); @@ -490,4 +490,4 @@ std::vector getIPv6Addresses() { return addresses; } #endif -} // namespace Atom::Web +} // namespace atom::web diff --git a/src/atom/web/address.hpp b/src/atom/web/address.hpp index 0df18d16..6620d1b2 100644 --- a/src/atom/web/address.hpp +++ b/src/atom/web/address.hpp @@ -32,7 +32,7 @@ Description: Address class for IPv4, IPv6, and Unix domain sockets. #include #include -namespace Atom::Web { +namespace atom::web { template static T CreateMask(uint32_t bits) { @@ -519,4 +519,4 @@ class IPv6Address : public IPAddress { * @return std::vector */ [[nodiscard]] std::vector getIPv6Addresses(); -} // namespace Atom::Web +} // namespace atom::web diff --git a/src/atom/web/curl.cpp b/src/atom/web/curl.cpp index 8994f7bd..aaea95f0 100644 --- a/src/atom/web/curl.cpp +++ b/src/atom/web/curl.cpp @@ -20,7 +20,7 @@ Description: Simple HTTP client using libcurl. #include "atom/log/loguru.hpp" -namespace Atom::Web { +namespace atom::web { CurlWrapper::CurlWrapper() { curl_global_init(CURL_GLOBAL_ALL); handle = curl_easy_init(); @@ -175,4 +175,4 @@ size_t CurlWrapper::writeCallback(void *contents, size_t size, size_t nmemb, str->append(static_cast(contents), realsize); return realsize; } -} // namespace Atom::Web +} // namespace atom::web diff --git a/src/atom/web/curl.hpp b/src/atom/web/curl.hpp index 78c95fe0..cb643139 100644 --- a/src/atom/web/curl.hpp +++ b/src/atom/web/curl.hpp @@ -23,7 +23,7 @@ Description: Simple HTTP client using libcurl. #include -namespace Atom::Web { +namespace atom::web { /** * @brief A wrapper class for performing HTTP requests using libcurl. * @@ -158,6 +158,6 @@ class CurlWrapper { void *userp); }; -} // namespace Atom::Web +} // namespace atom::web #endif diff --git a/src/atom/web/downloader.cpp b/src/atom/web/downloader.cpp index bb88b424..b0d89d09 100644 --- a/src/atom/web/downloader.cpp +++ b/src/atom/web/downloader.cpp @@ -22,7 +22,7 @@ Description: Downloader #include "atom/log/loguru.hpp" #include "cpp_httplib/httplib.h" -namespace Atom::Web { +namespace atom::web { DownloadManager::DownloadManager(const std::string &task_file) : task_file_(task_file) { try { @@ -250,4 +250,4 @@ void DownloadManager::save_task_list_to_file() { THROW_EXCEPTION("Error: ", e.what()); } } -} // namespace Atom::Web +} // namespace atom::web diff --git a/src/atom/web/downloader.hpp b/src/atom/web/downloader.hpp index 7eb1e2f2..054d35ae 100644 --- a/src/atom/web/downloader.hpp +++ b/src/atom/web/downloader.hpp @@ -24,7 +24,7 @@ Description: Downloader #include #include -namespace Atom::Web { +namespace atom::web { struct DownloadTask { std::string url; @@ -138,7 +138,7 @@ class DownloadManager { std::atomic running_{false}; ///< 是否正在下载中 std::chrono::system_clock::time_point start_time_; }; -} // namespace Atom::Web +} // namespace atom::web /* #include diff --git a/src/atom/web/httpclient.cpp b/src/atom/web/httpclient.cpp index 005713fe..f3fb9e67 100644 --- a/src/atom/web/httpclient.cpp +++ b/src/atom/web/httpclient.cpp @@ -24,7 +24,7 @@ Description: Http Client using namespace httplib; -namespace Atom::Web { +namespace atom::web { class HttpClient::HttpClientImpl { public: explicit HttpClientImpl(const std::string &host, int port, @@ -210,4 +210,4 @@ bool HttpClient::scanPort(int start_port, int end_port, bool HttpClient::checkServerStatus(std::string &status) { return m_impl->checkServerStatus(status); } -} // namespace Atom::Web +} // namespace atom::web diff --git a/src/atom/web/httpclient.hpp b/src/atom/web/httpclient.hpp index beb32357..8778f878 100644 --- a/src/atom/web/httpclient.hpp +++ b/src/atom/web/httpclient.hpp @@ -25,7 +25,7 @@ using json = nlohmann::json; #define CPPHTTPLIB_OPENSSL_SUPPORT -namespace Atom::Web { +namespace atom::web { /** * @brief Class for making HTTP requests using HttpClientImpl. */ @@ -141,6 +141,6 @@ class HttpClient { std::unique_ptr m_impl; }; -} // namespace Atom::Web +} // namespace atom::web #endif diff --git a/src/atom/web/httplite.cpp b/src/atom/web/httplite.cpp index 20cf61c6..28cf4d65 100644 --- a/src/atom/web/httplite.cpp +++ b/src/atom/web/httplite.cpp @@ -19,7 +19,7 @@ Description: Simple Http Client #include "atom/log/loguru.hpp" -namespace Atom::Web { +namespace atom::web { HttpClient::HttpClient() : socketfd(0) {} @@ -231,4 +231,4 @@ std::string HttpRequestBuilder::buildRequestString(const std::string &host, return request; } -} // namespace Atom::Web +} // namespace atom::web diff --git a/src/atom/web/httplite.hpp b/src/atom/web/httplite.hpp index cad3eb8a..4c9c4c12 100644 --- a/src/atom/web/httplite.hpp +++ b/src/atom/web/httplite.hpp @@ -34,7 +34,7 @@ Description: Simple Http Client #define SOCKET int #endif -namespace Atom::Web { +namespace atom::web { enum class HttpMethod { GET, POST, PUT, DELETE }; @@ -170,6 +170,6 @@ class HttpRequestBuilder { std::chrono::seconds timeout; /**< 超时时间 */ std::map headers; /**< 请求头映射 */ }; -} // namespace Atom::Web +} // namespace atom::web #endif \ No newline at end of file diff --git a/src/atom/web/httpparser.cpp b/src/atom/web/httpparser.cpp index c218dd65..f6d68867 100644 --- a/src/atom/web/httpparser.cpp +++ b/src/atom/web/httpparser.cpp @@ -17,14 +17,13 @@ Description: Http Header Parser #include #include +namespace atom::web { class HttpHeaderParserImpl { public: std::map> headers_; }; -HttpHeaderParser::HttpHeaderParser() : m_pImpl(new HttpHeaderParserImpl()) {} - -HttpHeaderParser::~HttpHeaderParser() { delete m_pImpl; } +HttpHeaderParser::HttpHeaderParser() : m_pImpl(std::make_unique()) {} void HttpHeaderParser::parseHeaders(const std::string &rawHeaders) { m_pImpl->headers_.clear(); @@ -89,3 +88,5 @@ bool HttpHeaderParser::hasHeader(const std::string &key) const { } void HttpHeaderParser::clearHeaders() { m_pImpl->headers_.clear(); } + +} // namespace atom::web diff --git a/src/atom/web/httpparser.hpp b/src/atom/web/httpparser.hpp index 4b970271..26e00807 100644 --- a/src/atom/web/httpparser.hpp +++ b/src/atom/web/httpparser.hpp @@ -21,7 +21,7 @@ Description: Http Header Parser #include -namespace Atom::Web { +namespace atom::web { class HttpHeaderParserImpl; /** @@ -35,11 +35,6 @@ class HttpHeaderParser { */ HttpHeaderParser(); - /** - * @brief Destroys the HttpHeaderParser object. - */ - ~HttpHeaderParser(); - /** * @brief Parses the raw HTTP headers and stores them internally. * @param rawHeaders The raw HTTP headers as a string. @@ -99,6 +94,6 @@ class HttpHeaderParser { private: std::unique_ptr m_pImpl; // Pointer to implementation }; -} // namespace Atom::Web +} // namespace atom::web #endif // ATOM_WEB_HTTP_PARSER_HPP \ No newline at end of file diff --git a/src/atom/web/time.cpp b/src/atom/web/time.cpp index 9c47319e..7a1cf591 100644 --- a/src/atom/web/time.cpp +++ b/src/atom/web/time.cpp @@ -44,7 +44,7 @@ Description: Time #include "atom/log/loguru.hpp" -namespace Atom::Web { +namespace atom::web { std::time_t getSystemTime() { return std::chrono::system_clock::to_time_t( std::chrono::system_clock::now()); @@ -197,7 +197,7 @@ bool syncTimeFromRTC() { FILETIME ft; ft.dwLowDateTime = (DWORD)new_timestamp; ft.dwHighDateTime = (DWORD)(new_timestamp >> 32); - if (!System::isRoot()) { + if (!system::isRoot()) { LOG_F(ERROR, "Permission denied. Need root privilege to set system time."); return false; @@ -414,4 +414,4 @@ time_t getNtpTime(const char *hostname) { return (time_t)timestamp; } -} // namespace Atom::Web +} // namespace atom::web diff --git a/src/atom/web/time.hpp b/src/atom/web/time.hpp index 33452978..6041cb39 100644 --- a/src/atom/web/time.hpp +++ b/src/atom/web/time.hpp @@ -8,7 +8,7 @@ Date: 2023-3-31 -Description: Time related functions. Not same as Atom::System::Time class. +Description: Time related functions. Not same as atom::system::Time class. **************************************************/ @@ -18,7 +18,7 @@ Description: Time related functions. Not same as Atom::System::Time class. #include #include -namespace Atom::Web { +namespace atom::web { /** * @brief Gets the current system time in seconds since January 1, 1970 (Unix @@ -65,6 +65,6 @@ bool setSystemTimezone(const std::string &timezone); */ bool syncTimeFromRTC(); -} // namespace Atom::Web +} // namespace atom::web #endif // TIME_HPP diff --git a/src/atom/web/utils.cpp b/src/atom/web/utils.cpp index a18c9309..4ac8b4ba 100644 --- a/src/atom/web/utils.cpp +++ b/src/atom/web/utils.cpp @@ -53,7 +53,7 @@ Description: Network Utils #include "atom/log/loguru.hpp" #include "atom/system/command.hpp" -namespace Atom::Web { +namespace atom::web { bool isConnectedToInternet() { bool connected = false; int sock = socket(AF_INET, SOCK_STREAM, 0); @@ -199,7 +199,7 @@ bool checkAndKillProgramOnPort(int port) { #endif std::string pid_str = - System::executeCommand(cmd, false, [](const std::string &line) { + system::executeCommand(cmd, false, [](const std::string &line) { return line.find("LISTENING") != std::string::npos; }); if (pid_str.empty()) { @@ -225,7 +225,7 @@ bool checkAndKillProgramOnPort(int port) { pid_str); #endif - if (!System::executeCommand( + if (!system::executeCommand( kill_cmd, false, [pid_str](const std::string &line) { return line.find(pid_str) != std::string::npos; @@ -267,4 +267,4 @@ bool isIPv6Format(const std::string &str) { std::regex ipv6Regex("^(([0-9A-Fa-f]{1,4}):){7}([0-9A-Fa-f]{1,4})$"); return std::regex_match(str, ipv6Regex); } -} // namespace Atom::Web +} // namespace atom::web diff --git a/src/atom/web/utils.hpp b/src/atom/web/utils.hpp index aca44a25..6ff12410 100644 --- a/src/atom/web/utils.hpp +++ b/src/atom/web/utils.hpp @@ -18,7 +18,7 @@ Description: Network Utils #include #include -namespace Atom::Web { +namespace atom::web { /** * @brief Check whether the device is connected to the internet. * 检查设备是否连接到互联网 @@ -71,6 +71,6 @@ bool checkAndKillProgramOnPort(int port); * 如果字符串为IPv4格式,则返回true;否则返回false。 */ [[nodiscard]] bool isIPv4Format(const std::string &str); -} // namespace Atom::Web +} // namespace atom::web #endif diff --git a/src/debug/terminal.cpp b/src/debug/terminal.cpp index 92a2aeeb..56fb4eaa 100644 --- a/src/debug/terminal.cpp +++ b/src/debug/terminal.cpp @@ -14,11 +14,6 @@ Description: Terminal #include "terminal.hpp" -#include -#include - -namespace fs = std::filesystem; - namespace lithium::Terminal { ConsoleTerminal::ConsoleTerminal() { @@ -27,44 +22,49 @@ ConsoleTerminal::ConsoleTerminal() { #else tcgetattr(STDIN_FILENO, &orig_termios); #endif - registerMemberCommand("help", this, helpCommand); - registerMemberCommand("pwd", this, pwdCommand); - registerMemberCommand("help", this, helpCommand); - registerMemberCommand("echo", this, echoCommand); - registerMemberCommand("create", this, createFile); - registerMemberCommand("delete", this, deleteFile); + registerMemberCommand("help", this, &ConsoleTerminal::helpCommand); + registerMemberCommand("pwd", this, &ConsoleTerminal::pwdCommand); + registerMemberCommand("echo", this, &ConsoleTerminal::echoCommand); + registerMemberCommand("create", this, &ConsoleTerminal::createFile); + registerMemberCommand("delete", this, &ConsoleTerminal::deleteFile); + registerMemberCommand("cd", this, &ConsoleTerminal::cdCommand); + registerMemberCommand("ls", this, &ConsoleTerminal::listDirectory); + registerMemberCommand("mkdir", this, &ConsoleTerminal::createDirectory); + registerMemberCommand("rmdir", this, &ConsoleTerminal::deleteDirectory); + registerMemberCommand("mv", this, &ConsoleTerminal::moveFile); + registerMemberCommand("cp", this, &ConsoleTerminal::copyFile); + registerMemberCommand("date", this, &ConsoleTerminal::showDateTime); + registerMemberCommand("setdate", this, &ConsoleTerminal::setDateTime); } ConsoleTerminal::~ConsoleTerminal() { -#ifdef _WIN32 - // Windows-specific cleanup can be added here if needed -#else +#ifndef _WIN32 tcsetattr(STDIN_FILENO, TCSANOW, &orig_termios); #endif } -void ConsoleTerminal::registerCommand(const std::string& name, +void ConsoleTerminal::registerCommand(std::string_view name, CommandFunction func) { commandMap.emplace(name, std::move(func)); } std::vector ConsoleTerminal::getRegisteredCommands() const { std::vector commands; + commands.reserve(commandMap.size()); for (const auto& [name, _] : commandMap) { - commands.push_back(name); + commands.emplace_back(name); } return commands; } -void ConsoleTerminal::callCommand(const std::string& name, +void ConsoleTerminal::callCommand(std::string_view name, const std::vector& args) { - if (auto it = commandMap.find(name); it != commandMap.end()) { + if (auto it = commandMap.find(name.data()); it != commandMap.end()) { try { it->second(args); } catch (const std::exception& e) { std::cout << "Error: " << e.what() << '\n'; } - } else { std::cout << "Command '" << name << "' not found.\n"; } @@ -73,7 +73,6 @@ void ConsoleTerminal::callCommand(const std::string& name, void ConsoleTerminal::run() { std::string input; std::deque history; - int historyIndex = 0; printHeader(); @@ -85,7 +84,6 @@ void ConsoleTerminal::run() { if (history.size() > MAX_HISTORY_SIZE) { history.pop_back(); } - historyIndex = 0; std::istringstream iss(input); std::string command; @@ -106,11 +104,9 @@ void ConsoleTerminal::run() { void ConsoleTerminal::helpCommand(const std::vector& args) { std::cout << "Available commands:\n"; - std::cout << " print [args...] - Print arguments to console\n"; - std::cout << " ls [dir] - List files in directory\n"; - std::cout << " rm - Delete file\n"; - std::cout << " help - Show available commands\n"; - std::cout << " exit - Exit the terminal\n"; + for (const auto& cmd : getRegisteredCommands()) { + std::cout << " " << cmd << "\n"; + } } void ConsoleTerminal::echoCommand(const std::vector& args) { @@ -163,6 +159,65 @@ void ConsoleTerminal::deleteFile(const std::vector& args) { std::cout << "File deleted: " << args[0] << '\n'; } +void ConsoleTerminal::createDirectory(const std::vector& args) { + if (args.empty()) { + std::cout << "No directory name provided.\n"; + return; + } + fs::create_directory(args[0]); + std::cout << "Directory created: " << args[0] << '\n'; +} + +void ConsoleTerminal::deleteDirectory(const std::vector& args) { + if (args.empty()) { + std::cout << "No directory name provided.\n"; + return; + } + fs::remove_all(args[0]); + std::cout << "Directory deleted: " << args[0] << '\n'; +} + +void ConsoleTerminal::moveFile(const std::vector& args) { + if (args.size() < 2) { + std::cout << "Usage: mv \n"; + return; + } + fs::rename(args[0], args[1]); + std::cout << "File moved: " << args[0] << " -> " << args[1] << '\n'; +} + +void ConsoleTerminal::copyFile(const std::vector& args) { + if (args.size() < 2) { + std::cout << "Usage: cp \n"; + return; + } + fs::copy(args[0], args[1]); + std::cout << "File copied: " << args[0] << " -> " << args[1] << '\n'; +} + +void ConsoleTerminal::showDateTime(const std::vector& args) { + auto now = std::chrono::system_clock::now(); + auto time = std::chrono::system_clock::to_time_t(now); + std::cout << "Current date and time: " + << std::put_time(std::localtime(&time), "%Y-%m-%d %H:%M:%S") + << '\n'; +} + +void ConsoleTerminal::setDateTime(const std::vector& args) { + if (args.size() < 2) { + std::cout << "Usage: setdate \n"; + return; + } + std::tm tm = {}; + std::istringstream ss(args[0] + " " + args[1]); + ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S"); + auto time = std::mktime(&tm); + std::chrono::system_clock::time_point tp = + std::chrono::system_clock::from_time_t(time); + std::chrono::system_clock::now() = tp; + std::cout << "Date and time set to: " << args[0] << " " << args[1] << '\n'; +} + void ConsoleTerminal::printHeader() { std::cout << "Welcome to Lithium Command Line Tool v1.0" << std::endl; std::cout << "A debugging tool for Lithium Engine" << std::endl; diff --git a/src/debug/terminal.hpp b/src/debug/terminal.hpp index d4db5457..d3f3ced4 100644 --- a/src/debug/terminal.hpp +++ b/src/debug/terminal.hpp @@ -10,6 +10,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #ifdef _WIN32 #include @@ -19,65 +25,58 @@ #endif namespace lithium::Terminal { +namespace fs = std::filesystem; + class ConsoleTerminal { public: - using CommandFunction = - std::function&)>; + using CommandFunction = std::function&)>; ConsoleTerminal(); - ~ConsoleTerminal(); - void registerCommand(const std::string& name, CommandFunction func); + void registerCommand(std::string_view name, CommandFunction func); template - void registerMemberCommand( - const std::string& name, Class* instance, - void (Class::*memFunc)(const std::vector&)) { - CommandFunction func = [instance, - memFunc](const std::vector& args) { + void registerMemberCommand(std::string_view name, Class* instance, void (Class::*memFunc)(const std::vector&)) { + registerCommand(name, [instance, memFunc](const std::vector& args) { (instance->*memFunc)(args); - }; - registerCommand(name, func); + }); } - std::vector getRegisteredCommands() const; - - void callCommand(const std::string& name, - const std::vector& args); - + [[nodiscard]] std::vector getRegisteredCommands() const; + void callCommand(std::string_view name, const std::vector& args); void run(); protected: void helpCommand(const std::vector& args); - void echoCommand(const std::vector& args); - void pwdCommand(const std::vector& args); - void cdCommand(const std::vector& args); - void listDirectory(const std::vector& args); - void createFile(const std::vector& args); - void deleteFile(const std::vector& args); + void createDirectory(const std::vector& args); + void deleteDirectory(const std::vector& args); + void moveFile(const std::vector& args); + void copyFile(const std::vector& args); + void showDateTime(const std::vector& args); + void setDateTime(const std::vector& args); private: void printHeader(); + void clearConsole(); -private: std::unordered_map commandMap; - static const int MAX_HISTORY_SIZE = 100; + static constexpr int MAX_HISTORY_SIZE = 100; #ifdef _WIN32 HANDLE hConsole; #else struct termios orig_termios; #endif - - void clearConsole(); }; -} // namespace lithium::Terminal -#endif +} // namespace lithium::Terminal + +#endif // LITHIUM_DEBUG_TERMINAL_HPP + diff --git a/src/device/server/hydrogen.cpp b/src/device/server/hydrogen.cpp index 5d293d59..0112f147 100644 --- a/src/device/server/hydrogen.cpp +++ b/src/device/server/hydrogen.cpp @@ -187,29 +187,29 @@ bool HydrogenManager::isRunning() { #if ENABLE_INDI #ifdef _WIN32 std::string processName = "indiserver.exe"; - return Atom::System::isProcessRunning(processName); + return atom::system::isProcessRunning(processName); #else std::string processName = "indiserver"; - return Atom::System::isProcessRunning(processName); + return atom::system::isProcessRunning(processName); #endif #else #ifdef _WIN32 std::string processName = "hydrogenserver.exe"; - return Atom::System::isProcessRunning(processName); + return atom::system::isProcessRunning(processName); #else std::string processName = "hydrogenserver"; - return Atom::System::isProcessRunning(processName); + return atom::system::isProcessRunning(processName); #endif #endif } bool HydrogenManager::isInstalled() { #ifdef _WIN32 - if (!Atom::System::checkSoftwareInstalled("hydrogenserver.exe")) { + if (!atom::system::checkSoftwareInstalled("hydrogenserver.exe")) { return false; } #else - if (!Atom::System::checkSoftwareInstalled("hydrogenserver")) { + if (!atom::system::checkSoftwareInstalled("hydrogenserver")) { return false; } #endif diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt new file mode 100644 index 00000000..5f694d86 --- /dev/null +++ b/src/modules/CMakeLists.txt @@ -0,0 +1,12 @@ +# CMakeLists.txt for Lithium Builtin Modules +# This project is licensed under the terms of the GPL3 license. +# +# Project Name: Lithium Builtin Modules +# Description: A collection of useful system functions +# Author: Max Qian +# License: GPL3 + +cmake_minimum_required(VERSION 3.20) +project(lithium.builtin C CXX) + +add_subdirectory(atom.system) diff --git a/src/modules/atom.system/CMakeLists.txt b/src/modules/atom.system/CMakeLists.txt new file mode 100644 index 00000000..93b627f4 --- /dev/null +++ b/src/modules/atom.system/CMakeLists.txt @@ -0,0 +1,73 @@ +# CMakeLists.txt for Atom-System-Builtin +# This project is licensed under the terms of the GPL3 license. +# +# Project Name: Atom-System-Builtin +# Description: A builtin module for Atom-System +# Author: Max Qian +# License: GPL3 + +cmake_minimum_required(VERSION 3.20) +project(atom.system C CXX) + +set(CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_MAJOR 1) +set(CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_MINOR 0) +set(CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_RELEASE 0) + +set(ATOM_SYSTEM_BUILTIN_SOVERSION ${CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_MAJOR}) +set(CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_STRING "${CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_MAJOR}.${CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_MINOR}.${CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_RELEASE}") +set(ATOM_SYSTEM_BUILTIN_VERSION ${CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_MAJOR}.${CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_MINOR}.${CMAKE_ATOM_SYSTEM_BUILTIN_VERSION_RELEASE}) + +# Sources +set(${PROJECT_NAME}_SOURCES + _main.cpp + _component.cpp +) + +# Headers +set(${PROJECT_NAME}_HEADERS +) + +# Private Headers +set(${PROJECT_NAME}_PRIVATE_HEADERS + _component.hpp +) + +set(${PROJECT_NAME}_LIBS + loguru + atom-component + atom-system + ${CMAKE_THREAD_LIBS_INIT} +) + +if(WIN32) +list(APPEND ${PROJECT_NAME}_LIBS pdh wlanapi ws2_32 userenv setupapi iphlpapi) +endif() + +# Build Object Library +add_library(${PROJECT_NAME}_OBJECT OBJECT) +set_property(TARGET ${PROJECT_NAME}_OBJECT PROPERTY POSITION_INDEPENDENT_CODE 1) + +target_sources(${PROJECT_NAME}_OBJECT + PUBLIC + ${${PROJECT_NAME}_HEADERS} + PRIVATE + ${${PROJECT_NAME}_SOURCES} + ${${PROJECT_NAME}_PRIVATE_HEADERS} +) + +target_link_libraries(${PROJECT_NAME}_OBJECT ${${PROJECT_NAME}_LIBS}) + +add_library(${PROJECT_NAME} SHARED) + +target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}_OBJECT ${${PROJECT_NAME}_LIBS}) +target_include_directories(${PROJECT_NAME} PUBLIC .) + +set_target_properties(${PROJECT_NAME} PROPERTIES + VERSION ${CMAKE_HYDROGEN_VERSION_STRING} + SOVERSION ${HYDROGEN_SOVERSION} + OUTPUT_NAME system +) + +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) \ No newline at end of file diff --git a/src/modules/atom.system/_component.cpp b/src/modules/atom.system/_component.cpp new file mode 100644 index 00000000..d21ec154 --- /dev/null +++ b/src/modules/atom.system/_component.cpp @@ -0,0 +1,215 @@ +/* + * _component.cpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2024-4-13 + +Description: Component of Atom-System + +**************************************************/ + +#include "_component.hpp" + +#include "atom/log/loguru.hpp" + +#include "module/battery.hpp" +#include "module/cpu.hpp" +#include "module/disk.hpp" +#include "module/gpu.hpp" +#include "module/memory.hpp" +#include "module/os.hpp" +#include "module/wifi.hpp" + +#include "command.hpp" +#include "crash.hpp" +#include "os.hpp" +#include "pidwatcher.hpp" +#include "platform.hpp" +#include "register.hpp" +#include "user.hpp" + +#include "_constant.hpp" + +using namespace atom::system; + +SystemComponent::SystemComponent(const std::string &name) : Component(name) { + DLOG_F(INFO, "SystemComponent::SystemComponent"); + registerCommand("cpu_usage", &getCurrentCpuUsage, "cpu", + "Get current CPU usage percentage"); + registerCommand("cpu_temperature", &getCurrentCpuTemperature, "cpu", + "Get current CPU temperature"); + registerCommand("memory_usage", &getMemoryUsage, "memory", + "Get current memory usage percentage"); + registerCommand("is_charging", &isBatteryCharging, PointerSentinel(this), + "battery", "Check if the battery is charging"); + registerCommand("battery_level", &getCurrentBatteryLevel, + PointerSentinel(this), "battery", + "Get current battery level"); + registerCommand("disk_usage", &getDiskUsage, "disk", + "Get current disk usage percentage"); + registerCommand("is_hotspot_connected", &isHotspotConnected, "wifi", + "Check if the hotspot is connected"); + registerCommand("wired_network", &getCurrentWiredNetwork, "wifi", + "Get current wired network"); + registerCommand("wifi_name", &getCurrentWifi, "wifi", + "Get current wifi name"); + registerCommand("current_ip", &getHostIPs, "network", + "Get current IP address"); + registerCommand("gpu_info", &getGPUInfo, "gpu", "Get GPU info"); + registerCommand("os_name", &getOSName, PointerSentinel(this), "os", + "Get OS name"); + registerCommand("os_version", &getOSVersion, PointerSentinel(this), "os", + "Get OS version"); + registerCommand("run_commands", &executeCommands, "os", + "Run a list of system commands"); + registerCommand("run_command_env", &executeCommandWithEnv, "os", + "Run a system command with environment variables"); + registerCommand("run_command_status", &executeCommandWithStatus, "os", + "Run a system command and get its status"); + registerCommand("kill_process", &killProcess, "os", + "Kill a process by its PID"); + + registerCommand("walk", &walk, "os", "Walk a directory"); + registerCommand("fwalk", &fwalk, "os", "Walk a directory"); + registerCommand("uname", &uname, "os", "Get uname information"); + registerCommand("ctermid", &ctermid, "os", "Get current terminal ID"); + registerCommand("jwalk", &jwalk, "os", "Walk a directory"); + registerCommand("getpriority", &getpriority, "os", + "Get current process priority"); + registerCommand("getlogin", &getlogin, "os", "Get current user name"); + registerCommand("Environ", &Environ, "os", "Get environment variables"); + + registerCommand("user_group", &getUserGroups, "user", + "Get current user groups"); + registerCommand("user_id", &getUserId, "user", "Get current user ID"); + registerCommand("user_host", &getHostname, "user", + "Get current user hostname"); + registerCommand("user_name", &getUsername, "user", "Get current user name"); + registerCommand("user_home", &getHomeDirectory, "user", + "Get current user home directory"); + + registerCommand("user_shell", &getLoginShell, "user", + "Get current user login shell"); + + registerCommand("user_groups", &getUserGroups, "user", + "Get current user groups"); + + addVariable("platform", platform, "Platform", "os_name", "os"); + addVariable("architecture", architecture, "Architecture", "os_arch", "os"); + addVariable("os_version", os_version, "OS Version", "kernel_version", "os"); + addVariable("compiler", compiler, "Compiler", "builder", "os"); + + registerCommand("make_pidwatcher", &makePidWatcher, PointerSentinel(this), + "os", "Make a PID watcher"); + registerCommand("start_watcher", &startPidWatcher, PointerSentinel(this), + "os", "Start a PID watcher"); + registerCommand("stop_watcher", &stopPidWatcher, PointerSentinel(this), + "os", "Stop a PID watcher"); + registerCommand("switch_watcher", &switchPidWatcher, PointerSentinel(this), + "os", "Switch a PID watcher"); + registerCommand("set_watcher_exit", &setPidWatcherExitCallback, + PointerSentinel(this), "os", + "Set a PID watcher exit callback"); + registerCommand("set_watcher_monitor", &setPidWatcherMonitorFunction, + PointerSentinel(this), "os", + "Set a PID watcher monitor callback"); + +#if ENABLE_REGISTRY_SUPPORT + registerCommand("get_registry_subkeys", &getRegistrySubKeys, "os", + "Get registry subkeys"); + registerCommand("get_registry_values", &getRegistryValues, "os", + "Get registry values"); + registerCommand("delete_registry_subkey", &deleteRegistrySubKey, "os", + "Delete registry subkey"); + registerCommand("modify_registry_value", &modifyRegistryValue, "os", + "Modify registry value"); + registerCommand("recursively_enumerate_registry_subkeys", + &recursivelyEnumerateRegistrySubKeys, "os", + "Recursively enumerate registry subkeys"); + registerCommand("find_registry_key", &findRegistryKey, "os", + "Find registry key"); + registerCommand("find_registry_value", &findRegistryValue, "os", + "Find registry value"); + registerCommand("backup_registry", &backupRegistry, "os", + "Backup registry"); + registerCommand("export_registry", &exportRegistry, "os", + "Export registry"); + registerCommand("delete_registry_value", &deleteRegistryValue, "os", + "Delete registry value"); +#endif + + registerCommand("save_crashreport", &saveCrashLog, "os", + "Save crash report"); +} + +SystemComponent::~SystemComponent() { + DLOG_F(INFO, "SystemComponent::~SystemComponent"); +} + +bool SystemComponent::initialize() { return true; } + +bool SystemComponent::destroy() { return true; } + +double SystemComponent::getCurrentBatteryLevel() { + return atom::system::getBatteryInfo().currentNow; +} + +bool SystemComponent::isBatteryCharging() { + return atom::system::getBatteryInfo().isCharging; +} + +std::string SystemComponent::getOSName() { + return atom::system::getOperatingSystemInfo().osName; +} + +std::string SystemComponent::getOSVersion() { + return atom::system::getOperatingSystemInfo().osVersion; +} + +std::string SystemComponent::getKernelVersion() { + return atom::system::getOperatingSystemInfo().kernelVersion; +} + +std::string SystemComponent::getArchitecture() { + return atom::system::getOperatingSystemInfo().architecture; +} + +void SystemComponent::makePidWatcher(const std::string &name) { + if (m_pidWatchers.find(name) != m_pidWatchers.end()) { + return; + } + m_pidWatchers[name] = std::make_shared(); +} + +bool SystemComponent::startPidWatcher(const std::string &name, + const std::string &pid) { + return m_pidWatchers[name]->Start(pid); +} + +void SystemComponent::stopPidWatcher(const std::string &name) { + m_pidWatchers[name]->Stop(); +} + +bool SystemComponent::switchPidWatcher(const std::string &name, + const std::string &pid) { + return m_pidWatchers[name]->Switch(pid); +} +void SystemComponent::setPidWatcherExitCallback( + const std::string &name, const std::function &callback) { + m_pidWatchers[name]->SetExitCallback(callback); +} + +void SystemComponent::setPidWatcherMonitorFunction( + const std::string &name, const std::function &callback, + std::chrono::milliseconds interval) { + m_pidWatchers[name]->SetMonitorFunction(callback, interval); +} + +void SystemComponent::getPidByName(const std::string &name, + const std::string &pid) { + m_pidWatchers[name]->GetPidByName(pid); +} \ No newline at end of file diff --git a/src/modules/atom.system/_component.hpp b/src/modules/atom.system/_component.hpp new file mode 100644 index 00000000..cddf5d50 --- /dev/null +++ b/src/modules/atom.system/_component.hpp @@ -0,0 +1,68 @@ +/* + * _component.hpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2024-4-13 + +Description: Component of Atom-System + +**************************************************/ + +#ifndef ATOM_SYSTEM_COMPONENT_HPP +#define ATOM_SYSTEM_COMPONENT_HPP + +#include "atom/components/component.hpp" + +#include +#include + +namespace atom::system { +class PidWatcher; +} + +class SystemComponent : public Component { +public: + explicit SystemComponent(const std::string &name); + ~SystemComponent(); + + // ------------------------------------------------------------------- + // Common methods + // ------------------------------------------------------------------- + + bool initialize() override; + bool destroy() override; + +protected: + // ------------------------------------------------------------------- + // Protected methods + // ------------------------------------------------------------------- + + double getCurrentBatteryLevel(); + bool isBatteryCharging(); + + std::string getOSName(); + std::string getOSVersion(); + std::string getKernelVersion(); + std::string getArchitecture(); + + void makePidWatcher(const std::string &name); + bool startPidWatcher(const std::string &name, const std::string &pid); + void stopPidWatcher(const std::string &name); + bool switchPidWatcher(const std::string &name, const std::string &pid); + void setPidWatcherExitCallback(const std::string &name, + const std::function &callback); + void setPidWatcherMonitorFunction(const std::string &name, + const std::function &callback, + std::chrono::milliseconds interval); + void getPidByName(const std::string &name, const std::string &pid); + +private: + std::unordered_map> + m_pidWatchers; +}; + +#endif diff --git a/src/modules/atom.system/_main.cpp b/src/modules/atom.system/_main.cpp new file mode 100644 index 00000000..a64e180d --- /dev/null +++ b/src/modules/atom.system/_main.cpp @@ -0,0 +1,29 @@ +/* + * _main.cpp + * + * Copyright (C) 2023-2024 Max Qian + */ + +/************************************************* + +Date: 2024-4-13 + +Description: Main Entry + +**************************************************/ + +#include "_component.hpp" + +#include "atom/type/json.hpp" +using json = nlohmann::json; + +extern "C" { + +std::shared_ptr getInstance([[maybe_unused]] const json ¶ms) { + if (params.contains("name") && params["name"].is_string()) { + return std::make_shared( + params["name"].get()); + } + return std::make_shared("atom.system"); +} +} \ No newline at end of file diff --git a/src/modules/atom.system/package.json b/src/modules/atom.system/package.json new file mode 100644 index 00000000..d72ff58c --- /dev/null +++ b/src/modules/atom.system/package.json @@ -0,0 +1,34 @@ +{ + "name": "atom.system", + "version": "1.0.0", + "type": "shared", + "description": "Atom system functions without any dependencies", + "license": "GPL-3.0-or-later", + "author": "Max Qian", + "repository": { + "type": "git", + "url": "https://github.com/ElementAstro/Lithium" + }, + "bugs": { + "type": "git", + "url": "https://github.com/ElementAstro/Lithium/issues" + }, + "homepage": { + "type": "git", + "url": "https://github.com/ElementAstro/Lithium" + }, + "keywords": [ + "lithium", + "config" + ], + "scripts": { + "build": "cmake --build-type=Release -- -j 4", + "lint": "clang-format -i src/*.cpp src/*.h" + }, + "modules": [ + { + "name": "system", + "entry": "getInstance" + } + ] +} \ No newline at end of file diff --git a/src/preload.cpp b/src/preload.cpp index 1427d295..4ca89f97 100644 --- a/src/preload.cpp +++ b/src/preload.cpp @@ -52,7 +52,7 @@ void downloadResources() { // 添加下载任务到线程池 tasks.emplace_back(pool.enqueue([url] { try { - auto client = Atom::Web::HttpClient( + auto client = atom::web::HttpClient( resource::LITHIUM_RESOURCE_SERVER, 443, true); json res_body; std::string err; diff --git a/src/script/custom/os.cpp b/src/script/custom/os.cpp index f869b1d8..b7901d49 100644 --- a/src/script/custom/os.cpp +++ b/src/script/custom/os.cpp @@ -38,7 +38,7 @@ void addOSModule(VM* vm) { LOG_F(ERROR, "Folder is not existing: {}", sv); return vm->None; } - auto result = Atom::System::jwalk(std::string(sv)); + auto result = atom::system::jwalk(std::string(sv)); if (result.empty()) { return vm->None; } diff --git a/src/script/custom/sys.cpp b/src/script/custom/sys.cpp index 7b5a37f3..6dd7ae5b 100644 --- a/src/script/custom/sys.cpp +++ b/src/script/custom/sys.cpp @@ -32,14 +32,14 @@ struct Wrapped_Process { PY_CLASS(Wrapped_Process, mod, Process) - Atom::System::ProcessInfo value; + atom::system::ProcessInfo value; - Atom::System::ProcessInfo *_() { return &value; } + atom::system::ProcessInfo *_() { return &value; } Wrapped_Process() = default; Wrapped_Process(const Wrapped_Process &) = default; - Wrapped_Process(Atom::System::ProcessInfo value) + Wrapped_Process(atom::system::ProcessInfo value) : value(value) { } @@ -80,7 +80,7 @@ void addSysModule(VM *vm) { "get CPU usage, and return a float value", [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get CPU usage"); - float cpu_usage = Atom::System::getCurrentCpuUsage(); + float cpu_usage = atom::system::getCurrentCpuUsage(); if (cpu_usage < 0.0f) { LOG_F(ERROR, "Failed to get cpu usage: {}", cpu_usage); } @@ -93,7 +93,7 @@ void addSysModule(VM *vm) { [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get CPU temperature"); float cpu_temperature = - Atom::System::getCurrentCpuTemperature(); + atom::system::getCurrentCpuTemperature(); if (cpu_temperature < 0.0f) { LOG_F(ERROR, "Failed to get cpu temperature: {}", cpu_temperature); @@ -105,11 +105,11 @@ void addSysModule(VM *vm) { vm->bind(mod, "get_cpu_info() -> dict", "get CPU infomation in dict format", [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get CPU infomation"); - auto cpu_model = Atom::System::getCPUModel(); - auto cpu_freq = Atom::System::getProcessorFrequency(); - auto cpu_id = Atom::System::getProcessorIdentifier(); - auto cpu_package = Atom::System::getNumberOfPhysicalPackages(); - auto cpu_core = Atom::System::getNumberOfPhysicalCPUs(); + auto cpu_model = atom::system::getCPUModel(); + auto cpu_freq = atom::system::getProcessorFrequency(); + auto cpu_id = atom::system::getProcessorIdentifier(); + auto cpu_package = atom::system::getNumberOfPhysicalPackages(); + auto cpu_core = atom::system::getNumberOfPhysicalCPUs(); Dict d(vm); d.set(py_var(vm, "model"), py_var(vm, cpu_model)); @@ -124,7 +124,7 @@ void addSysModule(VM *vm) { "get CPU model, and return a string value", [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get CPU model"); - std::string cpu_model = Atom::System::getCPUModel(); + std::string cpu_model = atom::system::getCPUModel(); if (cpu_model.empty()) { LOG_F(ERROR, "Failed to get cpu model: {}", cpu_model); } @@ -136,7 +136,7 @@ void addSysModule(VM *vm) { "get memory usage, and return a float value", [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get memory usage"); - float memory_usage = Atom::System::getMemoryUsage(); + float memory_usage = atom::system::getMemoryUsage(); if (memory_usage < 0.0f) { LOG_F(ERROR, "Failed to get memory usage: {}", memory_usage); @@ -149,7 +149,7 @@ void addSysModule(VM *vm) { "get total memory size, and return a float value", [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get memory total"); - float memory_total = Atom::System::getTotalMemorySize(); + float memory_total = atom::system::getTotalMemorySize(); if (memory_total < 0.0f) { LOG_F(ERROR, "Failed to get memory total: {}", memory_total); @@ -163,7 +163,7 @@ void addSysModule(VM *vm) { [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get available memory"); float available_memory = - Atom::System::getAvailableMemorySize(); + atom::system::getAvailableMemorySize(); if (available_memory < 0.0f) { LOG_F(ERROR, "Failed to get available memory: {}", available_memory); @@ -176,12 +176,12 @@ void addSysModule(VM *vm) { mod, "get_memory_info() -> dict", "get memory usage, and return a dict value", [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get memory info"); - auto total_memory = Atom::System::getTotalMemorySize(); - auto available_memory = Atom::System::getAvailableMemorySize(); - auto virtual_memory_max = Atom::System::getVirtualMemoryMax(); - auto virtual_memory_used = Atom::System::getVirtualMemoryUsed(); - auto swap_memory_total = Atom::System::getSwapMemoryTotal(); - auto swap_memory_used = Atom::System::getSwapMemoryUsed(); + auto total_memory = atom::system::getTotalMemorySize(); + auto available_memory = atom::system::getAvailableMemorySize(); + auto virtual_memory_max = atom::system::getVirtualMemoryMax(); + auto virtual_memory_used = atom::system::getVirtualMemoryUsed(); + auto swap_memory_total = atom::system::getSwapMemoryTotal(); + auto swap_memory_used = atom::system::getSwapMemoryUsed(); Dict d(vm); d.set(py_var(vm, "total"), py_var(vm, total_memory)); d.set(py_var(vm, "available"), py_var(vm, available_memory)); @@ -197,7 +197,7 @@ void addSysModule(VM *vm) { [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get disk usage"); std::vector> disk_usage = - Atom::System::getDiskUsage(); + atom::system::getDiskUsage(); if (disk_usage.empty()) { // LOG_F(ERROR, "Failed to get disk usage: {}", // disk_usage); @@ -218,7 +218,7 @@ void addSysModule(VM *vm) { Str &name = py_cast(vm, name_obj); std::string driver_model = - Atom::System::getDriveModel(name.c_str()); + atom::system::getDriveModel(name.c_str()); if (driver_model.empty()) { LOG_F(ERROR, "Failed to get disk model: {}", driver_model); } @@ -231,7 +231,7 @@ void addSysModule(VM *vm) { [](VM *vm, ArgsView args) { DLOG_F(INFO, "Get disk models"); std::vector> disk_models = - Atom::System::getStorageDeviceModels(); + atom::system::getStorageDeviceModels(); if (disk_models.empty()) { // LOG_F(ERROR, "Failed to get disk models: {}", // disk_models); @@ -251,21 +251,21 @@ void addSysModule(VM *vm) { DLOG_F(INFO, "Check if the current process is running as " "root"); - bool is_root = Atom::System::isRoot(); + bool is_root = atom::system::isRoot(); return py_var(vm, is_root); }); vm->bind(mod, "shutdown() -> bool", "shutdown the system", [](VM *vm, ArgsView args) { DLOG_F(INFO, "Shutdown the system"); - Atom::System::shutdown(); + atom::system::shutdown(); return py_var(vm, true); }); vm->bind(mod, "reboot() -> bool", "reboot the system", [](VM *vm, ArgsView args) { DLOG_F(INFO, "Reboot the system"); - Atom::System::reboot(); + atom::system::reboot(); return py_var(vm, true); }); @@ -276,7 +276,7 @@ void addSysModule(VM *vm) { Str &name = py_cast(vm, name_obj); bool is_duplicate = - Atom::System::checkDuplicateProcess(name.c_str()); + atom::system::checkDuplicateProcess(name.c_str()); if (is_duplicate) { LOG_F(ERROR, "Failed to check duplicate process: {}", is_duplicate); @@ -291,7 +291,7 @@ void addSysModule(VM *vm) { PyObject *name_obj = args[0]; Str &name = py_cast(vm, name_obj); - bool is_running = Atom::System::isProcessRunning(name.c_str()); + bool is_running = atom::system::isProcessRunning(name.c_str()); DLOG_F(INFO, "Process running: {}", is_running ? "true" : "false"); return py_var(vm, is_running); @@ -302,9 +302,9 @@ void addSysModule(VM *vm) { [](VM *vm, ArgsView args) { PyObject *name_obj = args[0]; Str &name = py_cast(vm, name_obj); - Atom::System::ProcessInfo info; + atom::system::ProcessInfo info; Dict d(vm); - if (Atom::System::getProcessInfoByName(name.c_str(), info)) { + if (atom::system::getProcessInfoByName(name.c_str(), info)) { d.set(VAR("id"), VAR(info.processID)); d.set(VAR("parent_id"), VAR(info.parentProcessID)); d.set(VAR("priority"), VAR(info.basePriority)); @@ -319,9 +319,9 @@ void addSysModule(VM *vm) { "get process info by id, and return a dict value", [](VM *vm, ArgsView args) { int id = py_cast(vm, args[0]); - Atom::System::ProcessInfo info; + atom::system::ProcessInfo info; Dict d(vm); - if (Atom::System::getProcessInfoByID(id, info)) { + if (atom::system::getProcessInfoByID(id, info)) { d.set(VAR("id"), VAR(info.processID)); d.set(VAR("parent_id"), VAR(info.parentProcessID)); d.set(VAR("priority"), VAR(info.basePriority)); diff --git a/src/server/controller/AsyncProcessController.hpp b/src/server/controller/AsyncProcessController.hpp index 968abb2c..55461395 100644 --- a/src/server/controller/AsyncProcessController.hpp +++ b/src/server/controller/AsyncProcessController.hpp @@ -41,7 +41,7 @@ void replaceAll(std::string &str, auto &from, auto &to) { class ProcessController : public oatpp::web::server::api::ApiController { private: - static std::shared_ptr m_processManager; + static std::shared_ptr m_processManager; public: ProcessController(const std::shared_ptr &objectMapper) @@ -235,8 +235,8 @@ class ProcessController : public oatpp::web::server::api::ApiController { }; }; -std::shared_ptr ProcessController::m_processManager = - GetPtr("lithium.system.process"); +std::shared_ptr ProcessController::m_processManager = + GetPtr("lithium.system.process"); #include OATPP_CODEGEN_END(ApiController) //<- End Codegen diff --git a/src/server/controller/AsyncSystemController.hpp b/src/server/controller/AsyncSystemController.hpp index 986dab01..f1fcb6a5 100644 --- a/src/server/controller/AsyncSystemController.hpp +++ b/src/server/controller/AsyncSystemController.hpp @@ -64,7 +64,7 @@ class SystemController : public oatpp::web::server::api::ApiController { Action act() override { auto res = BaseReturnSystemDto::createShared(); res->command = "getUICpuUsage"; - if (float cpu_usage = Atom::System::getCurrentCpuUsage(); + if (float cpu_usage = atom::system::getCurrentCpuUsage(); cpu_usage <= 0.0f) { res->status = "error"; res->message = "Failed to get current CPU usage"; @@ -91,7 +91,7 @@ class SystemController : public oatpp::web::server::api::ApiController { Action act() override { auto res = BaseReturnSystemDto::createShared(); res->command = "getUICpuTemperature"; - if (float cpu_temp = Atom::System::getCurrentCpuTemperature(); + if (float cpu_temp = atom::system::getCurrentCpuTemperature(); cpu_temp <= 0.0f) { res->code = 500; res->status = "error"; @@ -119,11 +119,11 @@ class SystemController : public oatpp::web::server::api::ApiController { auto res = ReturnCpuInfoDto::createShared(); res->command = "getUICpuInfo"; - auto cpu_model = Atom::System::getCPUModel(); - auto cpu_freq = Atom::System::getProcessorFrequency(); - auto cpu_id = Atom::System::getProcessorIdentifier(); - auto cpu_package = Atom::System::getNumberOfPhysicalPackages(); - auto cpu_core = Atom::System::getNumberOfPhysicalCPUs(); + auto cpu_model = atom::system::getCPUModel(); + auto cpu_freq = atom::system::getProcessorFrequency(); + auto cpu_id = atom::system::getProcessorIdentifier(); + auto cpu_package = atom::system::getNumberOfPhysicalPackages(); + auto cpu_core = atom::system::getNumberOfPhysicalCPUs(); if (cpu_model.empty() || cpu_freq <= 0.0f || cpu_id.empty() || cpu_package <= 0 || cpu_core <= 0) [[unlikely]] { @@ -176,7 +176,7 @@ class SystemController : public oatpp::web::server::api::ApiController { auto res = BaseReturnSystemDto::createShared(); res->command = "getUIMemoryUsage"; - auto memory_usage = Atom::System::getMemoryUsage(); + auto memory_usage = atom::system::getMemoryUsage(); if (memory_usage <= 0.0f) { res->code = 500; res->status = "error"; @@ -205,14 +205,14 @@ class SystemController : public oatpp::web::server::api::ApiController { auto res = ReturnMemoryInfoDto::createShared(); res->command = "getUIMemoryInfo"; - auto total_memory = Atom::System::getTotalMemorySize(); - auto available_memory = Atom::System::getAvailableMemorySize(); - auto virtual_memory_max = Atom::System::getVirtualMemoryMax(); - auto virtual_memory_used = Atom::System::getVirtualMemoryUsed(); - auto swap_memory_total = Atom::System::getSwapMemoryTotal(); - auto swap_memory_used = Atom::System::getSwapMemoryUsed(); + auto total_memory = atom::system::getTotalMemorySize(); + auto available_memory = atom::system::getAvailableMemorySize(); + auto virtual_memory_max = atom::system::getVirtualMemoryMax(); + auto virtual_memory_used = atom::system::getVirtualMemoryUsed(); + auto swap_memory_total = atom::system::getSwapMemoryTotal(); + auto swap_memory_used = atom::system::getSwapMemoryUsed(); - auto physical_memory = Atom::System::getPhysicalMemoryInfo(); + auto physical_memory = atom::system::getPhysicalMemoryInfo(); if (total_memory <= 0 || available_memory <= 0 || virtual_memory_max <= 0 || virtual_memory_used <= 0 || @@ -260,7 +260,7 @@ class SystemController : public oatpp::web::server::api::ApiController { auto res = ReturnDiskUsageDto::createShared(); res->command = "getUIDiskUsage"; - auto tmp = Atom::System::getDiskUsage(); + auto tmp = atom::system::getDiskUsage(); if (tmp.empty()) { res->code = 500; res->status = "error"; @@ -291,7 +291,7 @@ class SystemController : public oatpp::web::server::api::ApiController { auto res = ReturnAvailableDrivesDto::createShared(); res->command = "getUIAvailableDrives"; - auto tmp = Atom::System::getAvailableDrives(); + auto tmp = atom::system::getAvailableDrives(); if (tmp.empty()) { res->code = 500; @@ -327,7 +327,7 @@ class SystemController : public oatpp::web::server::api::ApiController { auto res = ReturnBatteryInfoDto::createShared(); res->command = "getUIBatteryInfo"; - const auto tmp = Atom::System::getBatteryInfo(); + const auto tmp = atom::system::getBatteryInfo(); res->isBatteryPresent = tmp.isBatteryPresent; res->isCharging = tmp.isCharging; @@ -367,9 +367,9 @@ class SystemController : public oatpp::web::server::api::ApiController { res->command = "getUINetworkInfo"; try { - auto isHotspotConnected = Atom::System::isHotspotConnected(); - auto wifi = Atom::System::getCurrentWifi(); - auto wired = Atom::System::getCurrentWiredNetwork(); + auto isHotspotConnected = atom::system::isHotspotConnected(); + auto wifi = atom::system::getCurrentWifi(); + auto wired = atom::system::getCurrentWiredNetwork(); res->hotspot = isHotspotConnected; res->wifi = wifi; @@ -404,7 +404,7 @@ class SystemController : public oatpp::web::server::api::ApiController { auto res = ReturnOSInfoDto::createShared(); res->command = "getUIOSInfo"; - auto tmp = Atom::System::getOperatingSystemInfo(); + auto tmp = atom::system::getOperatingSystemInfo(); if (tmp.osName.empty() || tmp.osVersion.empty() || tmp.kernelVersion.empty()) { @@ -443,7 +443,7 @@ class SystemController : public oatpp::web::server::api::ApiController { ENDPOINT_ASYNC_INIT(getUIProcesses); Action act() override { nlohmann::json res; - for (const auto &process : Atom::System::getProcessInfo()) { + for (const auto &process : atom::system::getProcessInfo()) { OATPP_LOGD("System", "Process Name: %s File Address: %s", process.first.c_str(), process.second.c_str()); res["value"][process.first] = process.second; @@ -463,7 +463,7 @@ class SystemController : public oatpp::web::server::api::ApiController { ENDPOINT_ASYNC("GET", "/api/system/shutdown", getUIShutdown) { ENDPOINT_ASYNC_INIT(getUIShutdown); Action act() override { - Atom::System::shutdown(); + atom::system::shutdown(); return _return(controller->createResponse( Status::CODE_200, "Wtf, how can you do that?")); } @@ -473,7 +473,7 @@ class SystemController : public oatpp::web::server::api::ApiController { ENDPOINT_ASYNC("GET", "/api/system/reboot", getUIReboot) { ENDPOINT_ASYNC_INIT(getUIReboot); Action act() override { - Atom::System::reboot(); + atom::system::reboot(); return _return(controller->createResponse( Status::CODE_200, "Wtf, how can you do that?")); } diff --git a/src/server/data/SystemCustom.hpp b/src/server/data/SystemCustom.hpp index 1a35f4f5..ce0ee5c0 100644 --- a/src/server/data/SystemCustom.hpp +++ b/src/server/data/SystemCustom.hpp @@ -10,10 +10,10 @@ class MemorySlotClass; } /* Declare ObjectWrapper for your type */ -/* Mapping-Enabled Atom::System::MemoryInfo::MemorySlot */ -typedef oatpp::data::mapping::type::Primitive - Atom::System::MemoryInfo::MemorySlot; + atom::system::MemoryInfo::MemorySlot; namespace __class { @@ -27,18 +27,18 @@ class MemorySlotClass { */ class Inter : public oatpp::Type::Interpretation< - Atom::System::MemoryInfo::MemorySlot, oatpp::UnorderedFields> { + atom::system::MemoryInfo::MemorySlot, oatpp::UnorderedFields> { public: oatpp::UnorderedFields interpret( - const Atom::System::MemoryInfo::MemorySlot& value) const override { + const atom::system::MemoryInfo::MemorySlot& value) const override { return {{"capacity", value.capacity}, {"clockSpeed", value.clockSpeed}, {"type", value.type}}; } - Atom::System::MemoryInfo::MemorySlot reproduce( + atom::system::MemoryInfo::MemorySlot reproduce( const oatpp::UnorderedFields map) const override { - return Atom::System::MemoryInfo::MemorySlot( + return atom::system::MemoryInfo::MemorySlot( {map["capacity"], map["clockSpeed"], map["type"]}); } }; @@ -55,7 +55,7 @@ class MemorySlotClass { }; const oatpp::ClassId MemorySlotClass::CLASS_ID( - "system::memory::Atom::System::MemoryInfo::MemorySlot"); + "system::memory::atom::system::MemoryInfo::MemorySlot"); } // namespace __class From 80922210f0b0b0481aed55caa4abe2df234dd7c0 Mon Sep 17 00:00:00 2001 From: Max Qian Date: Fri, 3 May 2024 21:07:34 +0800 Subject: [PATCH 02/28] big update --- Doxyfile | 2895 ++++++++++++++++++++++++ src/addon/manager.cpp | 219 +- src/addon/manager.hpp | 37 +- src/addon/sort.cpp | 9 +- src/addon/sort.hpp | 14 + src/atom/async/threadlocal.hpp | 99 + src/atom/components/base/main.cpp | 8 +- src/atom/components/component.hpp | 81 +- src/atom/components/dispatch.hpp | 59 +- src/atom/components/dispatch.inl | 79 +- src/atom/function/concept.hpp | 20 + src/atom/function/func_traits.hpp | 39 +- src/atom/function/proxy.hpp | 28 +- src/atom/io/io.cpp | 46 +- src/atom/io/io.hpp | 35 +- src/atom/type/indestructible.hpp | 81 + src/atom/utils/slice.cpp | 245 ++ src/atom/utils/slice.hpp | 332 +++ src/atom/utils/string.cpp | 6 + src/atom/utils/string.hpp | 8 + src/debug/terminal.cpp | 191 +- src/debug/terminal.hpp | 66 +- src/modules/CMakeLists.txt | 1 + src/modules/atom.io/CMakeLists.txt | 71 + src/modules/atom.io/_component.cpp | 75 + src/modules/atom.io/_component.hpp | 33 + src/modules/atom.io/_main.cpp | 29 + src/modules/atom.io/package.json | 34 + src/modules/atom.system/_component.cpp | 98 +- src/modules/atom.utils/CMakeLists.txt | 72 + src/modules/atom.utils/_component.cpp | 39 + src/modules/atom.utils/_component.hpp | 33 + src/modules/atom.utils/_main.cpp | 28 + src/modules/atom.utils/package.json | 0 tools/components/generator.py | 173 ++ 35 files changed, 5028 insertions(+), 255 deletions(-) create mode 100644 Doxyfile create mode 100644 src/atom/async/threadlocal.hpp create mode 100644 src/atom/function/concept.hpp create mode 100644 src/atom/type/indestructible.hpp create mode 100644 src/atom/utils/slice.cpp create mode 100644 src/atom/utils/slice.hpp create mode 100644 src/modules/atom.io/CMakeLists.txt create mode 100644 src/modules/atom.io/_component.cpp create mode 100644 src/modules/atom.io/_component.hpp create mode 100644 src/modules/atom.io/_main.cpp create mode 100644 src/modules/atom.io/package.json create mode 100644 src/modules/atom.utils/CMakeLists.txt create mode 100644 src/modules/atom.utils/_component.cpp create mode 100644 src/modules/atom.utils/_component.hpp create mode 100644 src/modules/atom.utils/_main.cpp create mode 100644 src/modules/atom.utils/package.json create mode 100644 tools/components/generator.py diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 00000000..04c8bd53 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,2895 @@ +# Doxyfile 1.10.0 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). +# +# Note: +# +# Use doxygen to compare the used configuration file with the template +# configuration file: +# doxygen -x [configFile] +# Use doxygen to compare the used configuration file with the template +# configuration file without replacing the environment variables or CMake type +# replacement variables: +# doxygen -x_noenv [configFile] + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = Lithium + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "Open Astrophotography Terminal" + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = C:/msys64/home/Qrm/Lithium/websrc/cobalt-web/public/atom.png + +# With the PROJECT_ICON tag one can specify an icon that is included in the tabs +# when the HTML document is shown. Doxygen will copy the logo to the output +# directory. + +PROJECT_ICON = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = C:\msys64\home\Qrm\Lithium\doc + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 +# sub-directories (in 2 levels) under the output directory of each output format +# and will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to +# control the number of sub-directories. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# Controls the number of sub-directories that will be created when +# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every +# level increment doubles the number of directories, resulting in 4096 +# directories at level 8 which is the default and also the maximum value. The +# sub-directories are organized in 2 levels, the first level always has a fixed +# number of 16 directories. +# Minimum value: 0, maximum value: 8, default value: 8. +# This tag requires that the tag CREATE_SUBDIRS is set to YES. + +CREATE_SUBDIRS_LEVEL = 8 + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian, +# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English +# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek, +# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with +# English messages), Korean, Korean-en (Korean with English messages), Latvian, +# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, +# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, +# Swedish, Turkish, Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = Chinese + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:^^" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". Note that you cannot put \n's in the value part of an alias +# to insert newlines (in the resulting output). You can put ^^ in the value part +# of an alias to insert a newline as if a physical newline was in the original +# file. When you need a literal { or } or , in the value part of an alias you +# have to escape them by means of a backslash (\), this can lead to conflicts +# with the commands \{ and \} for these it is advised to use the version @{ and +# @} or use a double escape (\\{ and \\}) + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, +# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# The MARKDOWN_ID_STYLE tag can be used to specify the algorithm used to +# generate identifiers for the Markdown headings. Note: Every identifier is +# unique. +# Possible values are: DOXYGEN use a fixed 'autotoc_md' string followed by a +# sequence number starting at 0 and GITHUB use the lower case version of title +# with any whitespace replaced by '-' and punctuation characters removed. +# The default value is: DOXYGEN. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +MARKDOWN_ID_STYLE = DOXYGEN + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which effectively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +# If the TIMESTAMP tag is set different from NO then each generated page will +# contain the date or date and time when the page was generated. Setting this to +# NO can help when comparing the output of multiple runs. +# Possible values are: YES, NO, DATETIME and DATE. +# The default value is: NO. + +TIMESTAMP = NO + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = YES + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# will also hide undocumented C++ concepts if enabled. This option has no effect +# if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# Possible values are: SYSTEM, NO and YES. +# The default value is: SYSTEM. + +CASE_SENSE_NAMES = SYSTEM + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class +# will show which file needs to be included to use the class. +# The default value is: YES. + +SHOW_HEADERFILE = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. See also section "Changing the +# layout of pages" for information. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as documenting some parameters in +# a documented function twice, or documenting parameters that don't exist or +# using markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete +# function parameter documentation. If set to NO, doxygen will accept that some +# parameters have no documentation without warning. +# The default value is: YES. + +WARN_IF_INCOMPLETE_DOC = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong parameter +# documentation, but not about the absence of documentation. If EXTRACT_ALL is +# set to YES then this flag will automatically be disabled. See also +# WARN_IF_INCOMPLETE_DOC +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about +# undocumented enumeration values. If set to NO, doxygen will accept +# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: NO. + +WARN_IF_UNDOC_ENUM_VAL = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS_PRINT then doxygen behaves +# like FAIL_ON_WARNINGS but in case no WARN_LOGFILE is defined doxygen will not +# write the warning messages in between other messages but write them at the end +# of a run, in case a WARN_LOGFILE is defined the warning messages will be +# besides being in the defined file also be shown at the end of a run, unless +# the WARN_LOGFILE is defined as - i.e. standard output (stdout) in that case +# the behavior will remain as with the setting FAIL_ON_WARNINGS. +# Possible values are: NO, YES, FAIL_ON_WARNINGS and FAIL_ON_WARNINGS_PRINT. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# See also: WARN_LINE_FORMAT +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# In the $text part of the WARN_FORMAT command it is possible that a reference +# to a more specific place is given. To make it easier to jump to this place +# (outside of doxygen) the user can define a custom "cut" / "paste" string. +# Example: +# WARN_LINE_FORMAT = "'vi $file +$line'" +# See also: WARN_FORMAT +# The default value is: at line $line of file $file. + +WARN_LINE_FORMAT = "at line $line of file $file" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). In case the file specified cannot be opened for writing the +# warning and error messages are written to standard error. When as file - is +# specified the warning and error messages are written to standard output +# (stdout). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = C:\msys64\home\Qrm\Lithium\src + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# See also: INPUT_FILE_ENCODING +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify +# character encoding on a per file pattern basis. Doxygen will compare the file +# name with each pattern and apply the encoding instead of the default +# INPUT_ENCODING) if there is a match. The character encodings are a list of the +# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding +# "INPUT_ENCODING" for further information on supported encodings. + +INPUT_FILE_ENCODING = + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cxxm, +# *.cpp, *.cppm, *.ccm, *.c++, *.c++m, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, +# *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, *.h++, *.ixx, *.l, *.cs, *.d, +# *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to +# be provided as doxygen C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, +# *.f18, *.f, *.for, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cxxm \ + *.cpp \ + *.cppm \ + *.ccm \ + *.c++ \ + *.c++m \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.ixx \ + *.l \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice \ + *.cpp + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# ANamespace::AClass, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that doxygen will use the data processed and written to standard output +# for further processing, therefore nothing else, like debug statements or used +# commands (so in case of a Windows batch file always use @echo OFF), should be +# written to standard output. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +# The Fortran standard specifies that for fixed formatted Fortran code all +# characters from position 72 are to be considered as comment. A common +# extension is to allow longer lines before the automatic comment starts. The +# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can +# be processed before the automatic comment starts. +# Minimum value: 7, maximum value: 10000, default value: 72. + +FORTRAN_COMMENT_AFTER = 72 + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# multi-line macros, enums or list initialized variables directly into the +# documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If the CLANG_ASSISTED_PARSING tag is set to YES and the CLANG_ADD_INC_PATHS +# tag is set to YES then doxygen will add the directory of each input to the +# include path. +# The default value is: YES. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_ADD_INC_PATHS = YES + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) +# that should be ignored while generating the index headers. The IGNORE_PREFIX +# tag works for classes, function and member names. The entity will be placed in +# the alphabetical list under the first letter of the entity name that remains +# after removing the prefix. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). +# Note: Since the styling of scrollbars can currently not be overruled in +# Webkit/Chromium, the styling will be left out of the default doxygen.css if +# one or more extra stylesheets have been specified. So if scrollbar +# customization is desired it has to be added explicitly. For an example see the +# documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output +# should be rendered with a dark or light theme. +# Possible values are: LIGHT always generate light mode output, DARK always +# generate dark mode output, AUTO_LIGHT automatically set the mode according to +# the user preference, use light mode if no preference is set (the default), +# AUTO_DARK automatically set the mode according to the user preference, use +# dark mode if no preference is set and TOGGLE allow to user to switch between +# light and dark mode via a button. +# The default value is: AUTO_LIGHT. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE = AUTO_LIGHT + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a color-wheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use gray-scales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# If the HTML_CODE_FOLDING tag is set to YES then classes and functions can be +# dynamically folded and expanded in the generated HTML source code. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_CODE_FOLDING = YES + +# If the HTML_COPY_CLIPBOARD tag is set to YES then doxygen will show an icon in +# the top right corner of code and text fragments that allows the user to copy +# its content to the clipboard. Note this only works if supported by the browser +# and the web page is served via a secure context (see: +# https://www.w3.org/TR/secure-contexts/), i.e. using the https: or file: +# protocol. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COPY_CLIPBOARD = YES + +# Doxygen stores a couple of settings persistently in the browser (via e.g. +# cookies). By default these settings apply to all HTML pages generated by +# doxygen across all projects. The HTML_PROJECT_COOKIE tag can be used to store +# the settings under a project specific key, such that the user preferences will +# be stored separately. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_PROJECT_COOKIE = + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = YES + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag determines the URL of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDURL = + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# on Windows. In the beginning of 2021 Microsoft took the original page, with +# a.o. the download links, offline the HTML help workshop was already many years +# in maintenance mode). You can download the HTML help workshop from the web +# archives at Installation executable (see: +# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo +# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = YES + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# The SITEMAP_URL tag is used to specify the full URL of the place where the +# generated documentation will be placed on the server by the user during the +# deployment of the documentation. The generated sitemap is called sitemap.xml +# and placed on the directory specified by HTML_OUTPUT. In case no SITEMAP_URL +# is specified no sitemap is generated. For information about the sitemap +# protocol see https://www.sitemaps.org +# This tag requires that the tag GENERATE_HTML is set to YES. + +SITEMAP_URL = + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine tune the look of the index (see "Fine-tuning the output"). As an +# example, the default style sheet generated by doxygen has an example that +# shows how to put an image at the root of the tree instead of the PROJECT_NAME. +# Since the tree basically has the same information as the tab index, you could +# consider setting DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the +# FULL_SIDEBAR option determines if the side bar is limited to only the treeview +# area (value NO) or if it should extend to the full height of the window (value +# YES). Setting this to YES gives a layout similar to +# https://docs.readthedocs.io with more room for contents, but less room for the +# project logo, title, and description. If either GENERATE_TREEVIEW or +# DISABLE_INDEX is set to NO, this option has no effect. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FULL_SIDEBAR = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email +# addresses. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +OBFUSCATE_EMAILS = YES + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_2 + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. For more details about the output format see MathJax +# version 2 (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 +# (see: +# http://docs.mathjax.org/en/latest/web/components/output.html). +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility. This is the name for Mathjax version 2, for MathJax version 3 +# this will be translated into chtml), NativeMML (i.e. MathML. Only supported +# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This +# is the name for Mathjax version 3, for MathJax version 2 this will be +# translated into HTML-CSS) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. The default value is: +# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 +# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# for MathJax version 2 (see +# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions): +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# For example for MathJax version 3 (see +# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): +# MATHJAX_EXTENSIONS = ams +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /