Skip to content

Commit 27f2922

Browse files
optimize: refactor the ui subsystem; simplifed docs; hwtier finishes (#5)
* hwtier system enabled * refactor: refactor the ui subsystem * simplified: remove the old documentations * simplified: remove the old documentations
1 parent 5f264ec commit 27f2922

139 files changed

Lines changed: 4829 additions & 28042 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ message("Including Requested CMake Dependencies OK")
1212
include(cmake/check_toolchain.cmake)
1313

1414
project(CFDesktop
15-
VERSION 0.18.0
15+
VERSION 0.19.0
1616
DESCRIPTION "CFDesktop: Given Your Device Portable Desktop Anywhere"
1717
HOMEPAGE_URL "https://github.com/Awesome-Embedded-Learning-Studio/CFDesktop"
1818
LANGUAGES CXX C

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 为嵌入式设备打造的现代化 Material Design 3 桌面框架
66

7-
[![License: MIT][license-badge]] [![Version: 0.18.0][version-badge]]
7+
[![License: MIT][license-badge]] [![Version: 0.19.0][version-badge]]
88
[![C++23][cpp-badge]] [![Qt 6.8][qt-badge]] [![CMake][cmake-badge]]
99
[![Documentation][docs-badge]]
1010

base/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ set(CFBASE_MODULE_TARGETS
2727
cfbase_network
2828
cfbase_gpu
2929
cfbase_console
30+
cfbase_hardware_tier
3031
)
3132

3233
# Link static libraries from sub-modules with --whole-archive to ensure

base/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ For detailed API reference, implementation notes, and usage examples, see the Ha
7979
- Memory API: [document/HandBook/api/system/memory/memory_info.md](../document/HandBook/api/system/memory/memory_info.md)
8080
- Windows CPU implementation: [document/HandBook/implementation/windows/cpu_implementation.md](../document/HandBook/implementation/windows/cpu_implementation.md)
8181
- Linux CPU implementation: [document/HandBook/implementation/linux/cpu_implementation.md](../document/HandBook/implementation/linux/cpu_implementation.md)
82+
83+
> 完整 API 手册: [document/HandBook/base/overview.md](../document/HandBook/base/overview.md)
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/**
2+
* @file hardware_tier.h
3+
* @brief Declares the hardware tier assessment public API.
4+
*
5+
* Provides functions for registering pluggable pipeline stages,
6+
* configuring DeviceConfig overrides, and performing hardware
7+
* tier assessments.
8+
*
9+
* @author Charliechen114514
10+
* @date 2026-05-23
11+
* @version 0.19
12+
* @since 0.19
13+
* @ingroup system_hardware_tier
14+
*/
15+
#pragma once
16+
17+
#include "base/expected/expected.hpp"
18+
#include "base/export.h"
19+
#include "system/hardware_tier/hardware_tier_data.h"
20+
21+
#include <memory>
22+
#include <string_view>
23+
24+
namespace cf {
25+
26+
class IHardwareCollector;
27+
class IHardwareScorer;
28+
class IHardwareAssessor;
29+
class IHardwarePolicy;
30+
31+
// ─────────────────────────────────────────────────────────
32+
// Pipeline Registry
33+
// ─────────────────────────────────────────────────────────
34+
35+
/**
36+
* @brief Registers a custom hardware data collector.
37+
*
38+
* Replaces the default collector. Must be called before the first
39+
* assessHardware() invocation.
40+
*
41+
* @param[in] collector Unique pointer to the collector implementation.
42+
*
43+
* @return void (replaces the registered collector).
44+
*
45+
* @since 0.19
46+
* @ingroup system_hardware_tier
47+
*/
48+
CF_BASE_EXPORT void registerCollector(std::unique_ptr<IHardwareCollector> collector);
49+
50+
/**
51+
* @brief Registers a custom scorer for a specific dimension.
52+
*
53+
* @param[in] dimension One of "cpu", "gpu", "memory", "display".
54+
* @param[in] scorer Unique pointer to the scorer implementation.
55+
*
56+
* @return void (replaces the registered scorer for the dimension).
57+
*
58+
* @since 0.19
59+
* @ingroup system_hardware_tier
60+
*/
61+
CF_BASE_EXPORT void registerScorer(std::string_view dimension,
62+
std::unique_ptr<IHardwareScorer> scorer);
63+
64+
/**
65+
* @brief Registers a custom assessor implementation.
66+
*
67+
* @param[in] assessor Unique pointer to the assessor implementation.
68+
*
69+
* @return void (replaces the registered assessor).
70+
*
71+
* @since 0.19
72+
* @ingroup system_hardware_tier
73+
*/
74+
CF_BASE_EXPORT void registerAssessor(std::unique_ptr<IHardwareAssessor> assessor);
75+
76+
/**
77+
* @brief Registers a custom policy implementation.
78+
*
79+
* @param[in] policy Unique pointer to the policy implementation.
80+
*
81+
* @return void (replaces the registered policy).
82+
*
83+
* @since 0.19
84+
* @ingroup system_hardware_tier
85+
*/
86+
CF_BASE_EXPORT void registerPolicy(std::unique_ptr<IHardwarePolicy> policy);
87+
88+
// ─────────────────────────────────────────────────────────
89+
// DeviceConfig Override
90+
// ─────────────────────────────────────────────────────────
91+
92+
/**
93+
* @brief Sets a manual tier override from DeviceConfig.
94+
*
95+
* When set, the pipeline short-circuits: collection and scoring are
96+
* skipped, and the specified tier level is used directly.
97+
*
98+
* @param[in] level The tier level to enforce.
99+
* @param[in] reason Optional human-readable reason string.
100+
*
101+
* @return void (activates the tier override).
102+
*
103+
* @since 0.19
104+
* @ingroup system_hardware_tier
105+
*/
106+
CF_BASE_EXPORT void setDeviceConfigOverride(HardwareTierLevel level, std::string reason = {});
107+
108+
/**
109+
* @brief Clears any active DeviceConfig override.
110+
*
111+
* @return void (restores normal pipeline behavior).
112+
*
113+
* @since 0.19
114+
* @ingroup system_hardware_tier
115+
*/
116+
CF_BASE_EXPORT void clearDeviceConfigOverride();
117+
118+
// ─────────────────────────────────────────────────────────
119+
// Assessment API
120+
// ─────────────────────────────────────────────────────────
121+
122+
/**
123+
* @brief Performs a complete hardware tier assessment.
124+
*
125+
* Executes the full pipeline: Collect -> Score -> Assess -> Policy.
126+
* If a DeviceConfig override is active, the pipeline short-circuits
127+
* and returns the overridden tier.
128+
*
129+
* The result is cached after the first successful call. Pass
130+
* force_refresh = true to re-run the pipeline.
131+
*
132+
* @param[in] force_refresh If true, forces re-running the pipeline.
133+
*
134+
* @return expected containing HardwareTierAssessment on success,
135+
* or HardwareTierError on failure.
136+
*
137+
* @since 0.19
138+
* @ingroup system_hardware_tier
139+
*/
140+
CF_BASE_EXPORT expected<HardwareTierAssessment, HardwareTierError>
141+
assessHardware(bool force_refresh = false);
142+
143+
/**
144+
* @brief Queries capability flags from the last assessment.
145+
*
146+
* Must be called after a successful assessHardware().
147+
*
148+
* @return expected containing HardwareTierCapabilities on success,
149+
* or HardwareTierError if no assessment exists.
150+
*
151+
* @since 0.19
152+
* @ingroup system_hardware_tier
153+
*/
154+
CF_BASE_EXPORT expected<HardwareTierCapabilities, HardwareTierError> getHardwareTierCapabilities();
155+
156+
} // namespace cf

0 commit comments

Comments
 (0)