Implement event rotating

Delete the oldest event of the same type
if a particular type of event reaches threshold.

Resolves openbmc/openbmc#2254

Change-Id: I2692193a027e82032f1d336515691de913bbb726
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/src/event_manager.cpp b/src/event_manager.cpp
index 9102137..2c09f35 100644
--- a/src/event_manager.cpp
+++ b/src/event_manager.cpp
@@ -62,6 +62,13 @@
     auto objPath =  std::string(OBJ_EVENT) + '/' + eventName + '/' +
                         std::to_string(id);
 
+    // check for capping of the events,if cap reached then erase the oldest
+    // event.
+    if (eventQueue.size() == MAX_EVENTS)
+    {
+        eventQueue.pop();
+    }
+
     eventQueue.emplace(std::make_unique<Entry>(
                        objPath,
                        ms, // Milliseconds since 1970