Skip to content

Commit

Permalink
Move implementation to .tpp
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Oct 20, 2023
1 parent 42fd638 commit 90d02c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
29 changes: 0 additions & 29 deletions include/openPMD/RecordComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,6 @@ namespace internal
};
} // namespace internal

class RecordComponent;

namespace detail
{
template <typename Functor, typename Res>
struct VisitRecordComponent
{
template <typename T, typename... Args>
static Res call(RecordComponent &rc, Args &&...args)
{
return Functor::template call<T>(rc, std::forward<Args>(args)...);
}

template <int = 0, typename... Args>
static Res call(Args &&...)
{
throw std::runtime_error(
"[RecordComponent::visit()] Unknown datatype in "
"RecordComponent");
}
};
} // namespace detail

class RecordComponent : public BaseRecordComponent
{
template <typename T, typename T_key, typename T_container>
Expand Down Expand Up @@ -461,13 +438,7 @@ class RecordComponent : public BaseRecordComponent
template <typename Visitor, typename... Args>
constexpr auto visit(Args &&...args)
-> decltype(Visitor::template call<char>(
std::declval<RecordComponent &>(), std::forward<Args>(args)...))
{
using Res = decltype(Visitor::template call<char>(
std::declval<RecordComponent &>(), std::forward<Args>(args)...));
return switchNonVectorType<detail::VisitRecordComponent<Visitor, Res>>(
getDatatype(), *this, std::forward<Args>(args)...);
}

static constexpr char const *const SCALAR = "\vScalar";

Expand Down
35 changes: 34 additions & 1 deletion include/openPMD/RecordComponent.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void RecordComponent::storeChunkRaw(T *ptr, Offset offset, Extent extent)

template <typename T_ContiguousContainer>
inline typename std::enable_if_t<
auxiliary::IsContiguousContainer_v<T_ContiguousContainer> >
auxiliary::IsContiguousContainer_v<T_ContiguousContainer>>
RecordComponent::storeChunk(T_ContiguousContainer &data, Offset o, Extent e)
{
uint8_t dim = getDimensionality();
Expand Down Expand Up @@ -373,4 +373,37 @@ RecordComponent::storeChunk(Offset offset, Extent extent)
#endif
});
}

namespace detail
{
template <typename Functor, typename Res>
struct VisitRecordComponent
{
template <typename T, typename... Args>
static Res call(RecordComponent &rc, Args &&...args)
{
return Functor::template call<T>(rc, std::forward<Args>(args)...);
}

template <int = 0, typename... Args>
static Res call(Args &&...)
{
throw std::runtime_error(
"[RecordComponent::visit()] Unknown datatype in "
"RecordComponent");
}
};
} // namespace detail

template <typename Visitor, typename... Args>
constexpr auto RecordComponent::visit(Args &&...args)
-> decltype(Visitor::template call<char>(
std::declval<RecordComponent &>(), std::forward<Args>(args)...))
{
using Res = decltype(Visitor::template call<char>(
std::declval<RecordComponent &>(), std::forward<Args>(args)...));
return switchNonVectorType<detail::VisitRecordComponent<Visitor, Res>>(
getDatatype(), *this, std::forward<Args>(args)...);
}

} // namespace openPMD

0 comments on commit 90d02c1

Please sign in to comment.