Skip to content

Commit

Permalink
Add m_datasetDefined
Browse files Browse the repository at this point in the history
Todo: Merge functionality with openPMD#1316
  • Loading branch information
franzpoeschel committed Mar 24, 2023
1 parent f362e2c commit 54cd3bd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/openPMD/RecordComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,15 @@ OPENPMD_protected

inline Data_t const &get() const
{
// cannot call this in the const overload
// datasetDefined(*m_recordComponentData);
return dynamic_cast<Data_t const &>(*m_attri);
}

inline Data_t &get()
{
auto &res = dynamic_cast<Data_t &>(*m_attri);
datasetDefined(res);
return res;
}

Expand Down
6 changes: 6 additions & 0 deletions include/openPMD/backend/BaseRecordComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ namespace internal
* instead defined via light-weight attributes.
*/
bool m_isConstant = false;
/*
* ... document this ...
*/
bool m_datasetDefined = false;

BaseRecordComponentData(BaseRecordComponentData const &) = delete;
BaseRecordComponentData(BaseRecordComponentData &&) = delete;
Expand Down Expand Up @@ -114,6 +118,8 @@ class BaseRecordComponent : virtual public Attributable
return dynamic_cast<Data_t &>(*m_attri);
}

void datasetDefined(Data_t &);

BaseRecordComponent();
}; // BaseRecordComponent

Expand Down
3 changes: 3 additions & 0 deletions include/openPMD/backend/PatchRecordComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,15 @@ OPENPMD_protected

inline Data_t const &get() const
{
// cannot call this in the const overload
// datasetDefined(*m_recordComponentData);
return dynamic_cast<Data_t const &>(*m_attri);
}

inline Data_t &get()
{
auto &res = dynamic_cast<Data_t &>(*m_attri);
datasetDefined(res);
return res;
}
}; // PatchRecordComponent
Expand Down
5 changes: 5 additions & 0 deletions src/backend/BaseRecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,9 @@ BaseRecordComponent::BaseRecordComponent()
std::make_shared<internal::BaseRecordComponentData>());
}

void BaseRecordComponent::datasetDefined(
internal::BaseRecordComponentData &data)
{
data.m_datasetDefined = true;
}
} // namespace openPMD

0 comments on commit 54cd3bd

Please sign in to comment.