From 344056bb5a44f694784552850615099e1bb93d23 Mon Sep 17 00:00:00 2001 From: libragliese581 Date: Fri, 27 Dec 2024 17:39:52 +0300 Subject: [PATCH 1/5] Added a class to get information about the system --- system/ISystemInfoAPI.h | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 system/ISystemInfoAPI.h diff --git a/system/ISystemInfoAPI.h b/system/ISystemInfoAPI.h new file mode 100644 index 0000000..14ed535 --- /dev/null +++ b/system/ISystemInfoAPI.h @@ -0,0 +1,50 @@ +#pragma once + +#include + +#include "stdafx.h" + +namespace alt +{ + namespace system + { + /// \brief Interface system information + /// \note Gets information about the system load + class ISystemInfoAPI + { + public: + ISystemInfoAPI() = default; + virtual ~ISystemInfoAPI() noexcept = default; + + static ISystemInfoAPI& GetInstance() { return *Instance(); } + + static void SetInstance(ISystemInfoAPI* server) { Instance() = server; } + +#ifdef ALT_CLIENT_API + /// \brief Get CPU load + /// \return Load percentage + virtual double GetCPULoad() = 0; + + /// \brief Get video memory usage + /// \return Size of used memory in MB + virtual std::size_t GetVideoMemoryUsage() = 0; + + /// \brief Get RAM usage + /// \return Size of used memory in MB + virtual std::size_t GetRAMUsage() = 0; +#endif + + private: + static ISystemInfoAPI*& Instance() + { + static ISystemInfoAPI* instance = nullptr; + return instance; + } + + ISystemInfoAPI(ISystemInfoAPI&& other) = delete; + ISystemInfoAPI(const ISystemInfoAPI& other) = delete; + ISystemInfoAPI& operator=(ISystemInfoAPI&& other) = delete; + ISystemInfoAPI& operator=(const ISystemInfoAPI& other) = delete; + }; + } // namespace system +} // namespace alt From a082f00c7628e0ce6372206975c79ab1572ebc13 Mon Sep 17 00:00:00 2001 From: libragliese581 Date: Fri, 27 Dec 2024 22:52:32 +0300 Subject: [PATCH 2/5] Update ICore.h --- ICore.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ICore.h b/ICore.h index 8e484ed..85851ab 100644 --- a/ICore.h +++ b/ICore.h @@ -404,6 +404,10 @@ namespace alt virtual alt::IAudioFilter* GetVoiceFilter(uint32_t player) const = 0; virtual void UpdateClipContext(const std::unordered_map& context) = 0; virtual bool ReloadVehiclePhysics(uint32_t modelHash) = 0; + + virtual double GetCPULoad() const = 0; + virtual uint32_t GetVideoMemoryUsage() const = 0; + virtual uint32_t GetRAMUsage() const = 0; #endif #ifdef ALT_SERVER_API // Server methods From 8de0895bd7baa78e04c6b1022f98aad1ad3b52be Mon Sep 17 00:00:00 2001 From: libragliese581 Date: Sat, 28 Dec 2024 08:31:45 +0300 Subject: [PATCH 3/5] Update ISystemInfoAPI.h --- system/ISystemInfoAPI.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/system/ISystemInfoAPI.h b/system/ISystemInfoAPI.h index 14ed535..632eccc 100644 --- a/system/ISystemInfoAPI.h +++ b/system/ISystemInfoAPI.h @@ -2,8 +2,6 @@ #include -#include "stdafx.h" - namespace alt { namespace system From 226a91381036019e2603573a286afc26a693bcd9 Mon Sep 17 00:00:00 2001 From: libragliese581 Date: Sat, 28 Dec 2024 08:51:28 +0300 Subject: [PATCH 4/5] Delete ISystemInfoAPI.h --- system/ISystemInfoAPI.h | 48 ----------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 system/ISystemInfoAPI.h diff --git a/system/ISystemInfoAPI.h b/system/ISystemInfoAPI.h deleted file mode 100644 index 632eccc..0000000 --- a/system/ISystemInfoAPI.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include - -namespace alt -{ - namespace system - { - /// \brief Interface system information - /// \note Gets information about the system load - class ISystemInfoAPI - { - public: - ISystemInfoAPI() = default; - virtual ~ISystemInfoAPI() noexcept = default; - - static ISystemInfoAPI& GetInstance() { return *Instance(); } - - static void SetInstance(ISystemInfoAPI* server) { Instance() = server; } - -#ifdef ALT_CLIENT_API - /// \brief Get CPU load - /// \return Load percentage - virtual double GetCPULoad() = 0; - - /// \brief Get video memory usage - /// \return Size of used memory in MB - virtual std::size_t GetVideoMemoryUsage() = 0; - - /// \brief Get RAM usage - /// \return Size of used memory in MB - virtual std::size_t GetRAMUsage() = 0; -#endif - - private: - static ISystemInfoAPI*& Instance() - { - static ISystemInfoAPI* instance = nullptr; - return instance; - } - - ISystemInfoAPI(ISystemInfoAPI&& other) = delete; - ISystemInfoAPI(const ISystemInfoAPI& other) = delete; - ISystemInfoAPI& operator=(ISystemInfoAPI&& other) = delete; - ISystemInfoAPI& operator=(const ISystemInfoAPI& other) = delete; - }; - } // namespace system -} // namespace alt From 358e45c31815ea08ac4b61398584eb4d5aae0ae5 Mon Sep 17 00:00:00 2001 From: libragliese581 Date: Sat, 28 Dec 2024 20:34:53 +0300 Subject: [PATCH 5/5] Update ICore.h --- ICore.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ICore.h b/ICore.h index 85851ab..84e032f 100644 --- a/ICore.h +++ b/ICore.h @@ -408,6 +408,8 @@ namespace alt virtual double GetCPULoad() const = 0; virtual uint32_t GetVideoMemoryUsage() const = 0; virtual uint32_t GetRAMUsage() const = 0; + virtual uint32_t GetTotalRAM() const = 0; + virtual uint32_t GetCurrentProcessRamUsage() const = 0; #endif #ifdef ALT_SERVER_API // Server methods