PEL: Don't allow duplicate callouts

When adding callouts, check if the callout being added already exists.
If it does, don't add it and rather just update the priority of the
existing one to be the highest of the two.

Callouts are considered to be equal if their location code matches, or
if they have the same maintenance procedure, or if they have the same
symbolic FRU.

The change entails adding an operator== on the Callout object, as well
as an operator> so that the callout with the highest priority can be
determined.  Also use this new operator> in the sort of the callout list
that happens after a callout is added or changed.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I5ee148cc12e92f67fb3da233c3615e9665e95355
diff --git a/extensions/openpower-pels/callout.cpp b/extensions/openpower-pels/callout.cpp
index 0c45950..705b1e4 100644
--- a/extensions/openpower-pels/callout.cpp
+++ b/extensions/openpower-pels/callout.cpp
@@ -205,6 +205,54 @@
     }
 }
 
+bool Callout::operator==(const Callout& right) const
+{
+    if ((_locationCodeSize != 0) || (right.locationCodeSize() != 0))
+    {
+        return locationCode() == right.locationCode();
+    }
+
+    if (!_fruIdentity || !right.fruIdentity())
+    {
+        return false;
+    }
+
+    auto myProc = _fruIdentity->getMaintProc();
+    auto otherProc = right.fruIdentity()->getMaintProc();
+    if (myProc)
+    {
+        if (otherProc)
+        {
+            return *myProc == *otherProc;
+        }
+        return false;
+    }
+
+    auto myPN = _fruIdentity->getPN();
+    auto otherPN = right.fruIdentity()->getPN();
+    if (myPN && otherPN)
+    {
+        return *myPN == *otherPN;
+    }
+
+    return false;
+}
+
+bool Callout::operator>(const Callout& right) const
+{
+    // Treat all of the mediums the same
+    const std::map<std::uint8_t, int> priorities = {
+        {'H', 10}, {'M', 9}, {'A', 9}, {'B', 9}, {'C', 9}, {'L', 8}};
+
+    if (!priorities.contains(priority()) ||
+        !priorities.contains(right.priority()))
+    {
+        return false;
+    }
+
+    return priorities.at(priority()) > priorities.at(right.priority());
+}
+
 } // namespace src
 } // namespace pels
 } // namespace openpower