Skip to content

Commit 3a255b1

Browse files
committed
Commom hat::system_info base class
1 parent ed4e9ff commit 3a255b1

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

include/libhat/System.hpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33
#include <libhat/Defines.hpp>
44
#include <string>
55

6+
namespace hat {
7+
struct system_info {
8+
system_info(const system_info&) = delete;
9+
system_info& operator=(const system_info&) = delete;
10+
system_info(system_info&&) = delete;
11+
system_info& operator=(system_info&&) = delete;
12+
protected:
13+
system_info();
14+
};
15+
}
16+
617
#if defined(LIBHAT_X86)
718
namespace hat {
819

9-
struct system_info_x86 {
20+
struct system_info_x86 : hat::system_info {
1021
std::string cpu_vendor{};
1122
std::string cpu_brand{};
1223
struct {
@@ -23,34 +34,29 @@ namespace hat {
2334
bool popcnt;
2435
bool bmi;
2536
} extensions{};
26-
27-
system_info_x86(const system_info_x86&) = delete;
28-
system_info_x86& operator=(const system_info_x86&) = delete;
2937
private:
3038
system_info_x86();
3139
friend const system_info_x86& get_system();
3240
static const system_info_x86 instance;
3341
};
3442

35-
using system_info = system_info_x86;
43+
using system_info_impl = system_info_x86;
3644
}
3745
#elif defined(LIBHAT_ARM)
3846
namespace hat {
3947

40-
struct system_info_arm {
41-
system_info_arm(const system_info_arm&) = delete;
42-
system_info_arm& operator=(const system_info_arm&) = delete;
48+
struct system_info_arm : hat::system_info {
4349
private:
4450
system_info_arm() = default;
4551
friend const system_info_arm& get_system();
4652
static const system_info_arm instance;
4753
};
4854

49-
using system_info = system_info_arm;
55+
using system_info_impl = system_info_arm;
5056
}
5157
#endif
5258

5359
namespace hat {
5460

55-
const system_info& get_system();
61+
const system_info_impl& get_system();
5662
}

src/System.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace hat {
44

5-
const system_info system_info::instance{};
6-
const system_info& get_system() {
7-
return system_info::instance;
5+
system_info::system_info() {}
6+
7+
const system_info_impl system_info_impl::instance{};
8+
const system_info_impl& get_system() {
9+
return system_info_impl::instance;
810
}
911
}

0 commit comments

Comments
 (0)