Make containerId optional in the event json file
During the PDR exchange, normalization causes the container IDs of
remote entities to change. Therefore, checking for a predefined
container ID from a remote terminus for sensor events does not provide
any benefit. This commit adds support for optionally skipping the check
for remote container id for sensor events when needed.
Tested:
Unit tests passed.
Change-Id: I871044815194b7aed507c105ae04f1418e084de1
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
diff --git a/libpldmresponder/event_parser.hpp b/libpldmresponder/event_parser.hpp
index 7498c4c..471c151 100644
--- a/libpldmresponder/event_parser.hpp
+++ b/libpldmresponder/event_parser.hpp
@@ -28,28 +28,43 @@
pdr::EntityInstance entityInstance;
pdr::SensorOffset sensorOffset;
pdr::StateSetId stateSetid;
+ bool skipContainerId;
bool operator==(const StateSensorEntry& e) const
{
- return (
- (containerId == e.containerId) && (entityType == e.entityType) &&
- (entityInstance == e.entityInstance) &&
- (sensorOffset == e.sensorOffset) && (stateSetid == e.stateSetid));
+ if (!skipContainerId)
+ {
+ return ((containerId == e.containerId) &&
+ (entityType == e.entityType) &&
+ (entityInstance == e.entityInstance) &&
+ (sensorOffset == e.sensorOffset) &&
+ (stateSetid == e.stateSetid));
+ }
+ else
+ {
+ return ((entityType == e.entityType) &&
+ (entityInstance == e.entityInstance) &&
+ (sensorOffset == e.sensorOffset) &&
+ (stateSetid == e.stateSetid));
+ }
}
bool operator<(const StateSensorEntry& e) const
{
- return (
- (containerId < e.containerId) ||
- ((containerId == e.containerId) && (entityType < e.entityType)) ||
- ((containerId == e.containerId) && (entityType == e.entityType) &&
- (entityInstance < e.entityInstance)) ||
- ((containerId == e.containerId) && (entityType == e.entityType) &&
- (entityInstance == e.entityInstance) &&
- (sensorOffset < e.sensorOffset)) ||
- ((containerId == e.containerId) && (entityType == e.entityType) &&
- (entityInstance == e.entityInstance) &&
- (sensorOffset == e.sensorOffset) && (stateSetid < e.stateSetid)));
+ if (!skipContainerId)
+ {
+ return std::tie(entityType, entityInstance, containerId,
+ sensorOffset, stateSetid) <
+ std::tie(e.entityType, e.entityInstance, e.containerId,
+ e.sensorOffset, e.stateSetid);
+ }
+ else
+ {
+ return std::tie(entityType, entityInstance, sensorOffset,
+ stateSetid) <
+ std::tie(e.entityType, e.entityInstance, e.sensorOffset,
+ e.stateSetid);
+ }
}
};