diff --git a/include/openPMD/RecordComponent.hpp b/include/openPMD/RecordComponent.hpp index ad23dcebf1..87301d39d1 100644 --- a/include/openPMD/RecordComponent.hpp +++ b/include/openPMD/RecordComponent.hpp @@ -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(*m_attri); } inline Data_t &get() { auto &res = dynamic_cast(*m_attri); + datasetDefined(res); return res; } diff --git a/include/openPMD/backend/BaseRecordComponent.hpp b/include/openPMD/backend/BaseRecordComponent.hpp index 56db7f3959..827af59f44 100644 --- a/include/openPMD/backend/BaseRecordComponent.hpp +++ b/include/openPMD/backend/BaseRecordComponent.hpp @@ -47,6 +47,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; @@ -112,6 +116,8 @@ class BaseRecordComponent : virtual public Attributable return dynamic_cast(*m_attri); } + void datasetDefined(Data_t &); + BaseRecordComponent(); }; // BaseRecordComponent diff --git a/include/openPMD/backend/PatchRecordComponent.hpp b/include/openPMD/backend/PatchRecordComponent.hpp index ba9eb0255b..62945fda2b 100644 --- a/include/openPMD/backend/PatchRecordComponent.hpp +++ b/include/openPMD/backend/PatchRecordComponent.hpp @@ -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(*m_attri); } inline Data_t &get() { auto &res = dynamic_cast(*m_attri); + datasetDefined(res); return res; } }; // PatchRecordComponent diff --git a/src/backend/BaseRecordComponent.cpp b/src/backend/BaseRecordComponent.cpp index ab470e4950..47243f00d6 100644 --- a/src/backend/BaseRecordComponent.cpp +++ b/src/backend/BaseRecordComponent.cpp @@ -71,4 +71,9 @@ BaseRecordComponent::BaseRecordComponent() std::make_shared()); } +void BaseRecordComponent::datasetDefined( + internal::BaseRecordComponentData &data) +{ + data.m_datasetDefined = true; +} } // namespace openPMD