10 #ifndef vtk_m_cont_ArrayHandleCounting_h
11 #define vtk_m_cont_ArrayHandleCounting_h
31 template <
class CountingValueType>
37 using ValueType = CountingValueType;
48 ArrayPortalCounting(ValueType start, ValueType step,
vtkm::Id numValues)
51 , NumberOfValues(numValues)
56 ValueType GetStart()
const {
return this->Start; }
59 ValueType GetStep()
const {
return this->Step; }
62 vtkm::Id GetNumberOfValues()
const {
return this->NumberOfValues; }
67 return ValueType(this->Start + this->Step * ValueType(
static_cast<ComponentType
>(index)));
79 template <
typename T,
typename UseVecTraits = vtkm::HasVecTraits<T>>
83 struct CanCountImpl<T, std::false_type>
86 static constexpr
bool IsNumeric =
87 !std::is_same<typename TTraits::NumericTag, vtkm::TypeTraitsUnknownTag>::value;
89 static constexpr
bool value = IsNumeric;
93 struct CanCountImpl<T, std::true_type>
96 using BaseType =
typename VTraits::BaseComponentType;
97 static constexpr
bool IsBool = std::is_same<BaseType, bool>::value;
99 static constexpr
bool value = CanCountImpl<BaseType, std::false_type>::value && !IsBool;
105 template <
typename T>
108 static constexpr
bool value = detail::CanCountImpl<T>::value;
111 template <
typename T>
112 using StorageTagCountingSuperclass =
115 template <
typename T>
116 struct Storage<T, typename std::enable_if<CanCount<T>::value, vtkm::cont::StorageTagCounting>::type>
117 : Storage<T, StorageTagCountingSuperclass<T>>
126 template <
typename CountingValueType>
137 : Superclass(internal::PortalToArrayHandleImplicitBuffers(
138 internal::ArrayPortalCounting<CountingValueType>(start, step, length)))
149 template <
typename CountingValueType>
166 template <
typename T>
167 struct SerializableTypeString<
vtkm::cont::ArrayHandleCounting<T>>
176 template <
typename T>
177 struct SerializableTypeString<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagCounting>>
178 : SerializableTypeString<vtkm::cont::ArrayHandleCounting<T>>
187 template <
typename T>
188 struct Serialization<
vtkm::cont::ArrayHandleCounting<T>>
195 static VTKM_CONT void save(BinaryBuffer& bb,
const BaseType& obj)
197 auto portal = obj.ReadPortal();
198 vtkmdiy::save(bb, portal.GetStart());
199 vtkmdiy::save(bb, portal.GetStep());
200 vtkmdiy::save(bb, portal.GetNumberOfValues());
216 template <
typename T>
217 struct Serialization<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagCounting>>
218 : Serialization<vtkm::cont::ArrayHandleCounting<T>>
224 #endif //vtk_m_cont_ArrayHandleCounting_h