From 54cd3bd396cbda6f72219da7cd0687f548622760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 20 Mar 2023 16:46:29 +0100 Subject: [PATCH] Add m_datasetDefined Todo: Merge functionality with #1316 --- include/openPMD/RecordComponent.hpp | 3 +++ include/openPMD/backend/BaseRecordComponent.hpp | 6 ++++++ include/openPMD/backend/PatchRecordComponent.hpp | 3 +++ src/backend/BaseRecordComponent.cpp | 5 +++++ 4 files changed, 17 insertions(+) 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 fb00e2f49e..c7f80e2acc 100644 --- a/include/openPMD/backend/BaseRecordComponent.hpp +++ b/include/openPMD/backend/BaseRecordComponent.hpp @@ -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; @@ -114,6 +118,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 813927f63d..9ec6a00668 100644 --- a/src/backend/BaseRecordComponent.cpp +++ b/src/backend/BaseRecordComponent.cpp @@ -91,4 +91,9 @@ BaseRecordComponent::BaseRecordComponent() std::make_shared()); } +void BaseRecordComponent::datasetDefined( + internal::BaseRecordComponentData &data) +{ + data.m_datasetDefined = true; +} } // namespace openPMD