VTK-m  2.0
TransportTagArrayInOut.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_cont_arg_TransportTagArrayInOut_h
11 #define vtk_m_cont_arg_TransportTagArrayInOut_h
12 
13 #include <vtkm/Deprecated.h>
14 #include <vtkm/Types.h>
15 
16 #include <vtkm/cont/ArrayHandle.h>
17 
19 
20 namespace vtkm
21 {
22 namespace cont
23 {
24 namespace arg
25 {
26 
34 {
35 };
36 
37 template <typename ContObjectType, typename Device>
38 struct Transport<vtkm::cont::arg::TransportTagArrayInOut, ContObjectType, Device>
39 {
40  // MSVC will issue deprecation warnings here if this template is instantiated with
41  // a deprecated class even if the template is used from a section of code where
42  // deprecation warnings are suppressed. This is annoying behavior since this template
43  // has no control over what class it is used with. To get around it, we have to
44  // suppress all deprecation warnings here.
45 #ifdef VTKM_MSVC
47 #endif
48 
49  // If you get a compile error here, it means you tried to use an object that
50  // is not an array handle as an argument that is expected to be one.
51  VTKM_IS_ARRAY_HANDLE(ContObjectType);
52 
53  using ExecObjectType = decltype(
54  std::declval<ContObjectType>().PrepareForInPlace(Device(), std::declval<vtkm::cont::Token&>()));
55 
56  template <typename InputDomainType>
57  VTKM_CONT ExecObjectType operator()(ContObjectType& object,
58  const InputDomainType& vtkmNotUsed(inputDomain),
59  vtkm::Id vtkmNotUsed(inputRange),
60  vtkm::Id outputRange,
61  vtkm::cont::Token& token) const
62  {
63  if (object.GetNumberOfValues() != outputRange)
64  {
65  throw vtkm::cont::ErrorBadValue("Input/output array to worklet invocation the wrong size.");
66  }
67 
68  return object.PrepareForInPlace(Device(), token);
69  }
70 
71 #ifdef VTKM_MSVC
73 #endif
74 };
75 }
76 }
77 } // namespace vtkm::cont::arg
78 
79 #endif //vtk_m_cont_arg_TransportTagArrayInOut_h
ArrayHandle.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
vtkm::cont::arg::Transport< vtkm::cont::arg::TransportTagArrayInOut, ContObjectType, Device >::operator()
VTKM_CONT ExecObjectType operator()(ContObjectType &object, const InputDomainType &vtkmNotUsed(inputDomain), vtkm::Id vtkmNotUsed(inputRange), vtkm::Id outputRange, vtkm::cont::Token &token) const
Definition: TransportTagArrayInOut.h:57
vtkm::cont::arg::Transport< vtkm::cont::arg::TransportTagArrayInOut, ContObjectType, Device >::ExecObjectType
decltype(std::declval< ContObjectType >().PrepareForInPlace(Device(), std::declval< vtkm::cont::Token & >())) ExecObjectType
Definition: TransportTagArrayInOut.h:54
vtkm::cont::arg::TransportTagArrayInOut
Transport tag for in-place arrays.
Definition: TransportTagArrayInOut.h:33
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
VTKM_DEPRECATED_SUPPRESS_END
#define VTKM_DEPRECATED_SUPPRESS_END
Definition: Deprecated.h:123
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
VTKM_IS_ARRAY_HANDLE
#define VTKM_IS_ARRAY_HANDLE(T)
Definition: ArrayHandle.h:132
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkmNotUsed
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
Transport.h
VTKM_DEPRECATED_SUPPRESS_BEGIN
#define VTKM_DEPRECATED_SUPPRESS_BEGIN
Definition: Deprecated.h:122
vtkm::cont::ErrorBadValue
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
Deprecated.h
vtkm::cont::arg::Transport
Class for transporting from the control to the execution environment.
Definition: Transport.h:38