summaryrefslogtreecommitdiffhomepage
path: root/InfoEx
diff options
context:
space:
mode:
Diffstat (limited to 'InfoEx')
-rw-r--r--InfoEx/CMakeLists.txt13
-rw-r--r--InfoEx/include/InfoEx.h27
-rw-r--r--InfoEx/src/description.cpp53
-rw-r--r--InfoEx/src/directx_other.cpp22
-rw-r--r--InfoEx/src/directx_win32.cpp28
-rw-r--r--InfoEx/test/description.cpp17
-rw-r--r--InfoEx/test/directx.cpp11
7 files changed, 171 insertions, 0 deletions
diff --git a/InfoEx/CMakeLists.txt b/InfoEx/CMakeLists.txt
new file mode 100644
index 0000000..dab78ff
--- /dev/null
+++ b/InfoEx/CMakeLists.txt
@@ -0,0 +1,13 @@
+project(InfoEx)
+add_library(${PROJECT_NAME} STATIC src/description.cpp)
+target_include_directories(${PROJECT_NAME} PUBLIC include/)
+if(WIN32)
+ target_sources(${PROJECT_NAME} PRIVATE src/directx_win32.cpp)
+else()
+ target_sources(${PROJECT_NAME} PRIVATE src/directx_other.cpp)
+endif()
+target_link_libraries(${PROJECT_NAME} PUBLIC FoundationEx PRIVATE iware::infoware)
+add_executable(${PROJECT_NAME}_test test/description.cpp test/directx.cpp)
+generate_emulator(${PROJECT_NAME}_test)
+target_link_libraries(${PROJECT_NAME}_test PRIVATE ${PROJECT_NAME} GTest::gtest_main)
+gtest_discover_tests(${PROJECT_NAME}_test DISCOVERY_TIMEOUT 60)
diff --git a/InfoEx/include/InfoEx.h b/InfoEx/include/InfoEx.h
new file mode 100644
index 0000000..7ea7bf8
--- /dev/null
+++ b/InfoEx/include/InfoEx.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <Text.h>
+
+
+namespace InfoEx
+{
+
+
+Text ShortDescription();
+Text LongDescription();
+
+
+enum struct DXVersion : int
+{
+ None,
+ Dx7 = 7,
+ Dx8,
+ Dx9,
+ Future,
+};
+
+
+DXVersion DirectX();
+
+
+} // namespace InfoEx
diff --git a/InfoEx/src/description.cpp b/InfoEx/src/description.cpp
new file mode 100644
index 0000000..5635de5
--- /dev/null
+++ b/InfoEx/src/description.cpp
@@ -0,0 +1,53 @@
+#include <InfoEx.h>
+
+#include <infoware/infoware.hpp>
+
+#include <Text.h>
+
+
+namespace
+{
+
+
+static constexpr const char* prefixes[] {"", "k", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"};
+
+
+Text
+HumanReadable(long double value, const char* unit)
+{
+ int magnitude = 0;
+ while (value > 1000) {
+ value /= 1000;
+ magnitude++;
+ }
+ return Text::format("%.2Lf %s%s", value, prefixes[magnitude], unit);
+}
+
+
+} // namespace
+
+
+namespace InfoEx
+{
+
+
+Text
+ShortDescription()
+{
+ return iware::system::OS_info().full_name.data();
+}
+
+
+Text
+LongDescription()
+{
+ return Text::format(
+ "OS: %s\nPhysical memory: %s\nCPU: %s\nCPU frequency: %s",
+ iware::system::OS_info().full_name.data(),
+ HumanReadable(iware::system::memory().physical_total, "B").data(),
+ iware::cpu::model_name().data(),
+ HumanReadable(iware::cpu::frequency(), "Hz").data());
+}
+
+
+} // namespace InfoEx
diff --git a/InfoEx/src/directx_other.cpp b/InfoEx/src/directx_other.cpp
new file mode 100644
index 0000000..75d1d39
--- /dev/null
+++ b/InfoEx/src/directx_other.cpp
@@ -0,0 +1,22 @@
+#ifndef _WIN32
+
+#include <InfoEx.h>
+
+#include <Text.h>
+
+
+namespace InfoEx
+{
+
+
+DXVersion
+DirectX()
+{
+ return DXVersion::None;
+}
+
+
+} // namespace InfoEx
+
+
+#endif // _WIN32
diff --git a/InfoEx/src/directx_win32.cpp b/InfoEx/src/directx_win32.cpp
new file mode 100644
index 0000000..4ade30b
--- /dev/null
+++ b/InfoEx/src/directx_win32.cpp
@@ -0,0 +1,28 @@
+#ifdef _WIN32
+
+#include <InfoEx.h>
+
+#include <windows.h>
+
+#include <Text.h>
+
+
+namespace InfoEx
+{
+
+
+DXVersion
+DirectX()
+{
+ auto lib = LoadLibrary("D3D9.DLL");
+ if (lib == nullptr)
+ return DXVersion::None;
+ FreeLibrary(lib);
+ return DXVersion::Dx9;
+}
+
+
+} // namespace InfoEx
+
+
+#endif // _WIN32
diff --git a/InfoEx/test/description.cpp b/InfoEx/test/description.cpp
new file mode 100644
index 0000000..e9f5120
--- /dev/null
+++ b/InfoEx/test/description.cpp
@@ -0,0 +1,17 @@
+#include <gtest/gtest.h>
+
+#include <iostream>
+
+#include <InfoEx.h>
+
+
+TEST(InfoEx, ShortDescription)
+{
+ std::cout << InfoEx::ShortDescription() << std::endl;
+}
+
+
+TEST(InfoEx, LongDescription)
+{
+ std::cout << InfoEx::LongDescription() << std::endl;
+}
diff --git a/InfoEx/test/directx.cpp b/InfoEx/test/directx.cpp
new file mode 100644
index 0000000..1e3444c
--- /dev/null
+++ b/InfoEx/test/directx.cpp
@@ -0,0 +1,11 @@
+#include <gtest/gtest.h>
+
+#include <iostream>
+
+#include <InfoEx.h>
+
+
+TEST(InfoEx, DirectX)
+{
+ std::cout << static_cast<int>(InfoEx::DirectX()) << std::endl;
+}