vtk-m/vtkm/cont/internal/VirtualObjectTransfer.cxx
Kenneth Moreland cb3bb43ff9 Completely deprecate virtual methods
Deprecate `VirtualObjectHandle` and all other classes that are used to
implement objects with virtual methods in the execution environment.

Additionally, the code is updated so that if the
`VTKm_NO_DEPRECATED_VIRTUAL` flag is set none of the code is compiled at
all. This opens us up to opportunities that do not work with virtual
methods such as backends that do not support virtual methods and dynamic
libraries for CUDA.
2021-04-28 07:28:32 -06:00

64 lines
1.8 KiB
C++

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/internal/VirtualObjectTransfer.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <array>
#include <memory>
VTKM_DEPRECATED_SUPPRESS_BEGIN
namespace vtkm
{
namespace cont
{
namespace internal
{
VTKM_CONT TransferInterface::~TransferInterface() = default;
bool TransferState::DeviceIdIsValid(vtkm::cont::DeviceAdapterId deviceId) const
{
auto index = static_cast<std::size_t>(deviceId.GetValue());
auto size = this->DeviceTransferState.size();
if (!this->HostPointer)
{
throw vtkm::cont::ErrorBadValue(
"No virtual object was bound before being asked to be executed");
}
if (index >= size)
{
std::string msg = "An invalid DeviceAdapter[id=" + std::to_string(deviceId.GetValue()) +
", name=" + deviceId.GetName() + "] was used when trying to construct a virtual object.";
throw vtkm::cont::ErrorBadType(msg);
}
if (!this->DeviceTransferState[index])
{
const std::string msg =
"VTK-m was asked to transfer a VirtualObjectHandle for execution on DeviceAdapter[id=" +
std::to_string(deviceId.GetValue()) + ", name=" + deviceId.GetName() +
"]. It can't as this VirtualObjectHandle was not constructed/bound with this "
"DeviceAdapter in the list of valid DeviceAdapters.";
throw vtkm::cont::ErrorBadType(msg);
}
return true;
}
}
}
}
VTKM_DEPRECATED_SUPPRESS_END