1*f84f1117SPatrick Williams<% 2*f84f1117SPatrick Williamsp_name = property.snake_case 3*f84f1117SPatrick Williamsp_tag = property.snake_case + "_t" 4*f84f1117SPatrick Williamsp_type = property.cppTypeParam(interface.name) 5*f84f1117SPatrick Williamsi_name = interface.classname 6*f84f1117SPatrick Williams%>\ 7*f84f1117SPatrick Williams static int _callback_get_${p_name}( 8*f84f1117SPatrick Williams sd_bus*, const char*, const char*, const char*, 9*f84f1117SPatrick Williams sd_bus_message* reply, void* context, 10*f84f1117SPatrick Williams sd_bus_error* error [[maybe_unused]]) 11*f84f1117SPatrick Williams { 12*f84f1117SPatrick Williams auto self = static_cast<${i_name}*>(context); 13*f84f1117SPatrick Williams 14*f84f1117SPatrick Williams try 15*f84f1117SPatrick Williams { 16*f84f1117SPatrick Williams auto m = sdbusplus::message_t{reply}; 17*f84f1117SPatrick Williams 18*f84f1117SPatrick Williams // Set up the transaction. 19*f84f1117SPatrick Williams server::transaction::set_id(m); 20*f84f1117SPatrick Williams 21*f84f1117SPatrick Williams // Get property value and add to message. 22*f84f1117SPatrick Williams if constexpr (server_details::has_get_property_msg<${p_tag}, 23*f84f1117SPatrick Williams Instance>) 24*f84f1117SPatrick Williams { 25*f84f1117SPatrick Williams auto v = self->${p_name}(m); 26*f84f1117SPatrick Williams static_assert(std::is_convertible_v<decltype(v), ${p_type}>, 27*f84f1117SPatrick Williams "Property doesn't convert to '${p_type}'."); 28*f84f1117SPatrick Williams m.append<${p_type}>(std::move(v)); 29*f84f1117SPatrick Williams } 30*f84f1117SPatrick Williams else 31*f84f1117SPatrick Williams { 32*f84f1117SPatrick Williams auto v = self->${p_name}(); 33*f84f1117SPatrick Williams static_assert(std::is_convertible_v<decltype(v), ${p_type}>, 34*f84f1117SPatrick Williams "Property doesn't convert to '${p_type}'."); 35*f84f1117SPatrick Williams m.append<${p_type}>(std::move(v)); 36*f84f1117SPatrick Williams } 37*f84f1117SPatrick Williams } 38*f84f1117SPatrick Williams % for e in property.errors: 39*f84f1117SPatrick Williams catch (const ${interface.errorNamespacedClass(e)}& e) 40*f84f1117SPatrick Williams { 41*f84f1117SPatrick Williams return sd_bus_error_set(error, e.name(), e.description()); 42*f84f1117SPatrick Williams } 43*f84f1117SPatrick Williams % endfor 44*f84f1117SPatrick Williams catch (const std::exception&) 45*f84f1117SPatrick Williams { 46*f84f1117SPatrick Williams self->_context().get_bus().set_current_exception( 47*f84f1117SPatrick Williams std::current_exception()); 48*f84f1117SPatrick Williams return -EINVAL; 49*f84f1117SPatrick Williams } 50*f84f1117SPatrick Williams 51*f84f1117SPatrick Williams return 1; 52*f84f1117SPatrick Williams } 53*f84f1117SPatrick Williams 54*f84f1117SPatrick Williams% if 'const' not in property.flags and 'readonly' not in property.flags: 55*f84f1117SPatrick Williams static int _callback_set_${p_name}( 56*f84f1117SPatrick Williams sd_bus*, const char*, const char*, const char*, 57*f84f1117SPatrick Williams sd_bus_message* value[[maybe_unused]], void* context [[maybe_unused]], 58*f84f1117SPatrick Williams sd_bus_error* error [[maybe_unused]]) 59*f84f1117SPatrick Williams { 60*f84f1117SPatrick Williams return -EINVAL; 61*f84f1117SPatrick Williams } 62*f84f1117SPatrick Williams% endif 63