Skip to content

Commit 43eba97

Browse files
committed
Move wrappers to header code
1 parent ca6d272 commit 43eba97

2 files changed

Lines changed: 52 additions & 65 deletions

File tree

include/openPMD/LoadStoreChunk.tpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,63 @@
44

55
namespace openPMD
66
{
7+
template <typename T>
8+
auto ConfigureLoadStore::withSharedPtr(std::shared_ptr<T> data)
9+
-> shared_ptr_return_type<T>
10+
{
11+
using T_decayed = std::remove_cv_t<std::remove_extent_t<T>>;
12+
constexpr auto dtype = determineDatatype<T_decayed>();
13+
if constexpr (std::is_const_v<T>)
14+
{
15+
return withSharedPtr_impl_const(data, dtype);
16+
}
17+
else
18+
{
19+
return withSharedPtr_impl_mut(data, dtype);
20+
}
21+
}
22+
23+
template <typename T>
24+
auto ConfigureLoadStore::withUniquePtr(UniquePtrWithLambda<T> data)
25+
-> unique_ptr_return_type<T>
26+
27+
{
28+
using T_decayed = std::remove_cv_t<std::remove_extent_t<T>>;
29+
constexpr auto dtype = determineDatatype<T_decayed>();
30+
if constexpr (std::is_const_v<T>)
31+
{
32+
return withUniquePtr_impl_const(
33+
std::move(data).template static_cast_<void const>(), dtype);
34+
}
35+
else
36+
{
37+
return withUniquePtr_impl_mut(
38+
std::move(data).template static_cast_<void>(), dtype);
39+
}
40+
}
41+
742
template <typename T, typename Del>
843
auto ConfigureLoadStore::withUniquePtr(std::unique_ptr<T, Del> data)
944
-> unique_ptr_return_type<T>
1045
{
1146
return withUniquePtr(UniquePtrWithLambda<T>(std::move(data)));
1247
}
48+
49+
template <typename T>
50+
auto ConfigureLoadStore::withRawPtr(T *data) -> shared_ptr_return_type<T>
51+
{
52+
using T_decayed = std::remove_cv_t<std::remove_extent_t<T>>;
53+
constexpr auto dtype = determineDatatype<T_decayed>();
54+
if constexpr (std::is_const_v<T>)
55+
{
56+
return withRawPtr_impl_const(data, dtype);
57+
}
58+
else
59+
{
60+
return withRawPtr_impl_mut(data, dtype);
61+
}
62+
}
63+
1364
template <typename T_ContiguousContainer>
1465
auto ConfigureLoadStore::withContiguousContainer(T_ContiguousContainer &data)
1566
-> std::enable_if_t<

src/LoadStoreChunk.cpp

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,6 @@ auto ConfigureLoadStore::withSharedPtr_impl_const(
146146
auxiliary::WriteBuffer(std::move(data)), datatype, {std::move(*this)});
147147
}
148148

149-
template <typename T>
150-
auto ConfigureLoadStore::withSharedPtr(std::shared_ptr<T> data)
151-
-> shared_ptr_return_type<T>
152-
{
153-
using T_decayed = std::remove_cv_t<std::remove_extent_t<T>>;
154-
constexpr auto dtype = determineDatatype<T_decayed>();
155-
if constexpr (std::is_const_v<T>)
156-
{
157-
return withSharedPtr_impl_const(data, dtype);
158-
}
159-
else
160-
{
161-
return withSharedPtr_impl_mut(data, dtype);
162-
}
163-
}
164-
165149
auto ConfigureLoadStore::withUniquePtr_impl_mut(
166150
UniquePtrWithLambda<void> data, Datatype dtype)
167151
-> openPMD::ConfigureStoreChunkFromBuffer
@@ -199,24 +183,6 @@ auto ConfigureLoadStore::withUniquePtr_impl_const(
199183
dtype,
200184
{std::move(*this)});
201185
}
202-
template <typename T>
203-
auto ConfigureLoadStore::withUniquePtr(UniquePtrWithLambda<T> data)
204-
-> unique_ptr_return_type<T>
205-
206-
{
207-
using T_decayed = std::remove_cv_t<std::remove_extent_t<T>>;
208-
constexpr auto dtype = determineDatatype<T_decayed>();
209-
if constexpr (std::is_const_v<T>)
210-
{
211-
return withUniquePtr_impl_const(
212-
std::move(data).template static_cast_<void const>(), dtype);
213-
}
214-
else
215-
{
216-
return withUniquePtr_impl_mut(
217-
std::move(data).template static_cast_<void>(), dtype);
218-
}
219-
}
220186

