Confusing callback mechanism on Data #3397
Replies: 3 comments
-
Thank for sharing. If I remember correctly, All the DDG system was designed for lazy updates and this is why updates only occurs when data are accessed and not when the data are changed. The component's callback you are pointing at is part it and does not change this lazy-behavior logic. This design In addition to that there is also a class called DataCallback that is implementing the call of the callback function when the data is actually changed. ComponentState is automatically added as an output so it is possible to track that "some internal" value have changed and track the changes on "anything that is not a data" and trigger its update. So actually when you write: object.d_componentstate.updateIfDirty(); it updates the component "internal" state if it is dirty. If I remember correctly Bruno Marques made an implementation of of forwarding link to component so that each time you access a component you are sure you get the latest version of its data. BaseObjectDataCallbackTest object;
SmartLink<BaseObject> linkToObject {object} ;
EXPECT_FALSE(linkToObject->isInputDataChanged);
linkToObject->d_inputData.setValue(true);
EXPECT_TRUE(linkToObject->isInputDataChanged); But this was never merged. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@damienmarchal answered my comment. This discussion can be closed. |
Beta Was this translation helpful? Give feedback.
-
I was confused about the callback mechanism on a Data.
Let's take the example of this class:
I was expecting that the following test passes:
But if fails at the last line.
This is because none of the callback output has been called. In our example, there is no output, but
d_componentState
is always implicitly added as an output. So to make the test pass, I need to do:And for a less "hacky" test, I transformed
bool isInputDataChanged
tosofa::Data<bool> isInputDataChanged
and addedisInputDataChanged
as an output of the callback:In the end, the output is crucial to design a Data callback, but it was not that obvious to me.
I don't have a question or a suggestion. I am just sharing my experience. Feel free to comment or suggest an improvement.
Beta Was this translation helpful? Give feedback.
All reactions