control: Don't cache non-group properties

The code was previously adding every single D-Bus
path/interface/property of a service when Manager::addObjects() was
being used to cache D-Bus property values.  This was resulting in a lot
of extra items in the cache that fan control would never use.

To fix this, create a single static set of all of the D-Bus paths from
all of the Group objects, which would be the master list of all the
D-Bus paths fan control would ever care about.  Then, only add a
path/interface/property to the cache if that path is in that set.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I787c9c36b88d003fe9fe7ac1d517fbb5aa510e4e
diff --git a/control/json/manager.cpp b/control/json/manager.cpp
index 2351597..9825a32 100644
--- a/control/json/manager.cpp
+++ b/control/json/manager.cpp
@@ -501,6 +501,22 @@
 
 void Manager::insertFilteredObjects(ManagedObjects& ref)
 {
+    // Filter out objects that aren't part of a group
+    const auto& allGroupMembers = Group::getAllMembers();
+    auto it = ref.begin();
+
+    while (it != ref.end())
+    {
+        if (allGroupMembers.find(it->first) == allGroupMembers.end())
+        {
+            it = ref.erase(it);
+        }
+        else
+        {
+            it++;
+        }
+    }
+
     for (auto& [path, pathMap] : ref)
     {
         for (auto& [intf, intfMap] : pathMap)
@@ -543,11 +559,10 @@
     for (const auto& objMgrPath : objMgrPaths)
     {
         // Get all managed objects of service
-        // want to filter here...
         auto objects = util::SDBusPlus::getManagedObjects<PropertyVariantType>(
             _bus, service, objMgrPath);
 
-        // insert all objects but remove any NaN values
+        // insert all objects that are in groups but remove any NaN values
         insertFilteredObjects(objects);
     }
 }