221187
auto ConfigureLoadStore::withRawPtr_impl_mut(void *data, Datatype dtype)
222188
-> openPMD::ConfigureLoadStoreFromBuffer
@@ -246,21 +212,6 @@ auto ConfigureLoadStore::withRawPtr_impl_const(void const *data, Datatype dtype)
246212
{std::move(*this)});
247213
}
248214

249-
template <typename T>
250-
auto ConfigureLoadStore::withRawPtr(T *data) -> shared_ptr_return_type<T>
251-
{
252-
using T_decayed = std::remove_cv_t<std::remove_extent_t<T>>;
253-
constexpr auto dtype = determineDatatype<T_decayed>();
254-
if constexpr (std::is_const_v<T>)
255-
{
256-
return withRawPtr_impl_const(data, dtype);
257-
}
258-
else
259-
{
260-
return withRawPtr_impl_mut(data, dtype);
261-
}
262-
}
263-
264215
template <typename T>
265216
auto ConfigureLoadStore::enqueueStore() -> DynamicMemoryView<T>
266217
{
@@ -452,25 +403,10 @@ void ConfigureStoreChunkFromBuffer::memorySelection_impl(MemorySelection sel)
452403
std::shared_ptr, dtype)>; \
453404
template auto ConfigureLoadStore::load(EnqueuePolicy) \
454405
->std::shared_ptr<dtype>;
455-
#define INSTANTIATE_FULLMATRIX(dtype) \
456-
template auto ConfigureLoadStore::withSharedPtr( \
457-
std::shared_ptr<dtype> data) -> shared_ptr_return_type<dtype>; \
458-
template auto ConfigureLoadStore::withUniquePtr( \
459-
UniquePtrWithLambda<dtype> data) -> unique_ptr_return_type<dtype>;
460406
#define INSTANTIATE_METHOD_TEMPLATES_WITH_AND_WITHOUT_EXTENT(type) \
461407
INSTANTIATE_METHOD_TEMPLATES(type) \
462408
INSTANTIATE_METHOD_TEMPLATES(OPENPMD_ARRAY(type)) \
463-
INSTANTIATE_FULLMATRIX(type) \
464-
INSTANTIATE_FULLMATRIX(type const) \
465-
INSTANTIATE_FULLMATRIX(OPENPMD_ARRAY(type)) \
466-
INSTANTIATE_FULLMATRIX(OPENPMD_ARRAY(type const)) \
467-
template auto ConfigureLoadStore::enqueueStore() \
468-
-> DynamicMemoryView<type>; \
469-
template auto ConfigureLoadStore::withRawPtr(OPENPMD_POINTER(type) data) \
470-
->OPENPMD_APPLY_TEMPLATE(shared_ptr_return_type, type); \
471-
template auto ConfigureLoadStore::withRawPtr(OPENPMD_POINTER(type const) \
472-
data) \
473-
->OPENPMD_APPLY_TEMPLATE(shared_ptr_return_type, type const);
409+
template auto ConfigureLoadStore::enqueueStore() -> DynamicMemoryView<type>;
474410

475411
OPENPMD_FOREACH_DATASET_DATATYPE(
476412
INSTANTIATE_METHOD_TEMPLATES_WITH_AND_WITHOUT_EXTENT)

0 commit comments

Comments
 (0)