Skip to content

Commit

Permalink
BUG: Rework API for DataMap and DeepCopy in DataObject.
Browse files Browse the repository at this point in the history
We need to be able to report errors back up the call tree if possible.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
  • Loading branch information
imikejackson committed May 2, 2024
1 parent f0e0eb7 commit 9d8546b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/simplnx/DataStructure/AttributeMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ bool AttributeMatrix::canInsert(const DataObject* obj) const

const usize totalTuples = std::accumulate(m_TupleShape.cbegin(), m_TupleShape.cend(), static_cast<usize>(1), std::multiplies<>());
const usize incomingTupleCount = std::accumulate(arrayTupleShape.cbegin(), arrayTupleShape.cend(), static_cast<usize>(1), std::multiplies<>());

if(totalTuples != incomingTupleCount)
{
std::cout << "AttributeMatrix: CanInsert() Failed with object " << obj->getName() << ". totalTuples=" << totalTuples << " incomingTupleCount=" << incomingTupleCount << "\n";
}
return (totalTuples == incomingTupleCount);
}

Expand Down
4 changes: 4 additions & 0 deletions src/simplnx/DataStructure/DataMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ DataMap DataMap::deepCopy(const DataPath& parentCopyPath) const
{
const auto& dataObj = m_Map.at(key);
const auto copy = dataObj->deepCopy(parentCopyPath.createChildPath(dataObj->getName()));
if(copy == nullptr)
{
throw std::runtime_error(fmt::format("A deep copy request for parent '{}' failed on child object '{}' ", parentCopyPath.toString(), dataObj->getName()));
}
dataMap.m_Map[key] = copy;
}
return dataMap;
Expand Down

0 comments on commit 9d8546b

Please sign in to comment.