@@ -123,6 +123,74 @@ namespace core
123123 return *m_extent;
124124 }
125125
126+ template <typename T>
127+ auto ConfigureLoadStore::withSharedPtr (std::shared_ptr<T> data)
128+ -> shared_ptr_return_type<T>
129+ {
130+ using T_decayed = std::remove_cv_t <std::remove_extent_t <T>>;
131+ if (!data)
132+ {
133+ throw std::runtime_error (
134+ " Unallocated pointer passed during chunk store." );
135+ }
136+ return shared_ptr_return_type<T>(
137+ auxiliary::WriteBuffer (
138+ std::static_pointer_cast<
139+ std::conditional_t <std::is_const_v<T>, void const , void >>(
140+ std::move (data))),
141+ determineDatatype<T_decayed>(),
142+ {std::move (*this )});
143+ }
144+ template <typename T>
145+ auto ConfigureLoadStore::withUniquePtr (UniquePtrWithLambda<T> data)
146+ -> unique_ptr_return_type<T>
147+
148+ {
149+ using T_decayed = std::remove_cv_t <std::remove_extent_t <T>>;
150+ if (!data)
151+ {
152+ throw std::runtime_error (
153+ " Unallocated pointer passed during chunk store." );
154+ }
155+ if constexpr (std::is_const_v<T>)
156+ {
157+ void const *raw_ptr = data.get ();
158+ return unique_ptr_return_type<T>(
159+ auxiliary::WriteBuffer (
160+ std::shared_ptr<void const >(
161+ raw_ptr,
162+ [data_lambda =
163+ std::move (data)](auto const *) { /* no-op */ })),
164+ determineDatatype<T_decayed>(),
165+ {std::move (*this )});
166+ }
167+ else
168+ {
169+ return unique_ptr_return_type<T>(
170+ auxiliary::WriteBuffer (
171+ std::move (data).template static_cast_ <void >()),
172+ determineDatatype<T_decayed>(),
173+ {std::move (*this )});
174+ }
175+ }
176+ template <typename T>
177+ auto ConfigureLoadStore::withRawPtr (T *data) -> shared_ptr_return_type<T>
178+ {
179+ using T_decayed = std::remove_cv_t <std::remove_extent_t <T>>;
180+ if (!data)
181+ {
182+ throw std::runtime_error (
183+ " Unallocated pointer passed during chunk store." );
184+ }
185+ return shared_ptr_return_type<T>(
186+ auxiliary::WriteBuffer (
187+ std::static_pointer_cast<
188+ std::conditional_t <std::is_const_v<T>, void const , void >>(
189+ auxiliary::shareRaw (data))),
190+ determineDatatype<T_decayed>(),
191+ {std::move (*this )});
192+ }
193+
126194 template <typename T>
127195 auto ConfigureLoadStore::enqueueStore () -> DynamicMemoryView<T>
128196 {
@@ -324,6 +392,7 @@ template class compose::ConfigureStoreChunkFromBuffer<
324392
325393// need this for clang-tidy
326394#define OPENPMD_ARRAY (type ) type[]
395+ #define OPENPMD_POINTER (type ) type *
327396#define OPENPMD_APPLY_TEMPLATE (template_, type ) template_<type>
328397
329398#define INSTANTIATE_METHOD_TEMPLATES (dtype ) \
@@ -332,11 +401,26 @@ template class compose::ConfigureStoreChunkFromBuffer<
332401 std::shared_ptr, dtype)>; \
333402 template auto core::ConfigureLoadStore::load (EnqueuePolicy) \
334403 ->std::shared_ptr<dtype>;
404+ #define INSTANTIATE_FULLMATRIX (dtype ) \
405+ template auto core::ConfigureLoadStore::withSharedPtr ( \
406+ std::shared_ptr<dtype> data) -> shared_ptr_return_type<dtype>; \
407+ template auto core::ConfigureLoadStore::withUniquePtr ( \
408+ UniquePtrWithLambda<dtype> data) -> unique_ptr_return_type<dtype>;
335409#define INSTANTIATE_METHOD_TEMPLATES_WITH_AND_WITHOUT_EXTENT (type ) \
336410 INSTANTIATE_METHOD_TEMPLATES (type) \
337411 INSTANTIATE_METHOD_TEMPLATES (OPENPMD_ARRAY(type)) \
412+ INSTANTIATE_FULLMATRIX (type) \
413+ INSTANTIATE_FULLMATRIX (type const ) \
414+ INSTANTIATE_FULLMATRIX (OPENPMD_ARRAY(type)) \
415+ INSTANTIATE_FULLMATRIX (OPENPMD_ARRAY(type const )) \
338416 template auto core::ConfigureLoadStore::enqueueStore () \
339- -> DynamicMemoryView<type>;
417+ -> DynamicMemoryView<type>; \
418+ template auto core::ConfigureLoadStore::withRawPtr (OPENPMD_POINTER(type) \
419+ data) \
420+ ->OPENPMD_APPLY_TEMPLATE(shared_ptr_return_type, type); \
421+ template auto core::ConfigureLoadStore::withRawPtr ( \
422+ OPENPMD_POINTER (type const ) data) \
423+ ->OPENPMD_APPLY_TEMPLATE(shared_ptr_return_type, type const );
340424
341425OPENPMD_FOREACH_DATASET_DATATYPE (
342426 INSTANTIATE_METHOD_TEMPLATES_WITH_AND_WITHOUT_EXTENT)
@@ -346,6 +430,7 @@ OPENPMD_FOREACH_DATASET_DATATYPE(
346430
347431#undef INSTANTIATE_METHOD_TEMPLATES
348432#undef OPENPMD_ARRAY
433+ #undef OPENPMD_POINTER
349434#undef OPENPMD_APPLY_TEMPLATE
350435
351436ConfigureLoadStore::ConfigureLoadStore (RecordComponent &rc)
0 commit comments