summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/interface.md11
-rw-r--r--example/net/poettering/Calculator.interface.yaml2
-rw-r--r--tools/sdbusplus/property.py1
-rw-r--r--tools/sdbusplus/templates/interface.mako.server.cpp.in4
4 files changed, 15 insertions, 3 deletions
diff --git a/docs/interface.md b/docs/interface.md
index 1613021..f32bd3b 100644
--- a/docs/interface.md
+++ b/docs/interface.md
@@ -141,9 +141,12 @@ methods:
## Properties
A property must have the YAML property `name` and `type` and may optionally
-have `description`, `default`, and `errors`. The `default` defines the default
-value of the property. See the `Methods` section above for more information on
-errors.
+have `description`, `flags`, `default`, and `errors`. The `default` defines the
+default value of the property. See the `Methods` section above for more
+information on errors.
+The only current supported value for `flags` is `const`, which corresponds to
+SD_BUS_VTABLE_PROPERTY_CONST, making the property read-only via D-Bus but
+still writable by the app implementing it.
Example:
```
@@ -151,6 +154,8 @@ properties:
- name: CardsRemaining
type: uint32
default: 52
+ flags:
+ - const
description: >
The number of cards remaining in the deck.
errors:
diff --git a/example/net/poettering/Calculator.interface.yaml b/example/net/poettering/Calculator.interface.yaml
index af4dd1b..6e44093 100644
--- a/example/net/poettering/Calculator.interface.yaml
+++ b/example/net/poettering/Calculator.interface.yaml
@@ -53,6 +53,8 @@ properties:
- name: Status
type: enum[self.State]
default: Success
+ flags:
+ - const
description: >
The current state of the Calculator.
- name: Owner
diff --git a/tools/sdbusplus/property.py b/tools/sdbusplus/property.py
index 8465315..33c7e25 100644
--- a/tools/sdbusplus/property.py
+++ b/tools/sdbusplus/property.py
@@ -8,6 +8,7 @@ class Property(NamedElement, Renderer):
self.typeName = kwargs.pop('type', None)
self.cppTypeName = self.parse_cpp_type(self.typeName)
self.defaultValue = kwargs.pop('default', None)
+ self.flags = kwargs.pop('flags', [])
self.errors = kwargs.pop('errors', [])
super(Property, self).__init__(**kwargs)
diff --git a/tools/sdbusplus/templates/interface.mako.server.cpp.in b/tools/sdbusplus/templates/interface.mako.server.cpp.in
index aee5424..c8d5f65 100644
--- a/tools/sdbusplus/templates/interface.mako.server.cpp.in
+++ b/tools/sdbusplus/templates/interface.mako.server.cpp.in
@@ -142,8 +142,12 @@ ${ s.cpp_prototype(loader, interface=interface, ptype='vtable') }
details::${classname}::_property_${p.name}
.data(),
_callback_get_${p.name},
+ % if 'const' in p.flags:
+ vtable::property_::const_),
+ % else:
_callback_set_${p.name},
vtable::property_::emits_change),
+ %endif
% endfor
vtable::end()
};
OpenPOWER on IntegriCloud