Skip to content

Commit

Permalink
Use deferred actions to remove the neighbor lists.
Browse files Browse the repository at this point in the history
Messages are now sent to the pipeline output to help the user understand what go deleted.
API was changed for DeleteDataAction to emit a warning if the target object does not exist

Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Apr 23, 2024
1 parent 6409474 commit f1132a1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/Geometry/ImageGeom.hpp"
#include "simplnx/Filter/Actions/DeleteDataAction.hpp"

#include "simplnx/Parameters/ArraySelectionParameter.hpp"
#include "simplnx/Parameters/AttributeMatrixSelectionParameter.hpp"
#include "simplnx/Parameters/BoolParameter.hpp"
Expand Down Expand Up @@ -423,7 +424,7 @@ IFilter::PreflightResult MinNeighbors::preflightImpl(const DataStructure& dataSt
{
ss.append(" " + featureNeighborList.toString() + "\n");
auto action = std::make_unique<DeleteDataAction>(featureNeighborList);
resultOutputActions.value().actions.emplace_back(std::move(action));
resultOutputActions.value().deferredActions.emplace_back(std::move(action));
}

// Inform users that the following arrays are going to be modified in place
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ IFilter::PreflightResult RemoveMinimumSizeFeaturesFilter::preflightImpl(const Da
{
ss.append(" " + featureNeighborList.toString() + "\n");
auto action = std::make_unique<DeleteDataAction>(featureNeighborList);
resultOutputActions.value().actions.emplace_back(std::move(action));
resultOutputActions.value().deferredActions.emplace_back(std::move(action));
}

// Inform users that the following arrays are going to be modified in place
Expand Down
2 changes: 1 addition & 1 deletion src/simplnx/Filter/Actions/DeleteDataAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Result<> TerminateNode(DataStructure& dataStructure, const DataPath& path, IData
DataObject* targetObject = dataStructure.getData(path);
if(targetObject == nullptr)
{
return {nonstd::make_unexpected(std::vector<Error>{{k_TargetNotFoundErrorCode, fmt::format("Trying to delete DataObject '{}' which does not exist.", path.getTargetName())}})};
return MakeWarningVoidResult(k_TargetNotFoundErrorCode, fmt::format("Trying to delete DataObject '{}' which does not exist.", path.getTargetName()));
}

dataStructure.removeData(targetObject->getId());
Expand Down
3 changes: 1 addition & 2 deletions src/simplnx/Utilities/DataGroupUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ bool RemoveInactiveObjects(DataStructure& dataStructure, const DataPath& feature
std::vector<DataPath> neighborListDataPaths = result.value();
for(const auto& neighborListDataPath : neighborListDataPaths)
{
messageHandler(
nx::core::IFilter::Message{nx::core::IFilter::Message::Type::Warning, fmt::format("NeighborList '{}' was removed from the DataStructure.", neighborListDataPath.toString())});
messageHandler(nx::core::IFilter::Message{nx::core::IFilter::Message::Type::Info, fmt::format("NeighborList '{}' was removed from the DataStructure.", neighborListDataPath.toString())});
dataStructure.removeData(neighborListDataPath);
}
}
Expand Down

0 comments on commit f1132a1

Please sign in to comment.