Skip to content

Commit

Permalink
[DataEngine] FIX: SimpleDataEngine can use datatracker in doUpdate()
Browse files Browse the repository at this point in the history
  • Loading branch information
marques-bruno committed Oct 10, 2018
1 parent 16bfafb commit 87dab0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 5 additions & 5 deletions SofaKernel/framework/framework_test/core/DataEngine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ class SimpleTestEngine : public core::SimpleDataEngine
private:
void doUpdate() override
{
// SimpleDataEngines cannot check whether a datafield is dirty or not:
// all input fields must be considered dirty in update.
if (output.getValue() != NO_CHANGED)
output.setValue(NO_CHANGED);
else
// true only iff the DataTracker associated to the Data 'input' is Dirty
// that could only happen if 'input' was dirtied since last update
if( m_dataTracker.isDirty( input ) )
output.setValue(CHANGED);
else
output.setValue(NO_CHANGED);
}
};

Expand Down
14 changes: 10 additions & 4 deletions SofaKernel/framework/sofa/core/DataEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,23 @@ class SOFA_CORE_API SimpleDataEngine : public sofa::core::DataEngine
SimpleDataEngine() : Inherit1() {}
virtual ~SimpleDataEngine() {}

/// Updates your inputs and calls cleanDirty() for you.
/// User implementation moved to doUpdate()
virtual void update() final

virtual void updateAllInputs()
{
for(auto& input : getInputs())
{
static_cast<sofa::core::objectmodel::BaseData*>(input)
->updateIfDirty();
}
cleanDirty();
}
/// Updates your inputs and calls cleanDirty() for you.
/// User implementation moved to doUpdate()
virtual void update() final
{
updateAllInputs();
DDGNode::cleanDirty();
doUpdate();
m_dataTracker.clean();
}

/// Automatically adds the input fields to the datatracker
Expand Down

0 comments on commit 87dab0b

Please sign in to comment.