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>
7 files changed
tree: 7a139d2ba2d5ba73823490d544d5682fa2b9f368
  1. chromeos-dbus-bindings/