Skip to content

Commit bf4b6bb

Browse files
committed
Add m_datasetDefined
Todo: Merge functionality with openPMD#1316
1 parent fd672b1 commit bf4b6bb

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

include/openPMD/RecordComponent.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,15 @@ OPENPMD_protected
440440

441441
inline Data_t const &get() const
442442
{
443+
// cannot call this in the const overload
444+
// datasetDefined(*m_recordComponentData);
443445
return dynamic_cast<Data_t const &>(*m_attri);
444446
}
445447

446448
inline Data_t &get()
447449
{
448450
auto &res = dynamic_cast<Data_t &>(*m_attri);
451+
datasetDefined(res);
449452
return res;
450453
}
451454

include/openPMD/backend/BaseRecordComponent.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ namespace internal
4747
* instead defined via light-weight attributes.
4848
*/
4949
bool m_isConstant = false;
50+
/*
51+
* ... document this ...
52+
*/
53+
bool m_datasetDefined = false;
5054

5155
BaseRecordComponentData(BaseRecordComponentData const &) = delete;
5256
BaseRecordComponentData(BaseRecordComponentData &&) = delete;
@@ -112,6 +116,8 @@ class BaseRecordComponent : virtual public Attributable
112116
return dynamic_cast<Data_t &>(*m_attri);
113117
}
114118

119+
void datasetDefined(Data_t &);
120+
115121
BaseRecordComponent();
116122
}; // BaseRecordComponent
117123

include/openPMD/backend/PatchRecordComponent.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,15 @@ OPENPMD_protected
121121

122122
inline Data_t const &get() const
123123
{
124+
// cannot call this in the const overload
125+
// datasetDefined(*m_recordComponentData);
124126
return dynamic_cast<Data_t const &>(*m_attri);
125127
}
126128

127129
inline Data_t &get()
128130
{
129131
auto &res = dynamic_cast<Data_t &>(*m_attri);
132+
datasetDefined(res);
130133
return res;
131134
}
132135
}; // PatchRecordComponent

src/backend/BaseRecordComponent.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ BaseRecordComponent::BaseRecordComponent()
7171
std::make_shared<internal::BaseRecordComponentData>());
7272
}
7373

74+
void BaseRecordComponent::datasetDefined(
75+
internal::BaseRecordComponentData &data)
76+
{
77+
data.m_datasetDefined = true;
78+
}
7479
} // namespace openPMD

0 commit comments

Comments
 (0)