Commit 360694b5 authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot
Browse files

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's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland's avatarKenneth Moreland <kmorel@sandia.gov>
Merge-request: !302
parents 34ad5209 b70a000a
......@@ -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()
......
Supports Markdown
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