xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Go to the documentation of this file.
1 #pragma once
5 #include <map>
6 #include <vector>
7 #include "architecture_id.h"
8 #include "object.h"
9 #include "ustring.h"
12 namespace 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) {}
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();}
32  xtd::architecture_id architecture() const noexcept {return architecture_;}
36  uint32_t core_count() const noexcept {return core_count_;}
40  bool is_64_bit() const noexcept {return is_64_bit_;}
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  }
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  }
61  xtd::ustring to_string() const noexcept {return architecture_string();}
63  private:
65  bool is_64_bit_ = false;
66  uint32_t core_count_ = 1;
67  mutable xtd::ustring architecture_string_;
68  };
69 }
xtd::architecture_id architecture() const noexcept
Gets a xtd::platform_id enumeration value that identifies the operating system platform.
Definition: processor.h:32
The processor architecture is ARM.
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
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Identifies the processor architecture, supported by an assembly.
Definition: architecture_id.h:16
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
uint32_t core_count() const noexcept
Gets the number of processors on the current machine.
Definition: processor.h:36
The processor architecture is unknown.
Contains xtd::architecture_id enum class.
Contains xtd::ustring class.
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:26
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
Represents information about a processor, such as the architecture. This class cannot be inherited...
Definition: processor.h:19
bool is_64_bit() const noexcept
Determines whether the current operating system is a 64-bit operating system.
Definition: processor.h:40
The processor architecture is x86 (Intel or amd).