本文整理汇总了C++中VariantType::ambPropertyName方法的典型用法代码示例。如果您正苦于以下问题:C++ VariantType::ambPropertyName方法的具体用法?C++ VariantType::ambPropertyName怎么用?C++ VariantType::ambPropertyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariantType
的用法示例。
在下文中一共展示了VariantType::ambPropertyName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleMyMethodCall
//.........这里部分代码省略.........
}
auto time = AbstractDBusInterface::getProperty(connection, sender, object_path, ifaceName, "Time", nullptr, iface);
auto zone = AbstractDBusInterface::getProperty(connection, sender, object_path, ifaceName, "Zone", nullptr, iface);
g_variant_builder_add(&builder, "{sv}", "Time", g_variant_new("v", time));
g_variant_builder_add(&builder, "{sv}", "Zone", g_variant_new("v", zone));
g_dbus_method_invocation_return_value(invocation, g_variant_new("(a{sv})", &builder));
return;
}
else if(method == "Set")
{
gchar* ifaceName = nullptr;
gchar* propName = nullptr;
GVariant* value;
g_variant_get(parameters, "(ssv)", &ifaceName, &propName, &value);
AbstractDBusInterface::setProperty(connection, sender, object_path, ifaceName, propName, value, nullptr, iface,
[&invocation, &ifaceName](bool success, AsyncPropertyReply::Error error) {
if(success)
{
g_dbus_method_invocation_return_value(invocation, nullptr);
}
else
{
g_dbus_method_invocation_return_dbus_error(invocation, ifaceName, AsyncPropertyReply::errorToStr(error).c_str());
}
});
return;
}
}
else if(method == "GetHistory")
{
double beginTime = 0;
double endTime = 0;
g_variant_get(parameters, "(dd)", &beginTime, &endTime);
auto propertyMap = iface->getProperties();
PropertyList propertyList;
for(auto itr = propertyMap.begin(); itr != propertyMap.end(); itr++)
{
VariantType* prop = (*itr).second;
if(!contains(propertyList, prop->ambPropertyName()))
propertyList.push_back(prop->ambPropertyName());
}
std::string ifaceName = iface->interfaceName();
AsyncRangePropertyRequest request;
request.properties = propertyList;
request.timeBegin = beginTime;
request.timeEnd = endTime;
request.zone = iface->zone();
//request.sourceUuid = iface->source();
request.completed = [&invocation,&ifaceName](AsyncRangePropertyReply* r)
{
auto reply = amb::make_unique(r);
if(!reply->success)
{
stringstream str;
str<<"Error during request: "<<AsyncPropertyReply::errorToStr(reply->error);
ifaceName += ".Error";
g_dbus_method_invocation_return_dbus_error(invocation, ifaceName.c_str(), str.str().c_str());
return;
}
if(!reply->values.size())
{
ifaceName += ".Error";
g_dbus_method_invocation_return_dbus_error(invocation, ifaceName.c_str(), "No results");
return;
}
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{svd}"));
for(auto itr = reply->values.begin(); itr != reply->values.end(); itr++)
{
AbstractPropertyType* value = *itr;
g_variant_builder_add(&builder, "{svd}", value->name.c_str(), g_variant_ref(value->toVariant()),value->timestamp);
}
g_dbus_method_invocation_return_value(invocation,g_variant_new("(a{svd})",&builder));
};
iface->re->getRangePropertyAsync(request);
return;
}
g_dbus_method_invocation_return_error(invocation,G_DBUS_ERROR,G_DBUS_ERROR_UNKNOWN_METHOD, "Unknown method.");
}