@@ -45,7 +45,7 @@ namespace auxiliary::detail
4545#undef OPENPMD_ENUMERATE_TYPES
4646} // namespace auxiliary::detail
4747
48- enum class EnqueuePolicy
48+ enum class EnqueuePolicy : std:: uint8_t
4949{
5050 Defer,
5151 Immediate
@@ -73,12 +73,16 @@ class ConfigureLoadStore
7373
7474 auto deferFlush (Attributable &);
7575
76+ auto getOffset () -> Offset const &;
77+ auto getExtent () -> Extent const &;
78+
7679 // The below methods return void.
7780 // For chaining calls, they should return *this, but this class right
7881 // here is going to be somewhere in the inheritance chain, and the final
7982 // class should be returned. Could be solved more elegantly with CRT,
8083 // but that blows up compile-time, so we make internal void functions
8184 // and then repeat them in the final classes.
85+ // (e.g. ConfigureLoadStoreFromBuffer::offset())
8286
8387 void offset_impl (Offset);
8488 void extent_impl (Extent);
@@ -100,9 +104,7 @@ class ConfigureLoadStore
100104public:
101105 using this_t = ConfigureLoadStore;
102106
103- auto getOffset () -> Offset const &;
104- auto getExtent () -> Extent const &;
105-
107+ // Configuration methods (always available)
106108 auto offset (Offset offset) -> this_t &
107109 {
108110 offset_impl (std::move (offset));
@@ -113,46 +115,37 @@ class ConfigureLoadStore
113115 extent_impl (std::move (extent));
114116 return *this ;
115117 }
118+
116119 /*
117120 * If the type is non-const, then the return type should be
118- * ConfigureLoadStoreFromBuffer<>, ...
121+ * ConfigureLoadStoreFromBuffer, but if it is a const type, Load operations
122+ * make no sense, so the return type should be
123+ * ConfigureStoreChunkFromBuffer<>.
119124 */
120125 template <typename T>
121- struct shared_ptr_return_type_impl
122- {
123- using return_type = openPMD::ConfigureLoadStoreFromBuffer;
124- using normalize_pointer_type = std::shared_ptr<std::remove_extent_t <T>>;
125- };
126- /*
127- * ..., but if it is a const type, Load operations make no sense, so the
128- * return type should be ConfigureStoreChunkFromBuffer<>.
129- */
130- template <typename T>
131- struct shared_ptr_return_type_impl <T const >
132- {
133- using return_type = openPMD::ConfigureStoreChunkFromBuffer;
134- using normalize_pointer_type =
135- std::shared_ptr<std::remove_extent_t <T> const >;
136- };
137-
138- template <typename T>
139- using shared_ptr_return_type = typename shared_ptr_return_type_impl<
140- std::remove_extent_t <T>>::return_type;
126+ using shared_ptr_return_type = std::conditional_t <
127+ std::is_const_v<T>,
128+ ConfigureStoreChunkFromBuffer,
129+ ConfigureLoadStoreFromBuffer>;
141130 template <typename T>
142- using shared_ptr_normalized_type = typename shared_ptr_return_type_impl<
143- std::remove_extent_t <T>>::normalized_pointer_type;
131+ using shared_ptr_normalized_type = std::conditional_t <
132+ std::is_const_v<T>,
133+ std::shared_ptr<std::remove_extent_t <T> const >,
134+ std::shared_ptr<std::remove_extent_t <T>>>;
144135
145136 /*
146137 * As loading into unique pointer types makes no sense, the case is
147138 * simpler for unique pointers. Just remove the array extents here.
139+ * (Our interface wrappers still support const-type unique pointers,
140+ * but the internal logic does not handle them separately.)
148141 */
149142 template <typename T>
150143 using unique_ptr_return_type = openPMD::ConfigureStoreChunkFromBuffer;
151144 template <typename T>
152145 using unique_ptr_normalized_type =
153146 UniquePtrWithLambda<std::remove_extent_t <T>>;
154147
155- // @todo rvalue references..?
148+ // Buffer specification methods (return specialized configurations)
156149 template <typename T>
157150 auto withSharedPtr (std::shared_ptr<T>) -> shared_ptr_return_type<T>;
158151 template <typename T>
@@ -167,6 +160,7 @@ class ConfigureLoadStore
167160 auxiliary::IsContiguousContainer_v<T_ContiguousContainer>,
168161 shared_ptr_return_type<typename T_ContiguousContainer::value_type>>;
169162
163+ // Enqueue methods (deferred execution)
170164 template <typename T>
171165 [[nodiscard]] auto enqueueStore () -> DynamicMemoryView<T>;
172166 // definition for this one is in RecordComponent.tpp since it needs the
@@ -178,12 +172,13 @@ class ConfigureLoadStore
178172 [[nodiscard]] auto enqueueLoad ()
179173 -> auxiliary::DeferredComputation<std::shared_ptr<T>>;
180174
181- template <typename T>
182- [[nodiscard]] auto load (EnqueuePolicy) -> std::shared_ptr<T>;
183-
184175 [[nodiscard]] auto enqueueLoadVariant () -> auxiliary::DeferredComputation<
185176 auxiliary::detail::shared_ptr_dataset_types>;
186177
178+ // Direct execution methods (with EnqueuePolicy)
179+ template <typename T>
180+ [[nodiscard]] auto load (EnqueuePolicy) -> std::shared_ptr<T>;
181+
187182 [[nodiscard]] auto loadVariant (EnqueuePolicy)
188183 -> auxiliary::detail::shared_ptr_dataset_types;
189184};
@@ -208,9 +203,12 @@ class ConfigureStoreChunkFromBuffer : public ConfigureLoadStore
208203 // and then repeat them in the final classes.
209204 void memorySelection_impl (MemorySelection);
210205
206+ auto storeChunkConfig () -> internal::LoadStoreConfigWithBuffer;
207+
211208public:
212209 using this_t = ConfigureStoreChunkFromBuffer;
213210
211+ // Configuration methods (always available)
214212 auto offset (Offset offset) -> this_t &
215213 {
216214 offset_impl (std::move (offset));
@@ -227,10 +225,10 @@ class ConfigureStoreChunkFromBuffer : public ConfigureLoadStore
227225 return *this ;
228226 }
229227
230- auto storeChunkConfig () -> internal::LoadStoreConfigWithBuffer;
231-
228+ // Enqueue method (deferred execution)
232229 auto enqueueStore () -> auxiliary::DeferredComputation<void>;
233230
231+ // Direct execution method (with EnqueuePolicy)
234232 auto store (EnqueuePolicy) -> void;
235233
236234 /* * This intentionally shadows the parent class's enqueueLoad methods in
@@ -266,6 +264,7 @@ class ConfigureLoadStoreFromBuffer : public ConfigureStoreChunkFromBuffer
266264public:
267265 using this_t = ConfigureLoadStoreFromBuffer;
268266
267+ // Configuration methods (always available)
269268 auto offset (Offset offset) -> this_t &
270269 {
271270 offset_impl (std::move (offset));
@@ -282,8 +281,10 @@ class ConfigureLoadStoreFromBuffer : public ConfigureStoreChunkFromBuffer
282281 return *this ;
283282 }
284283
284+ // Enqueue method (deferred execution)
285285 auto enqueueLoad () -> auxiliary::DeferredComputation<void>;
286286
287+ // Direct execution method (with EnqueuePolicy)
287288 auto load (EnqueuePolicy) -> void;
288289};
289290
0 commit comments