1 /** 2 * @file PathWatchimpl.hpp 3 * @brief Add interfaces added watch for the specified path 4 * 5 */ 6 #pragma once 7 8 #include <sdbusplus/message.hpp> 9 #include <sdbusplus/bus/match.hpp> 10 #include <vector> 11 #include "callback.hpp" 12 #include "data_types.hpp" 13 #include "pathwatch.hpp" 14 15 namespace phosphor 16 { 17 namespace dbus 18 { 19 namespace monitoring 20 { 21 22 template <typename DBusInterfaceType> void PathWatch<DBusInterfaceType>::start() 23 { 24 if (alreadyRan) 25 { 26 return; 27 } 28 // Watch for new interfaces added on this path. 29 DBusInterfaceType::addMatch( 30 sdbusplus::bus::match::rules::interfacesAdded(objectPath), 31 [this](auto& msg) 32 // *INDENT-OFF* 33 { (this->cb)(Context::SIGNAL, msg); }); 34 // *INDENT-ON* 35 36 alreadyRan = true; 37 } 38 39 template <typename DBusInterfaceType> 40 void PathWatch<DBusInterfaceType>::callback(Context ctx) 41 { 42 (this->cb)(ctx); 43 } 44 45 template <typename DBusInterfaceType> 46 void PathWatch<DBusInterfaceType>::callback(Context ctx, 47 sdbusplus::message::message& msg) 48 { 49 (this->cb)(ctx, msg); 50 } 51 } // namespace monitoring 52 } // namespace dbus 53 } // namespace phosphor 54