Skip to content

Commit

Permalink
Don't require unitSI when reading patch record component
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jun 30, 2023
1 parent 32aa2cb commit 08bdd4d
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/backend/PatchRecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,26 @@ void PatchRecordComponent::flush(

void PatchRecordComponent::read()
{
Parameter<Operation::READ_ATT> aRead;

aRead.name = "unitSI";
IOHandler()->enqueue(IOTask(this, aRead));
IOHandler()->flush(internal::defaultFlushParams);
if (auto val = Attribute(*aRead.resource).getOptional<double>();
val.has_value())
setUnitSI(val.value());
else
throw error::ReadError(
error::AffectedObject::Attribute,
error::Reason::UnexpectedContent,
{},
"Unexpected Attribute datatype for 'unitSI' (expected double, "
"found " +
datatypeToString(Attribute(*aRead.resource).dtype) + ")");

readAttributes(ReadMode::FullyReread); // this will set dirty() = false

if (containsAttribute("unitSI"))
{
if (auto val = getAttribute("unitSI").getOptional<double>();
val.has_value())
{
setUnitSI(val.value());
}
else
{
throw error::ReadError(
error::AffectedObject::Attribute,
error::Reason::UnexpectedContent,
{},
"Unexpected Attribute datatype for 'unitSI' (expected double, "
"found " +
datatypeToString(getAttribute("unitSI").dtype) + ")");
}
}
}

bool PatchRecordComponent::dirtyRecursive() const
Expand Down

0 comments on commit 08bdd4d

Please sign in to comment.