| #pragma once |
| |
| #include <iostream> |
| #include <string> |
| #include <string_view> |
| |
| namespace boot_time_monitor |
| { |
| /** @brief Tag identifying a BMC node. Used for grouping operations. */ |
| inline constexpr std::string_view kBootTimeTagBMC = "BMC"; |
| /** @brief Tag identifying a Host node. Used for grouping operations. */ |
| inline constexpr std::string_view kBootTimeTagHost = "Host"; |
| |
| /** |
| * @brief Represents the configuration for a specific node being monitored. |
| * |
| * This structure holds the unique name of a node (e.g., "host0", "bmc") and |
| * an optional tag (e.g., "Host", "BMC") used for grouping nodes. It provides |
| * comparison operators for use in containers like `std::map` and an output |
| * stream operator for easy printing. |
| */ |
| struct NodeConfig |
| { |
| /** |
| * @brief The unique identifier name for the node (e.g., "host0", "bmc"). |
| */ |
| std::string nodeName; |
| /** @brief An optional tag for grouping nodes (e.g., "Host", "BMC"). */ |
| std::string tag = ""; |
| |
| /** |
| * @brief Less-than comparison operator based on `nodeName`. |
| * @param other The NodeConfig to compare against. |
| * @return True if this nodeName is lexicographically less than |
| * other.nodeName. |
| */ |
| bool operator<(const NodeConfig& other) const |
| { |
| return nodeName < other.nodeName; |
| } |
| |
| /** |
| * @brief Equality comparison operator based on `nodeName`. |
| * @param other The NodeConfig to compare against. |
| * @return True if nodeNames are equal. |
| */ |
| bool operator==(const NodeConfig& other) const |
| { |
| return nodeName == other.nodeName; |
| } |
| |
| /** |
| * @brief Output stream operator for printing the NodeConfig. |
| * @param os The output stream. |
| * @param k The NodeConfig object to print. |
| * @return The output stream with the NodeConfig printed in the format: |
| * `{"<nodeName>", "<tag>"}`. |
| */ |
| friend std::ostream& operator<<(std::ostream& os, const NodeConfig& k) |
| { |
| os << "{\"" << k.nodeName << "\", \"" << k.tag << "\"}"; |
| return os; |
| } |
| }; |
| } // namespace boot_time_monitor |