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 13, 2023
1 parent f5e9144 commit 9ad8bd5
Show file tree
Hide file tree
Showing 4 changed files with 26 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,11 +440,14 @@ OPENPMD_protected

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

inline Data_t &get()
{
setDatasetDefined(*m_recordComponentData);
return *m_recordComponentData;
}

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 @@ -166,6 +170,10 @@ class BaseRecordComponent : virtual public Attributable
Attributable::setData(m_baseRecordComponentData);
}

void setDatasetDefined(Data_t &);

bool datasetDefined() const;

BaseRecordComponent();
BaseRecordComponent(NoInit);
}; // 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 @@ -124,11 +124,14 @@ OPENPMD_protected

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

inline Data_t &get()
{
setDatasetDefined(*m_patchRecordComponentData);
return *m_patchRecordComponentData;
}

Expand Down
12 changes: 12 additions & 0 deletions src/backend/BaseRecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,16 @@ BaseRecordComponent::BaseRecordComponent() : Attributable(NoInit())

BaseRecordComponent::BaseRecordComponent(NoInit) : Attributable(NoInit())
{}

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 9ad8bd5

Please sign in to comment.