1 #include <sdbusplus/server/interface.hpp> 2 3 namespace sdbusplus 4 { 5 6 namespace server 7 { 8 9 namespace interface 10 { 11 12 interface::interface(sdbusplus::bus_t& bus, const char* path, 13 const char* interf, const sdbusplus::vtable_t* vtable, 14 void* context) : 15 _bus(get_busp(bus), bus.getInterface()), 16 _path(path), _interf(interf), _intf(bus.getInterface()), 17 _interface_added(false) 18 { 19 sd_bus_slot* slot = nullptr; 20 int r = _intf->sd_bus_add_object_vtable( 21 get_busp(_bus), &slot, _path.c_str(), _interf.c_str(), vtable, context); 22 if (r < 0) 23 { 24 throw exception::SdBusError(-r, "sd_bus_add_object_vtable"); 25 } 26 27 _slot = std::move(slot); 28 } 29 30 interface::~interface() 31 { 32 emit_removed(); 33 } 34 35 void interface::property_changed(const char* property) 36 { 37 std::array<const char*, 2> values = {property, nullptr}; 38 39 // Note: Converting to use _strv version, could also mock two pointer 40 // use-case explicitly. 41 _intf->sd_bus_emit_properties_changed_strv(get_busp(_bus), _path.c_str(), 42 _interf.c_str(), values.data()); 43 } 44 45 } // namespace interface 46 } // namespace server 47 } // namespace sdbusplus 48