blob: 222164060f898f8f0cb65ba549583056bb952e82 [file] [log] [blame]
#ifndef PRODUCTION_SUSHID_SAFEPOWER_AGENT_ACTION_HASH_H_
#define PRODUCTION_SUSHID_SAFEPOWER_AGENT_ACTION_HASH_H_
#include <cstddef>
#include <tuple>
#include "safepower_agent.pb.h"
#include "absl/hash/hash.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(),
action.target_component().node_entity_tag(),
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_SUSHID_SAFEPOWER_AGENT_ACTION_HASH_H_