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 Apr 11, 2023
1 parent e38bbfc commit 5128fea
Show file tree
Hide file tree
Showing 4 changed files with 25 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);
setDatasetDefined(res);
return res;
}

Expand Down
8 changes: 8 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,10 @@ class BaseRecordComponent : virtual public Attributable
return dynamic_cast<Data_t &>(*m_attri);
}

void setDatasetDefined(Data_t &);

bool datasetDefined() const;

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 @@ -122,12 +122,15 @@ OPENPMD_protected

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

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

void BaseRecordComponent::setDatasetDefined(
internal::BaseRecordComponentData &data)
{
data.m_datasetDefined = true;
}

bool BaseRecordComponent::datasetDefined() const
{
auto & data = get();
return data.m_datasetDefined;
}
} // namespace openPMD

0 comments on commit 5128fea

Please sign in to comment.