From bb7661c1699f5f1ca04c9129c4049c276bb64f6a Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Thu, 5 Aug 2021 16:16:49 -0600 Subject: [PATCH] Fix recursive header file dependancies Having UnknownArrayHandle.h include DefaultTypes.h is problematic, because that header includes lots of other classes like cell sets. Keeping these from in turn depending back on UnknownArrayHandle.h is difficult. So this dependancy is broken. --- vtkm/cont/CastAndCall.h | 24 +++++++++++++++++++----- vtkm/cont/Field.h | 1 + vtkm/cont/UncertainArrayHandle.h | 1 + vtkm/cont/UnknownArrayHandle.h | 31 +++++++------------------------ 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/vtkm/cont/CastAndCall.h b/vtkm/cont/CastAndCall.h index 4632fe5b6..66c3d5741 100644 --- a/vtkm/cont/CastAndCall.h +++ b/vtkm/cont/CastAndCall.h @@ -12,6 +12,9 @@ #include +#include +#include + #include namespace vtkm @@ -25,8 +28,6 @@ class Field; template class ArrayHandle; -class UnknownArrayHandle; - template class CellSetStructured; template @@ -70,9 +71,13 @@ void CastAndCall(const vtkm::cont::ArrayHandle& handle, Functor&& f, Args& /// A specialization of CastAndCall for UnknownArrayHandle. /// Since we have no hints on the types, use VTKM_DEFAULT_TYPE_LIST /// and VTKM_DEFAULT_STORAGE_LIST. -// actually implemented in vtkm/cont/UnknownArrayHandle +// Implemented here to avoid circular dependencies. template -void CastAndCall(const UnknownArrayHandle& handle, Functor&& f, Args&&... args); +void CastAndCall(const UnknownArrayHandle& handle, Functor&& f, Args&&... args) +{ + handle.CastAndCallForTypes( + std::forward(f), std::forward(args)...); +} /// A specialization of CastAndCall for basic CellSetStructured types, /// Since the type is already known no deduction is needed. @@ -172,7 +177,16 @@ struct DynamicTransformTraits /// using DynamicTag = vtkm::cont::internal::DynamicTransformTagStatic; }; -} + +// Implemented here to avoid circular dependencies. +template <> +struct DynamicTransformTraits +{ + using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall; +}; + +} // namespace internal + } } // namespace vtkm::cont diff --git a/vtkm/cont/Field.h b/vtkm/cont/Field.h index b9b04c996..5f6af4179 100644 --- a/vtkm/cont/Field.h +++ b/vtkm/cont/Field.h @@ -16,6 +16,7 @@ #include #include +#include #include namespace vtkm diff --git a/vtkm/cont/UncertainArrayHandle.h b/vtkm/cont/UncertainArrayHandle.h index f2da66b5c..f5bf4020b 100644 --- a/vtkm/cont/UncertainArrayHandle.h +++ b/vtkm/cont/UncertainArrayHandle.h @@ -10,6 +10,7 @@ #ifndef vtk_m_cont_UncertainArrayHandle_h #define vtk_m_cont_UncertainArrayHandle_h +#include #include namespace vtkm diff --git a/vtkm/cont/UnknownArrayHandle.h b/vtkm/cont/UnknownArrayHandle.h index b6c224572..5d5b8255d 100644 --- a/vtkm/cont/UnknownArrayHandle.h +++ b/vtkm/cont/UnknownArrayHandle.h @@ -18,8 +18,9 @@ #include #include #include -#include -#include +#include + +#include #include #include @@ -513,10 +514,10 @@ public: template VTKM_DEPRECATED(1.6, "Specify both value types and storage types.") VTKM_CONT - vtkm::cont::UncertainArrayHandle ResetTypes( + vtkm::cont::UncertainArrayHandle ResetTypes( NewValueTypeList = NewValueTypeList{}) const { - return this->ResetTypes(); + return this->ResetTypes(); } /// \brief Returns the number of values in the array. @@ -806,13 +807,13 @@ private: template VTKM_CONT void CastAndCallImpl(std::false_type, Args&&... args) const { - this->CastAndCallForTypes( + this->CastAndCallForTypes( std::forward(args)...); } template VTKM_CONT void CastAndCallImpl(std::true_type, StorageList, Args&&... args) const { - this->CastAndCallForTypes(std::forward(args)...); + this->CastAndCallForTypes(std::forward(args)...); } }; @@ -1014,13 +1015,6 @@ VTKM_CONT inline ArrayHandleType Cast(const vtkm::cont::UnknownArrayHandle& arra return array.template AsArrayHandle(); } -template -void CastAndCall(const UnknownArrayHandle& handle, Functor&& f, Args&&... args) -{ - handle.CastAndCallForTypes( - std::forward(f), std::forward(args)...); -} - namespace detail { @@ -1074,17 +1068,6 @@ inline void UnknownArrayHandle::CastAndCallWithExtractedArray(Functor&& functor, } } -namespace internal -{ - -template <> -struct DynamicTransformTraits -{ - using DynamicTag = vtkm::cont::internal::DynamicTransformTagCastAndCall; -}; - -} // namespace internal - } } // namespace vtkm::cont