#
a0fe02ca |
| 10-Mar-2025 |
Alexander Hansen <alexander.hansen@9elements.com> |
aserver: constructor to initialize properties
Functions like 'emit_added()' do not work correctly if properties are not initialized. Often, the initial values for the properties of an interface are
aserver: constructor to initialize properties
Functions like 'emit_added()' do not work correctly if properties are not initialized. Often, the initial values for the properties of an interface are known, such as
- Software Version Interface - Software ActivationProgress Interface - Software ApplyTime Interface - ...
How was this previously handled?
- Write a wrapper class for the specific aserver class. This allows to initialize the properties, as they are protected members. Example [2]
- Write a wrapper class and provide methods to get/set the variables. This is done in [1]
- Set each property with a method call, which emits 'PropertyChanged' signal by default, not ideal. This also does not work if the interface is ever refactored to have additional properties.
To facilitate using these interfaces without having to write a wrapper class to inherit from them, and to avoid having to manually set each property, which can easily be forgotten, provide a constructor to allow for passing a struct with values for all the properties.
Tested: Unit tests pass, but still needs to be build-tested against openbmc/openbmc. The concern there is mostly due to an added template parameter.
References: [1] https://github.com/openbmc/sdbusplus/blob/da8574d5888b2c1622f5482a47adc7a12ffa0d0e/example/calculator-aserver.cpp#L44 [2] https://github.com/openbmc/phosphor-bmc-code-mgmt/blob/4983b138ea8fc70bd66fe4d30500e6252629fa5d/common/src/software.cpp#L29
Change-Id: I873cbca97ae16b19bfbf622303f4d52e2563a62c Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com> Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
show more ...
|