Skip to content

Commit

Permalink
Add warning is non-existent data is accessed in lsPointData
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed Jun 14, 2024
1 parent 848e813 commit 1b5c161
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/viennals/lsPointData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,23 @@ class PointData {
if (int i = getScalarDataIndex(searchLabel); i != -1) {
return &(scalarData[i]);
}
Logger::getInstance()
.addWarning("PointData attempted to access scalar data labeled '" +
searchLabel +
"', which does not exist. Returning nullptr instead.")
.print();
return nullptr;
}

const ScalarDataType *getScalarData(std::string searchLabel) const {
if (int i = getScalarDataIndex(searchLabel); i != -1) {
return &(scalarData[i]);
}
Logger::getInstance()
.addWarning("PointData attempted to access scalar data labeled '" +
searchLabel +
"', which does not exist. Returning nullptr instead.")
.print();
return nullptr;
}

Expand Down Expand Up @@ -146,13 +156,23 @@ class PointData {
if (int i = getVectorDataIndex(searchLabel); i != -1) {
return &(vectorData[i]);
}
Logger::getInstance()
.addWarning("PointData attempted to access scalar data labeled '" +
searchLabel +
"', which does not exist. Returning nullptr instead.")
.print();
return nullptr;
}

const VectorDataType *getVectorData(std::string searchLabel) const {
if (int i = getVectorDataIndex(searchLabel); i != -1) {
return &(vectorData[i]);
}
Logger::getInstance()
.addWarning("PointData attempted to access scalar data labeled '" +
searchLabel +
"', which does not exist. Returning nullptr instead.")
.print();
return nullptr;
}

Expand Down

0 comments on commit 1b5c161

Please sign in to comment.