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