blob: bb1f7e7fe90c8cbfb156047056a8bc18975e3d11 [file] [log] [blame]
#ifndef PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_ACTION_HASH_H_
#define PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_ACTION_HASH_H_
#include <cstddef>
#include <tuple>
#include "safepower_agent.pb.h"
#include "absl/hash/hash.h"
#include "absl/strings/string_view.h"
namespace safepower_agent {
namespace internal {
inline auto MakeActionTuple(const safepower_agent_proto::Action& action) {
// LINT.IfChange(ActionFields)
return std::make_tuple(
action.action_type(), action.action_severity(),
absl::string_view(action.target_component().node_entity_tag()),
absl::string_view(action.target_component().name()));
// LINT.ThenChange(//depot/proto/safepower_agent.proto:ActionFields)
}
} // namespace internal
struct ActionHash {
size_t operator()(const safepower_agent_proto::Action& action) const {
return absl::HashOf(internal::MakeActionTuple(action));
}
};
struct ActionEq {
bool operator()(const safepower_agent_proto::Action& a,
const safepower_agent_proto::Action& b) const {
return internal::MakeActionTuple(a) == internal::MakeActionTuple(b);
}
};
} // namespace safepower_agent
#endif // PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_ACTION_HASH_H_