motherboard.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_METRICS_MOTHERBOARD_H_
  5. #define COMPONENTS_METRICS_MOTHERBOARD_H_
  6. #include <string>
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. namespace metrics {
  9. class Motherboard final {
  10. public:
  11. enum class BiosType { kLegacy, kUefi };
  12. Motherboard();
  13. Motherboard(Motherboard&&);
  14. Motherboard(const Motherboard&) = delete;
  15. ~Motherboard();
  16. // The fields below provide details about Motherboard and BIOS on the system.
  17. //
  18. // A `nullopt_t` means that the property does not exist/could not be read.
  19. // A valid value could be an UTF-8 string with characters or an empty string.
  20. //
  21. // This `absl::optional` can be mapped directly to the optional proto message
  22. // field, where the message field is added only if there is a valid value.
  23. const absl::optional<std::string>& manufacturer() const {
  24. return manufacturer_;
  25. }
  26. const absl::optional<std::string>& model() const { return model_; }
  27. const absl::optional<std::string>& bios_manufacturer() const {
  28. return bios_manufacturer_;
  29. }
  30. const absl::optional<std::string>& bios_version() const {
  31. return bios_version_;
  32. }
  33. absl::optional<BiosType> bios_type() const { return bios_type_; }
  34. private:
  35. absl::optional<std::string> manufacturer_;
  36. absl::optional<std::string> model_;
  37. absl::optional<std::string> bios_manufacturer_;
  38. absl::optional<std::string> bios_version_;
  39. absl::optional<BiosType> bios_type_;
  40. };
  41. } // namespace metrics
  42. #endif // COMPONENTS_METRICS_MOTHERBOARD_H_