Commit dae779b9 authored by Sujin Philip's avatar Sujin Philip

ArrayHandleVirtual bugfixes

After the change to `ArrayHandleVirtual` where it became a subclass of
`vtkm::cont::ArrayHandle`, a few extra changes are required.

1. Functions with `ArrayHandleVirtual` as parameters will not be callable
with the superclass `ArrayHandle`. This is fixed by changing the argument
types to the superclass.
2. Add Serialization classes specializations for the superclass, as "is-a"
relation is not considered for class template parameters.
parent d0d33f98
......@@ -213,9 +213,11 @@ VTKM_CONT vtkm::cont::ArrayHandleVirtual<T> make_ArrayHandleVirtual(
/// Returns true if \c virtHandle matches the type of ArrayHandleType.
///
template <typename ArrayHandleType, typename T>
VTKM_CONT inline bool IsType(const vtkm::cont::ArrayHandleVirtual<T>& virtHandle)
VTKM_CONT inline bool IsType(
const vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagVirtual>& virtHandle)
{
return virtHandle.template IsType<ArrayHandleType>();
return static_cast<vtkm::cont::ArrayHandleVirtual<T>>(virtHandle)
.template IsType<ArrayHandleType>();
}
/// Returns \c virtHandle cast to the given \c ArrayHandle type. Throws \c
......@@ -223,9 +225,11 @@ VTKM_CONT inline bool IsType(const vtkm::cont::ArrayHandleVirtual<T>& virtHandle
/// to check if the cast can happen.
///
template <typename ArrayHandleType, typename T>
VTKM_CONT inline ArrayHandleType Cast(const vtkm::cont::ArrayHandleVirtual<T>& virtHandle)
VTKM_CONT inline ArrayHandleType Cast(
const vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagVirtual>& virtHandle)
{
return virtHandle.template Cast<ArrayHandleType>();
return static_cast<vtkm::cont::ArrayHandleVirtual<T>>(virtHandle)
.template Cast<ArrayHandleType>();
}
//=============================================================================
// Specializations of serialization related classes
......@@ -239,6 +243,12 @@ struct SerializableTypeString<vtkm::cont::ArrayHandleVirtual<T>>
}
};
template <typename T>
struct SerializableTypeString<vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagVirtual>>
: public SerializableTypeString<vtkm::cont::ArrayHandleVirtual<T>>
{
};
#ifndef vtk_m_cont_ArrayHandleVirtual_cxx
#define VTK_M_ARRAY_HANDLE_VIRTUAL_EXPORT(T) \
......
......@@ -154,6 +154,13 @@ struct Serialization<vtkm::cont::ArrayHandleVirtual<vtkm::Int64>>
: public IntAnySerializer<vtkm::Int64>
{
};
}
template <typename T>
struct Serialization<vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagVirtual>>
: public Serialization<vtkm::cont::ArrayHandleVirtual<T>>
{
};
} // mangled_diy_namespace
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment