Get an inventory property's value

Adds support for inventory manager to retrieve a property's value that
it hosts as input to condition tests. Utilizing a provided sdbusplus
server binding member function to get a property from the inventory
hosted interface, a property can be read from that interface within
inventory manager. After the property is read, the condition test is
performed and the resulting action(s) occur.

The only currently supported condition test for using a property from
within inventory manager is the `propertyIs` condition.

This is an example of the expected generated source to get a property
from within inventory manager:

make_filter(functor::propertyIs(
    "/system/chassis",
    "xyz.openbmc_project.Inventory.Decorator.CoolingType",
    "WaterCooled",
    true,
    "xyz.openbmc_project.Inventory.Manager",
    make_get_property<sdbusplus::xyz::openbmc_project::Inventory::
                      Decorator::server::CoolingType::PropertiesVariant>
    (
        functor::getProperty<sdbusplus::xyz::openbmc_project::
            Inventory::Decorator::server::CoolingType>
        (
                "/system/chassis",
                "xyz.openbmc_project.Inventory.Decorator.CoolingType",
                &sdbusplus::xyz::openbmc_project::Inventory::
                    Decorator::server::CoolingType::getPropertyByName,
                "WaterCooled"
        )
    )
))

Tested:
    Manually edited generated code to use property within inventory
    and actions occurred when condition passed
    Manually edited generated code to use property within inventory
    and actions did not run when condition failed
    Actions not run when get property function omitted

Change-Id: I094bbacbcdeb239d33cac343b2daeb5f86e0a58a
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/functor.cpp b/functor.cpp
index 90d713a..b8771d7 100644
--- a/functor.cpp
+++ b/functor.cpp
@@ -13,8 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include "config.h"
+
 #include "functor.hpp"
 
+#include "manager.hpp"
+
 #include <sdbusplus/bus.hpp>
 
 namespace phosphor
@@ -34,7 +38,8 @@
 }
 
 bool PropertyConditionBase::operator()(const std::string& path,
-                                       sdbusplus::bus::bus& bus, Manager&) const
+                                       sdbusplus::bus::bus& bus,
+                                       Manager& mgr) const
 {
     std::string host;
 
@@ -66,13 +71,25 @@
         }
 
         host = mapperResponse.begin()->first;
+    }
 
-        if (host == bus.get_unique_name())
+    // When the host service name is inventory manager, eval using
+    // a given `getProperty` function to retrieve a property value from
+    // an interface hosted by inventory manager.
+    if (host == BUSNAME)
+    {
+        try
         {
-            // TODO I can't call myself here.
+            return eval(mgr);
+        }
+        catch (const std::exception& e)
+        {
+            // Unable to find property on inventory manager,
+            // default condition to false.
             return false;
         }
     }
+
     auto hostCall = bus.new_method_call(
         host.c_str(), path.c_str(), "org.freedesktop.DBus.Properties", "Get");
     hostCall.append(_iface);