control: Store/use trigger enable functions on events

Create and store trigger enablement functions on the events based on the
trigger's configuration so that they can be enabled separately from when
the event is created. This will allow actions that load events to be
able to be parsed and then enabled when the action determines that the
events should be enabled. It also supports the use of SIGHUP to reload
the event configuration since the events JSON configuration must
successfully be loaded before the newly created events can be enabled in
place of the currently enabled events.

Change-Id: I31871ee1691d5e6b26fe16cde2a829c426ad6504
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json/event.cpp b/control/json/event.cpp
index 6e2c080..faa8c84 100644
--- a/control/json/event.cpp
+++ b/control/json/event.cpp
@@ -20,7 +20,7 @@
 #include "group.hpp"
 #include "manager.hpp"
 #include "sdbusplus.hpp"
-#include "triggers/trigger.hpp"
+#include "trigger.hpp"
 
 #include <fmt/format.h>
 
@@ -55,6 +55,14 @@
     setTriggers(jsonObj);
 }
 
+void Event::enable()
+{
+    for (const auto& trigger : _triggers)
+    {
+        trigger(getName(), _manager, _actions);
+    }
+}
+
 auto& Event::getAvailGroups()
 {
     static auto groups = Manager::getConfig<Group>(true);
@@ -235,7 +243,8 @@
         auto trigFunc = trigger::triggers.find(tClass);
         if (trigFunc != trigger::triggers.end())
         {
-            trigFunc->second(jsonTrig, getName(), _manager, _actions);
+            _triggers.emplace_back(
+                trigFunc->second(jsonTrig, getName(), _manager, _actions));
         }
         else
         {