Skip to content

Commit e7cfadc

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent bf6147f commit e7cfadc

File tree

86 files changed

+3968
-3514
lines changed

Some content is hidden

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

86 files changed

+3968
-3514
lines changed

atom/sysinfo/common/CMakeLists.txt

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
cmake_minimum_required(VERSION 3.20)
2-
project(atom_sysinfo_common VERSION 1.0.0 LANGUAGES CXX)
2+
project(
3+
atom_sysinfo_common
4+
VERSION 1.0.0
5+
LANGUAGES CXX)
36

47
# Set C++ standard
58
set(CMAKE_CXX_STANDARD 20)
69
set(CMAKE_CXX_STANDARD_REQUIRED ON)
710

811
# Define the library
9-
set(COMMON_HEADERS
10-
types.hpp
11-
utils.hpp
12-
platform_detection.hpp
13-
error_handling.hpp
14-
)
12+
set(COMMON_HEADERS types.hpp utils.hpp platform_detection.hpp
13+
error_handling.hpp)
1514

1615
# Header-only library
1716
add_library(${PROJECT_NAME} INTERFACE)
@@ -20,27 +19,24 @@ add_library(${PROJECT_NAME} INTERFACE)
2019
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_20)
2120

2221
# Include directories
23-
target_include_directories(${PROJECT_NAME}
24-
INTERFACE
25-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
26-
$<INSTALL_INTERFACE:include>
27-
)
22+
target_include_directories(
23+
${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
24+
$<INSTALL_INTERFACE:include>)
2825

2926
# Installation
30-
install(TARGETS ${PROJECT_NAME}
31-
EXPORT ${PROJECT_NAME}Targets
32-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
33-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
34-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
35-
)
27+
install(
28+
TARGETS ${PROJECT_NAME}
29+
EXPORT ${PROJECT_NAME}Targets
30+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
31+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
32+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3633

3734
install(FILES ${COMMON_HEADERS}
38-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/atom/sysinfo/common
39-
)
35+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/atom/sysinfo/common)
4036

4137
# Export targets
42-
install(EXPORT ${PROJECT_NAME}Targets
43-
FILE ${PROJECT_NAME}Targets.cmake
44-
NAMESPACE atom::sysinfo::
45-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
46-
)
38+
install(
39+
EXPORT ${PROJECT_NAME}Targets
40+
FILE ${PROJECT_NAME}Targets.cmake
41+
NAMESPACE atom::sysinfo::
42+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

atom/sysinfo/src/battery/API_REFERENCE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct BatteryInfo {
5858
### Enumerations
5959
6060
#### BatteryError
61+
6162
```cpp
6263
enum class BatteryError {
6364
NOT_PRESENT, // Battery not detected
@@ -69,6 +70,7 @@ enum class BatteryError {
6970
```
7071

7172
#### BatteryChemistry
73+
7274
```cpp
7375
enum class BatteryChemistry {
7476
UNKNOWN,
@@ -82,6 +84,7 @@ enum class BatteryChemistry {
8284
```
8385
8486
#### PowerState
87+
8588
```cpp
8689
enum class PowerState {
8790
UNKNOWN,
@@ -94,6 +97,7 @@ enum class PowerState {
9497
```
9598

9699
#### PowerPlan
100+
97101
```cpp
98102
enum class PowerPlan {
99103
BALANCED,
@@ -107,6 +111,7 @@ enum class PowerPlan {
107111
```
108112
109113
#### AlertType
114+
110115
```cpp
111116
enum class AlertType {
112117
LOW_BATTERY,
@@ -127,21 +132,27 @@ enum class AlertType {
127132
### Battery Information Retrieval
128133

129134
#### getBatteryInfo()
135+
130136
```cpp
131137
auto getBatteryInfo() -> std::optional<BatteryInfo>;
132138
```
139+
133140
Gets basic battery information. Returns `std::nullopt` if no battery is present or accessible.
134141

135142
#### getDetailedBatteryInfo()
143+
136144
```cpp
137145
auto getDetailedBatteryInfo() -> BatteryResult;
138146
```
147+
139148
Gets detailed battery information including manufacturer, model, and advanced metrics. Returns either `BatteryInfo` or `BatteryError`.
140149

141150
#### getAllBatteries()
151+
142152
```cpp
143153
auto getAllBatteries() -> MultiBatteryInfo;
144154
```
155+
145156
Gets information for all batteries in the system. Useful for laptops with multiple batteries.
146157

147158
## Classes
@@ -163,6 +174,7 @@ public:
163174
```
164175
165176
**Usage Example:**
177+
166178
```cpp
167179
BatteryMonitor::startMonitoring([](const BatteryInfo& info) {
168180
std::cout << "Battery: " << info.batteryLifePercent << "%" << std::endl;
@@ -193,6 +205,7 @@ public:
193205
```
194206
195207
**Usage Example:**
208+
196209
```cpp
197210
auto& manager = BatteryManager::getInstance();
198211
manager.setAlertCallback([](AlertType type, const BatteryInfo& info) {
@@ -218,6 +231,7 @@ public:
218231
```
219232
220233
**Usage Example:**
234+
221235
```cpp
222236
// Set power plan based on battery level
223237
auto batteryInfo = getBatteryInfo();
@@ -277,18 +291,21 @@ public:
277291
## Platform Support
278292
279293
### Windows
294+
280295
- Full support via Windows API and WMI
281296
- Advanced battery information through device APIs
282297
- Power plan management through Windows power APIs
283298
- Thermal information where available
284299
285300
### macOS
301+
286302
- IOKit integration for comprehensive battery data
287303
- Power source information through IOPowerSources
288304
- Limited power plan control (macOS manages power automatically)
289305
- Thermal monitoring through system APIs
290306
291307
### Linux
308+
292309
- sysfs integration for battery information
293310
- UPower support where available
294311
- powerprofilesctl integration for power plan management
Lines changed: 58 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cmake_minimum_required(VERSION 3.20)
2-
project(atom_sysinfo_battery VERSION 1.0.0 LANGUAGES CXX)
2+
project(
3+
atom_sysinfo_battery
4+
VERSION 1.0.0
5+
LANGUAGES CXX)
36

47
# Set C++ standard
58
set(CMAKE_CXX_STANDARD 20)
@@ -9,117 +12,100 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
912
find_package(spdlog REQUIRED)
1013

1114
# Define the library
12-
set(BATTERY_SOURCES
13-
battery.cpp
14-
common.cpp
15-
)
15+
set(BATTERY_SOURCES battery.cpp common.cpp)
1616

17-
set(BATTERY_HEADERS
18-
battery.hpp
19-
common.hpp
20-
)
17+
set(BATTERY_HEADERS battery.hpp common.hpp)
2118

2219
# Add platform-specific sources
2320
if(WIN32)
24-
list(APPEND BATTERY_SOURCES platform/windows.cpp)
25-
list(APPEND BATTERY_HEADERS platform/windows.hpp)
21+
list(APPEND BATTERY_SOURCES platform/windows.cpp)
22+
list(APPEND BATTERY_HEADERS platform/windows.hpp)
2623
elseif(UNIX AND NOT APPLE)
27-
list(APPEND BATTERY_SOURCES platform/linux.cpp)
28-
list(APPEND BATTERY_HEADERS platform/linux.hpp)
24+
list(APPEND BATTERY_SOURCES platform/linux.cpp)
25+
list(APPEND BATTERY_HEADERS platform/linux.hpp)
2926
elseif(APPLE)
30-
list(APPEND BATTERY_SOURCES platform/macos.cpp)
31-
list(APPEND BATTERY_HEADERS platform/macos.hpp)
27+
list(APPEND BATTERY_SOURCES platform/macos.cpp)
28+
list(APPEND BATTERY_HEADERS platform/macos.hpp)
3229
endif()
3330

3431
# Create the library
3532
add_library(atom_sysinfo_battery ${BATTERY_SOURCES} ${BATTERY_HEADERS})
3633

3734
# Set target properties
38-
set_target_properties(atom_sysinfo_battery PROPERTIES
39-
VERSION ${PROJECT_VERSION}
40-
SOVERSION 1
41-
CXX_STANDARD 20
42-
CXX_STANDARD_REQUIRED ON
43-
)
35+
set_target_properties(
36+
atom_sysinfo_battery
37+
PROPERTIES VERSION ${PROJECT_VERSION}
38+
SOVERSION 1
39+
CXX_STANDARD 20
40+
CXX_STANDARD_REQUIRED ON)
4441

4542
# Include directories
46-
target_include_directories(atom_sysinfo_battery
47-
PUBLIC
48-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
49-
$<INSTALL_INTERFACE:include>
50-
PRIVATE
51-
${CMAKE_CURRENT_SOURCE_DIR}
52-
)
43+
target_include_directories(
44+
atom_sysinfo_battery
45+
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
46+
$<INSTALL_INTERFACE:include>
47+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
5348

5449
# Link libraries
55-
target_link_libraries(atom_sysinfo_battery
56-
PUBLIC
57-
spdlog::spdlog
58-
)
50+
target_link_libraries(atom_sysinfo_battery PUBLIC spdlog::spdlog)
5951

6052
# Platform-specific libraries
6153
if(WIN32)
62-
target_link_libraries(atom_sysinfo_battery PRIVATE setupapi powrprof)
54+
target_link_libraries(atom_sysinfo_battery PRIVATE setupapi powrprof)
6355
elseif(APPLE)
64-
find_library(IOKIT_FRAMEWORK IOKit)
65-
find_library(COREFOUNDATION_FRAMEWORK CoreFoundation)
66-
target_link_libraries(atom_sysinfo_battery PRIVATE
67-
${IOKIT_FRAMEWORK}
68-
${COREFOUNDATION_FRAMEWORK}
69-
)
56+
find_library(IOKIT_FRAMEWORK IOKit)
57+
find_library(COREFOUNDATION_FRAMEWORK CoreFoundation)
58+
target_link_libraries(atom_sysinfo_battery
59+
PRIVATE ${IOKIT_FRAMEWORK} ${COREFOUNDATION_FRAMEWORK})
7060
endif()
7161

7262
# Compiler-specific options
7363
if(MSVC)
74-
target_compile_options(atom_sysinfo_battery PRIVATE /W4)
64+
target_compile_options(atom_sysinfo_battery PRIVATE /W4)
7565
else()
76-
target_compile_options(atom_sysinfo_battery PRIVATE -Wall -Wextra -Wpedantic)
66+
target_compile_options(atom_sysinfo_battery PRIVATE -Wall -Wextra -Wpedantic)
7767
endif()
7868

7969
# Install targets
80-
install(TARGETS atom_sysinfo_battery
81-
EXPORT atom_sysinfo_batteryTargets
82-
LIBRARY DESTINATION lib
83-
ARCHIVE DESTINATION lib
84-
RUNTIME DESTINATION bin
85-
INCLUDES DESTINATION include
86-
)
87-
88-
install(FILES ${BATTERY_HEADERS}
89-
DESTINATION include/atom/sysinfo/battery
90-
)
70+
install(
71+
TARGETS atom_sysinfo_battery
72+
EXPORT atom_sysinfo_batteryTargets
73+
LIBRARY DESTINATION lib
74+
ARCHIVE DESTINATION lib
75+
RUNTIME DESTINATION bin
76+
INCLUDES
77+
DESTINATION include)
78+
79+
install(FILES ${BATTERY_HEADERS} DESTINATION include/atom/sysinfo/battery)
9180

9281
# Export targets
93-
install(EXPORT atom_sysinfo_batteryTargets
94-
FILE atom_sysinfo_batteryTargets.cmake
95-
NAMESPACE atom::
96-
DESTINATION lib/cmake/atom_sysinfo_battery
97-
)
82+
install(
83+
EXPORT atom_sysinfo_batteryTargets
84+
FILE atom_sysinfo_batteryTargets.cmake
85+
NAMESPACE atom::
86+
DESTINATION lib/cmake/atom_sysinfo_battery)
9887

9988
# Create config file
10089
include(CMakePackageConfigHelpers)
10190
write_basic_package_version_file(
102-
atom_sysinfo_batteryConfigVersion.cmake
103-
VERSION ${PROJECT_VERSION}
104-
COMPATIBILITY AnyNewerVersion
105-
)
91+
atom_sysinfo_batteryConfigVersion.cmake
92+
VERSION ${PROJECT_VERSION}
93+
COMPATIBILITY AnyNewerVersion)
10694

10795
configure_package_config_file(
108-
${CMAKE_CURRENT_SOURCE_DIR}/atom_sysinfo_battery_config.cmake.in
109-
${CMAKE_CURRENT_BINARY_DIR}/atom_sysinfo_batteryConfig.cmake
110-
INSTALL_DESTINATION lib/cmake/atom_sysinfo_battery
111-
)
96+
${CMAKE_CURRENT_SOURCE_DIR}/atom_sysinfo_battery_config.cmake.in
97+
${CMAKE_CURRENT_BINARY_DIR}/atom_sysinfo_batteryConfig.cmake
98+
INSTALL_DESTINATION lib/cmake/atom_sysinfo_battery)
11299

113-
install(FILES
114-
${CMAKE_CURRENT_BINARY_DIR}/atom_sysinfo_batteryConfig.cmake
115-
${CMAKE_CURRENT_BINARY_DIR}/atom_sysinfo_batteryConfigVersion.cmake
116-
DESTINATION lib/cmake/atom_sysinfo_battery
117-
)
100+
install(
101+
FILES ${CMAKE_CURRENT_BINARY_DIR}/atom_sysinfo_batteryConfig.cmake
102+
${CMAKE_CURRENT_BINARY_DIR}/atom_sysinfo_batteryConfigVersion.cmake
103+
DESTINATION lib/cmake/atom_sysinfo_battery)
118104

119105
# Add subdirectories
120106
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/examples)
121-
add_subdirectory(examples)
107+
add_subdirectory(examples)
122108
endif()
123109
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests)
124-
add_subdirectory(tests)
110+
add_subdirectory(tests)
125111
endif()

0 commit comments

Comments
 (0)