summaryrefslogtreecommitdiff
path: root/chromeos-dbus-bindings/interface.h
diff options
context:
space:
mode:
authorPeter Qiu <zqiu@chromium.org>2014-11-02 16:00:46 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-03 22:09:54 +0000
commitdd885751db1da01f14c873484e1344378614108a (patch)
tree7a139d2ba2d5ba73823490d544d5682fa2b9f368 /chromeos-dbus-bindings/interface.h
parentb19e92f93f5cd73fa19a65f6a5b2205fe47fc41c (diff)
downloaddbus-binding-generator-dd885751db1da01f14c873484e1344378614108a.tar.gz
chromeos-dbus-bindings: Add support for DBus Property
It is desired to have this tool auto generate codes for DBus Property, both registering property to the DBus interface and prvoiding accessor functions for the property. This make adding DBus property much easier for the application developers. The accessor functions are named based on the property name (GetPropertyName and SetPropertyName). So the developer doesn't need to know the actual variable name being used. Note that DBus spec requires the user to specify access permission for the property, which is not currently supported by chrome-dbus (always read/write with write operation not supported). So this attribute is currently a noop. Example: <property name="InterfaceName" type="s" access="read"/> dbus_interface_->AddProperty "InterfaceName", &interface_name_); std::string GetInterfaceName() const { return interface_name_.GetValue.Get<std::string>(); } void SetInterfaceName( const std::string& interface_name) { interface_name_.SetValue(interface_name); } chromeos::dbus_utils::ExportedProperty<std::string> interface_name_; BUG=chromium:429027 TEST=unittests, emerge apmanager with DBus property binding Change-Id: Ib05af799afdbe63d740c75196f6967b2b11f1748 Reviewed-on: https://chromium-review.googlesource.com/226946 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Peter Qiu <zqiu@chromium.org> Tested-by: Peter Qiu <zqiu@chromium.org>
Diffstat (limited to 'chromeos-dbus-bindings/interface.h')
-rw-r--r--chromeos-dbus-bindings/interface.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/chromeos-dbus-bindings/interface.h b/chromeos-dbus-bindings/interface.h
index 04de002..627dce4 100644
--- a/chromeos-dbus-bindings/interface.h
+++ b/chromeos-dbus-bindings/interface.h
@@ -41,15 +41,27 @@ struct Interface {
std::string name;
std::vector<Argument> arguments;
};
+ struct Property {
+ Property(const std::string& name_in,
+ const std::string& type_in,
+ const std::string& access_in)
+ : name(name_in), type(type_in), access(access_in) {}
+ std::string name;
+ std::string type;
+ std::string access;
+ };
Interface() = default;
Interface(const std::string& name_in,
const std::vector<Method>& methods_in,
- const std::vector<Signal>& signals_in)
- : name(name_in), methods(methods_in), signals(signals_in) {}
+ const std::vector<Signal>& signals_in,
+ const std::vector<Property>& properties_in)
+ : name(name_in), methods(methods_in), signals(signals_in),
+ properties(properties_in) {}
std::string name;
std::vector<Method> methods;
std::vector<Signal> signals;
+ std::vector<Property> properties;
};
} // namespace chromeos_dbus_bindings