Skip to content

Commit d5ecbd5

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

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-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+
setDatasetDefined(res);
449452
return res;
450453
}
451454

include/openPMD/backend/BaseRecordComponent.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ namespace internal
4949
* instead defined via light-weight attributes.
5050
*/
5151
bool m_isConstant = false;
52+
/*
53+
* ... document this ...
54+
*/
55+
bool m_datasetDefined = false;
5256

5357
BaseRecordComponentData(BaseRecordComponentData const &) = delete;
5458
BaseRecordComponentData(BaseRecordComponentData &&) = delete;
@@ -114,6 +118,10 @@ class BaseRecordComponent : virtual public Attributable
114118
return dynamic_cast<Data_t &>(*m_attri);
115119
}
116120

121+
void setDatasetDefined(Data_t &);
122+
123+
bool datasetDefined() const;
124+
117125
BaseRecordComponent();
118126
}; // BaseRecordComponent
119127

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+
// setDatasetDefined(*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+
setDatasetDefined(res);
130133
return res;
131134
}
132135
}; // PatchRecordComponent

src/backend/BaseRecordComponent.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,15 @@ BaseRecordComponent::BaseRecordComponent()
9191
std::make_shared<internal::BaseRecordComponentData>());
9292
}
9393

94+
void BaseRecordComponent::setDatasetDefined(
95+
internal::BaseRecordComponentData &data)
96+
{
97+
data.m_datasetDefined = true;
98+
}
99+
100+
bool BaseRecordComponent::datasetDefined() const
101+
{
102+
auto & data = get();
103+
return data.m_datasetDefined;
104+
}
94105
} // namespace openPMD

0 commit comments

Comments
 (0)