From 36ce07093b68b07513149577c209ae7a57ab356b Mon Sep 17 00:00:00 2001 From: Gabriele Contini <contini.mailing@gmail.com> Date: 周日, 15 3月 2020 16:26:21 +0800 Subject: [PATCH] Merge branch 'feature/pc_identifiers' into develop issues #2 #3 #14 #49 --- src/library/os/cpu_info.hpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/src/library/os/cpu_info.hpp b/src/library/os/cpu_info.hpp new file mode 100644 index 0000000..a35de10 --- /dev/null +++ b/src/library/os/cpu_info.hpp @@ -0,0 +1,39 @@ +/* + * cpu_info.h + * + * Created on: Dec 14, 2019 + * Author: devel + */ + +#ifndef SRC_LIBRARY_OS_CPU_INFO_H_ +#define SRC_LIBRARY_OS_CPU_INFO_H_ +#include <string> +namespace license { +namespace os { +typedef enum { BARE_TO_METAL, VMWARE, VIRTUALBOX, V_XEN, KVM, HV, V_OTHER } VIRTUALIZATION_DETAIL; + +/** + * Cpu informations + */ +class CpuInfo { +private: + bool is_hypervisor_set() const; + const std::string m_vendor; + const std::string m_brand; +public: + CpuInfo(); + virtual ~CpuInfo(); + /** + * Detect Virtual machine using hypervisor bit or the cpu vendor name. + * @return true if the cpu is detected to be a virtual cpu + */ + bool cpu_virtual() const; + uint32_t model() const; + const std::string& vendor() const { return m_vendor; } + const std::string& brand() const { return m_brand; } + VIRTUALIZATION_DETAIL virtualization_details() const; +}; + +} // namespace os +} // namespace license +#endif /* SRC_LIBRARY_OS_CPU_INFO_H_ */ -- Gitblit v1.9.1