mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-19 10:35:42 +00:00
Merge topic 'reset_type_and_storage_in_single_call'
b70a000a Allow resetting the Type and Storage of a DynamicArrayHandle in a single call. Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Kenneth Moreland <kmorel@sandia.gov> Merge-request: !302
This commit is contained in:
commit
360694b54c
@ -276,6 +276,22 @@ public:
|
||||
return DynamicArrayHandleBase<TypeList,NewStorageList>(*this);
|
||||
}
|
||||
|
||||
/// Changes the value, and array storage types to try casting to when
|
||||
/// resolving this dynamic array. Since C++ does not allow you to actually
|
||||
/// change the template arguments, this method returns a new dynamic array
|
||||
/// object. This method is particularly useful when you have both custom
|
||||
/// types and traits.
|
||||
///
|
||||
template<typename NewTypeList, typename NewStorageList>
|
||||
VTKM_CONT_EXPORT
|
||||
DynamicArrayHandleBase<NewTypeList,NewStorageList>
|
||||
ResetTypeAndStorageLists(NewTypeList = NewTypeList(),
|
||||
NewStorageList = NewStorageList()) const {
|
||||
VTKM_IS_LIST_TAG(NewTypeList);
|
||||
VTKM_IS_LIST_TAG(NewStorageList);
|
||||
return DynamicArrayHandleBase<NewTypeList,NewStorageList>(*this);
|
||||
}
|
||||
|
||||
/// Attempts to cast the held array to a specific value type and storage,
|
||||
/// then call the given functor with the cast array. The types and storage
|
||||
/// tried in the cast are those in the lists defined by the TypeList and
|
||||
|
@ -332,6 +332,19 @@ void TryUnusualTypeAndStorage()
|
||||
std::cout << " Caught exception for unrecognized type." << std::endl;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//resetting the string and tag should result in a valid array handle
|
||||
CheckDynamicArray(array.ResetTypeAndStorageLists(TypeListTagString(),
|
||||
StorageListTagUnusual()),
|
||||
1);
|
||||
}
|
||||
catch (vtkm::cont::ErrorControlBadValue)
|
||||
{
|
||||
VTKM_TEST_FAIL("ResetTypeAndStorageLists should have handled the custom type/storage.");
|
||||
}
|
||||
|
||||
|
||||
CheckCalled = false;
|
||||
CheckDynamicArray(array
|
||||
.ResetTypeList(TypeListTagString())
|
||||
@ -345,6 +358,13 @@ void TryUnusualTypeAndStorage()
|
||||
.ResetTypeList(TypeListTagString()),
|
||||
1);
|
||||
std::cout << " Found instance when storage and type lists were reset." << std:: endl;
|
||||
|
||||
CheckCalled = false;
|
||||
CheckDynamicArray(array
|
||||
.ResetTypeAndStorageLists(TypeListTagString(),
|
||||
StorageListTagUnusual()),
|
||||
1);
|
||||
std::cout << " Found instance when storage and type lists were reset." << std:: endl;
|
||||
}
|
||||
|
||||
void TryCastToArrayHandle()
|
||||
|
Loading…
Reference in New Issue
Block a user