xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
processor.h
Go to the documentation of this file.
1
4#pragma once
5#include <map>
6#include <vector>
7#include "architecture_id.h"
8#include "object.h"
9#include "ustring.h"
10
12namespace xtd {
19 class processor final : public object {
20 public:
21 processor(xtd::architecture_id architecture, bool is_64_bit, uint32_t core_count) : architecture_(architecture), is_64_bit_(is_64_bit), core_count_(core_count) {}
22
24 processor() = default;
25 processor(const processor&) = default;
26 processor& operator=(const processor&) = default;
27 friend std::ostream& operator <<(std::ostream& os, const processor& processor) noexcept {return os << processor.to_string();}
29
32 xtd::architecture_id architecture() const noexcept {return architecture_;}
33
36 uint32_t core_count() const noexcept {return core_count_;}
37
40 bool is_64_bit() const noexcept {return is_64_bit_;}
41
44 xtd::ustring name() const noexcept {
45 static std::map<xtd::architecture_id, xtd::ustring> processor_names {{architecture_id::x86, "Intel or AMD"}, {architecture_id::arm, "ARM"}, {architecture_id::unknown, "<Unknown>"}};
46 return processor_names[architecture_];
47 }
48
49 xtd::ustring architecture_string() const noexcept {
50 if (!architecture_string_.empty()) return architecture_string_;
51 architecture_string_ = ustring::format("{}", architecture_);
52 if (is_64_bit_) {
53 if (architecture_ == architecture_id::x86) architecture_string_ += "_";
54 architecture_string_ += "64";
55 }
56 return architecture_string_;
57 }
58
61 xtd::ustring to_string() const noexcept {return architecture_string();}
62
63 private:
65 bool is_64_bit_ = false;
66 uint32_t core_count_ = 1;
67 mutable xtd::ustring architecture_string_;
68 };
69}
Contains xtd::architecture_id enum class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:26
Represents information about a processor, such as the architecture. This class cannot be inherited.
Definition processor.h:19
uint32_t core_count() const noexcept
Gets the number of processors on the current machine.
Definition processor.h:36
xtd::architecture_id architecture() const noexcept
Gets a xtd::platform_id enumeration value that identifies the operating system platform.
Definition processor.h:32
xtd::ustring name() const noexcept
Gets the concatenated string representation of the platform identifier.
Definition processor.h:44
xtd::ustring to_string() const noexcept
Converts the value of this processor object to its equivalent string representation.
Definition processor.h:61
bool is_64_bit() const noexcept
Determines whether the current operating system is a 64-bit operating system.
Definition processor.h:40
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:48
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition ustring.h:689
architecture_id
Identifies the processor architecture, supported by an assembly.
Definition architecture_id.h:16
@ x86
The processor architecture is x86 (Intel or amd).
@ unknown
The processor architecture is unknown.
@ arm
The processor architecture is ARM.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Contains xtd::object class.
Contains xtd::ustring class.