1212namespace openPMD
1313{
1414class RecordComponent ;
15- template <typename Ptr_Type, typename ChildClass >
15+ template <typename Ptr_Type>
1616class ConfigureStoreChunkFromBuffer ;
1717template <typename Ptr_Type>
1818class ConfigureLoadStoreFromBuffer ;
@@ -41,6 +41,15 @@ namespace auxiliary::detail
4141 map_variant<as_shared_pointer, dataset_types>::type;
4242} // namespace auxiliary::detail
4343
44+ namespace auxiliary
45+ {
46+ template <typename possibly_void, typename alternative>
47+ using non_void_or = std::conditional_t <
48+ !std::is_void_v<possibly_void>,
49+ /* then*/ possibly_void,
50+ /* else*/ alternative>;
51+ } // namespace auxiliary
52+
4453enum class EnqueuePolicy
4554{
4655 Defer,
@@ -84,8 +93,7 @@ struct ConfigureLoadStoreCore
8493 template <typename T>
8594 struct shared_ptr_return_type_impl <T const >
8695 {
87- using type =
88- ConfigureStoreChunkFromBuffer<std::shared_ptr<T const >, void >;
96+ using type = ConfigureStoreChunkFromBuffer<std::shared_ptr<T const >>;
8997 };
9098
9199 template <typename T>
@@ -98,8 +106,7 @@ struct ConfigureLoadStoreCore
98106 */
99107 template <typename T>
100108 using unique_ptr_return_type = ConfigureStoreChunkFromBuffer<
101- UniquePtrWithLambda<std::remove_extent_t <T>>,
102- void >;
109+ UniquePtrWithLambda<std::remove_extent_t <T>>>;
103110
104111 // @todo rvalue references..?
105112 template <typename T>
@@ -133,77 +140,17 @@ struct ConfigureLoadStoreCore
133140 -> std::future<auxiliary::detail::future_to_shared_ptr_dataset_types>;
134141};
135142
136- /* * Basic configuration for a Load/Store operation.
137- *
138- * @tparam ChildClass CRT pattern.
139- * The purpose is that in child classes `return *this` should return
140- * an instance of the child class, not of ConfigureLoadStore.
141- * Instantiate with void when using without subclass.
142- */
143- template <typename ChildClass = void >
144- class ConfigureLoadStore : public ConfigureLoadStoreCore
145- {
146- friend class RecordComponent ;
147- friend struct ConfigureLoadStoreCore ;
148-
149- protected:
150- ConfigureLoadStore (RecordComponent &rc);
151- ConfigureLoadStore (ConfigureLoadStoreCore &&);
152-
153- public:
154- using return_type = std::conditional_t <
155- std::is_void_v<ChildClass>,
156- /* then*/ ConfigureLoadStore<void >,
157- /* else*/ ChildClass>;
158-
159- auto offset (Offset) -> return_type &;
160- auto extent (Extent) -> return_type &;
161- };
162-
163- /* * Configuration for a Store operation with a buffer type.
164- *
165- * This class does intentionally not support Load operations since there are
166- * pointer types (const pointers, unique pointers) where Load operations make no
167- * sense. See the \ref ConfigureLoadStoreFromBuffer class template for both
168- * Load/Store operations.
169- *
170- * @tparam Ptr_Type The type of pointer used internally.
171- * @tparam ChildClass CRT pattern.
172- * The purpose is that in child classes `return *this` should return
173- * an instance of the child class, not of ConfigureStoreChunkFromBuffer.
174- * Instantiate with void when using without subclass.
175- */
176- template <typename Ptr_Type, typename ChildClass = void >
177- class ConfigureStoreChunkFromBuffer
178- : public ConfigureLoadStore<std::conditional_t <
179- std::is_void_v<ChildClass>,
180- /* then*/ ConfigureStoreChunkFromBuffer<Ptr_Type, void >,
181- /* else*/ ChildClass>>
143+ template <typename Ptr_Type>
144+ class ConfigureStoreChunkFromBufferCore : public ConfigureLoadStoreCore
182145{
183146public:
184- using return_type = std::conditional_t <
185- std::is_void_v<ChildClass>,
186- /* then*/ ConfigureStoreChunkFromBuffer<Ptr_Type, void >,
187- /* else*/ ChildClass>;
188- using parent_t = ConfigureLoadStore<return_type>;
189-
190- protected:
191- friend struct ConfigureLoadStoreCore ;
192-
193147 Ptr_Type m_buffer;
194148 std::optional<MemorySelection> m_mem_select;
195149
196- auto storeChunkConfig () -> internal::LoadStoreConfigWithBuffer;
197-
198- protected:
199- ConfigureStoreChunkFromBuffer (Ptr_Type buffer, parent_t &&);
150+ ConfigureStoreChunkFromBufferCore (
151+ Ptr_Type buffer, ConfigureLoadStoreCore &&);
200152
201- public:
202- auto memorySelection (MemorySelection) -> return_type &;
203-
204- auto as_parent () && -> parent_t &&;
205- auto as_parent () & -> parent_t &;
206- auto as_parent () const & -> parent_t const &;
153+ auto storeChunkConfig () -> internal::LoadStoreConfigWithBuffer;
207154
208155 auto enqueueStore () -> void;
209156
@@ -222,32 +169,95 @@ class ConfigureStoreChunkFromBuffer
222169 }
223170};
224171
225- /* * Configuration for a Load/Store operation with a buffer type.
226- *
227- * Only instantiated for pointer types where Load operations make sense (e.g. no
228- * const pointers and no unique pointers).
229- * \ref ConfigureStoreChunkFromBuffer is used otherwise.
230- *
231- * @tparam Ptr_Type The type of pointer used internally.
232- */
233172template <typename Ptr_Type>
234- class ConfigureLoadStoreFromBuffer
235- : public ConfigureStoreChunkFromBuffer<
236- Ptr_Type,
237- ConfigureLoadStoreFromBuffer<Ptr_Type>>
173+ class ConfigureLoadStoreFromBufferCore
174+ : public ConfigureStoreChunkFromBufferCore<Ptr_Type>
238175{
239- using parent_t = ConfigureStoreChunkFromBuffer<
240- Ptr_Type,
241- ConfigureLoadStoreFromBuffer<Ptr_Type>>;
242- friend struct ConfigureLoadStoreCore ;
243- ConfigureLoadStoreFromBuffer (
244- Ptr_Type buffer, typename parent_t ::parent_t &&);
245-
246176public:
177+ using ConfigureStoreChunkFromBufferCore<
178+ Ptr_Type>::ConfigureStoreChunkFromBufferCore;
179+
247180 auto enqueueLoad () -> void;
248181
249182 auto load (EnqueuePolicy) -> void;
250183};
184+
185+ namespace compose
186+ {
187+ /* * Basic configuration for a Load/Store operation.
188+ *
189+ * @tparam ChildClass CRT pattern.
190+ * The purpose is that in child classes `return *this` should return
191+ * an instance of the child class, not of ConfigureLoadStore.
192+ * Instantiate with void when using without subclass.
193+ */
194+ template <typename ChildClass>
195+ class ConfigureLoadStore
196+ {
197+ public:
198+ auto offset (Offset) -> ChildClass &;
199+ auto extent (Extent) -> ChildClass &;
200+ };
201+
202+ /* * Configuration for a Store operation with a buffer type.
203+ *
204+ * This class does intentionally not support Load operations since there are
205+ * pointer types (const pointers, unique pointers) where Load operations
206+ * make no sense. See the \ref ConfigureLoadStoreFromBuffer class template
207+ * for both Load/Store operations.
208+ *
209+ * @tparam Ptr_Type The type of pointer used internally.
210+ * @tparam ChildClass CRT pattern.
211+ * The purpose is that in child classes `return *this` should return
212+ * an instance of the child class, not of
213+ * ConfigureStoreChunkFromBuffer. Instantiate with void when using without
214+ * subclass.
215+ */
216+ template <typename ChildClass = void >
217+ class ConfigureStoreChunkFromBuffer
218+ {
219+ public:
220+ auto memorySelection (MemorySelection) -> ChildClass &;
221+ };
222+ } // namespace compose
223+
224+ class ConfigureLoadStore
225+ : public ConfigureLoadStoreCore
226+ , public compose::ConfigureLoadStore<ConfigureLoadStore>
227+ {
228+ friend class RecordComponent ;
229+ friend struct ConfigureLoadStoreCore ;
230+
231+ ConfigureLoadStore (RecordComponent &rc);
232+ ConfigureLoadStore (ConfigureLoadStoreCore &&);
233+ };
234+
235+ template <typename Ptr_Type>
236+ class ConfigureStoreChunkFromBuffer
237+ : public ConfigureStoreChunkFromBufferCore<Ptr_Type>
238+ , public compose::ConfigureLoadStore<
239+ ConfigureStoreChunkFromBuffer<Ptr_Type>>
240+ , public compose::ConfigureStoreChunkFromBuffer<
241+ ConfigureStoreChunkFromBuffer<Ptr_Type>>
242+ {
243+ friend struct ConfigureLoadStoreCore ;
244+
245+ using ConfigureStoreChunkFromBufferCore<
246+ Ptr_Type>::ConfigureStoreChunkFromBufferCore;
247+ };
248+
249+ template <typename Ptr_Type>
250+ class ConfigureLoadStoreFromBuffer
251+ : public ConfigureLoadStoreFromBufferCore<Ptr_Type>
252+ , public compose::ConfigureLoadStore<ConfigureLoadStoreFromBuffer<Ptr_Type>>
253+ , public compose::ConfigureStoreChunkFromBuffer<
254+ ConfigureLoadStoreFromBuffer<Ptr_Type>>
255+ {
256+ friend struct ConfigureLoadStoreCore ;
257+
258+ using ConfigureLoadStoreFromBufferCore<
259+ Ptr_Type>::ConfigureLoadStoreFromBufferCore;
260+ };
251261} // namespace openPMD
252262
253263#include " openPMD/LoadStoreChunk.tpp"
0 commit comments