TypeListTag.h 7.81 KB
Newer Older
1 2 3 4 5 6 7 8
//============================================================================
//  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.
//
9
//  Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10
//  Copyright 2014 UT-Battelle, LLC.
11
//  Copyright 2014 Los Alamos National Security.
12
//
13
//  Under the terms of Contract DE-NA0003525 with NTESS,
14 15 16 17 18 19 20 21 22 23
//  the U.S. Government retains certain rights in this software.
//
//  Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
//  Laboratory (LANL), the U.S. Government retains certain rights in
//  this software.
//============================================================================
#ifndef vtk_m_TypeListTag_h
#define vtk_m_TypeListTag_h

#ifndef VTKM_DEFAULT_TYPE_LIST_TAG
24
#define VTKM_DEFAULT_TYPE_LIST_TAG ::vtkm::TypeListTagCommon
25 26 27 28 29
#endif

#include <vtkm/ListTag.h>
#include <vtkm/Types.h>

30 31
namespace vtkm
{
32

33 34
/// A list containing the type vtkm::Id.
///
35
struct VTKM_ALWAYS_EXPORT TypeListTagId : vtkm::ListTagBase<vtkm::Id>
36 37
{
};
38 39 40

/// A list containing the type vtkm::Id2.
///
41
struct VTKM_ALWAYS_EXPORT TypeListTagId2 : vtkm::ListTagBase<vtkm::Id2>
42 43
{
};
44 45 46

/// A list containing the type vtkm::Id3.
///
47
struct VTKM_ALWAYS_EXPORT TypeListTagId3 : vtkm::ListTagBase<vtkm::Id3>
48 49
{
};
50

51 52
/// A list containing the type vtkm::IdComponent
///
53
struct VTKM_ALWAYS_EXPORT TypeListTagIdComponent : vtkm::ListTagBase<vtkm::IdComponent>
54 55
{
};
56

57 58 59
/// A list containing types used to index arrays. Contains vtkm::Id, vtkm::Id2,
/// and vtkm::Id3.
///
60
struct VTKM_ALWAYS_EXPORT TypeListTagIndex : vtkm::ListTagBase<vtkm::Id, vtkm::Id2, vtkm::Id3>
61 62
{
};
63

64 65 66
/// A list containing types used for scalar fields. Specifically, contains
/// floating point numbers of different widths (i.e. vtkm::Float32 and
/// vtkm::Float64).
67
struct VTKM_ALWAYS_EXPORT TypeListTagFieldScalar : vtkm::ListTagBase<vtkm::Float32, vtkm::Float64>
68 69
{
};
70 71 72 73

/// A list containing types for values for fields with two dimensional
/// vectors.
///
74
struct VTKM_ALWAYS_EXPORT TypeListTagFieldVec2
75 76 77
  : vtkm::ListTagBase<vtkm::Vec<vtkm::Float32, 2>, vtkm::Vec<vtkm::Float64, 2>>
{
};
78 79 80 81

/// A list containing types for values for fields with three dimensional
/// vectors.
///
82
struct VTKM_ALWAYS_EXPORT TypeListTagFieldVec3
83 84 85
  : vtkm::ListTagBase<vtkm::Vec<vtkm::Float32, 3>, vtkm::Vec<vtkm::Float64, 3>>
{
};
86 87 88 89

/// A list containing types for values for fields with four dimensional
/// vectors.
///
90
struct VTKM_ALWAYS_EXPORT TypeListTagFieldVec4
91 92 93
  : vtkm::ListTagBase<vtkm::Vec<vtkm::Float32, 4>, vtkm::Vec<vtkm::Float64, 4>>
{
};
94

95 96 97 98
/// A list containing common types for floating-point vectors. Specifically contains
/// floating point vectors of size 2, 3, and 4 with floating point components.
/// Scalars are not included.
///
99 100 101 102 103 104 105
struct VTKM_ALWAYS_EXPORT TypeListTagFloatVec
  : vtkm::ListTagBase<vtkm::Vec<vtkm::Float32, 2>,
                      vtkm::Vec<vtkm::Float64, 2>,
                      vtkm::Vec<vtkm::Float32, 3>,
                      vtkm::Vec<vtkm::Float64, 3>,
                      vtkm::Vec<vtkm::Float32, 4>,
                      vtkm::Vec<vtkm::Float64, 4>>
106 107 108
{
};

109 110 111 112
/// A list containing common types for values in fields. Specifically contains
/// floating point scalars and vectors of size 2, 3, and 4 with floating point
/// components.
///
113 114 115 116 117 118 119 120 121
struct VTKM_ALWAYS_EXPORT TypeListTagField
  : vtkm::ListTagBase<vtkm::Float32,
                      vtkm::Float64,
                      vtkm::Vec<vtkm::Float32, 2>,
                      vtkm::Vec<vtkm::Float64, 2>,
                      vtkm::Vec<vtkm::Float32, 3>,
                      vtkm::Vec<vtkm::Float64, 3>,
                      vtkm::Vec<vtkm::Float32, 4>,
                      vtkm::Vec<vtkm::Float64, 4>>
122 123
{
};
124

125 126
/// A list of all scalars defined in vtkm/Types.h. A scalar is a type that
/// holds a single number.
127
///
128 129 130 131 132 133 134 135 136 137 138
struct VTKM_ALWAYS_EXPORT TypeListTagScalarAll
  : vtkm::ListTagBase<vtkm::Int8,
                      vtkm::UInt8,
                      vtkm::Int16,
                      vtkm::UInt16,
                      vtkm::Int32,
                      vtkm::UInt32,
                      vtkm::Int64,
                      vtkm::UInt64,
                      vtkm::Float32,
                      vtkm::Float64>
139 140
{
};
141 142 143 144 145

/// A list of the most commonly use Vec classes. Specifically, these are
/// vectors of size 2, 3, or 4 containing either unsigned bytes, signed
/// integers of 32 or 64 bits, or floating point values of 32 or 64 bits.
///
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
struct VTKM_ALWAYS_EXPORT TypeListTagVecCommon
  : vtkm::ListTagBase<vtkm::Vec<vtkm::UInt8, 2>,
                      vtkm::Vec<vtkm::Int32, 2>,
                      vtkm::Vec<vtkm::Int64, 2>,
                      vtkm::Vec<vtkm::Float32, 2>,
                      vtkm::Vec<vtkm::Float64, 2>,
                      vtkm::Vec<vtkm::UInt8, 3>,
                      vtkm::Vec<vtkm::Int32, 3>,
                      vtkm::Vec<vtkm::Int64, 3>,
                      vtkm::Vec<vtkm::Float32, 3>,
                      vtkm::Vec<vtkm::Float64, 3>,
                      vtkm::Vec<vtkm::UInt8, 4>,
                      vtkm::Vec<vtkm::Int32, 4>,
                      vtkm::Vec<vtkm::Int64, 4>,
                      vtkm::Vec<vtkm::Float32, 4>,
                      vtkm::Vec<vtkm::Float64, 4>>
162 163 164 165 166
{
};

namespace internal
{
167 168 169 170 171

/// A list of uncommon Vec classes with length up to 4. This is not much
/// use in general, but is used when joined with \c TypeListTagVecCommon
/// to get a list of all vectors up to size 4.
///
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
struct VTKM_ALWAYS_EXPORT TypeListTagVecUncommon
  : vtkm::ListTagBase<vtkm::Vec<vtkm::Int8, 2>,
                      vtkm::Vec<vtkm::Int16, 2>,
                      vtkm::Vec<vtkm::UInt16, 2>,
                      vtkm::Vec<vtkm::UInt32, 2>,
                      vtkm::Vec<vtkm::UInt64, 2>,
                      vtkm::Vec<vtkm::Int8, 3>,
                      vtkm::Vec<vtkm::Int16, 3>,
                      vtkm::Vec<vtkm::UInt16, 3>,
                      vtkm::Vec<vtkm::UInt32, 3>,
                      vtkm::Vec<vtkm::UInt64, 3>,
                      vtkm::Vec<vtkm::Int8, 4>,
                      vtkm::Vec<vtkm::Int16, 4>,
                      vtkm::Vec<vtkm::UInt16, 4>,
                      vtkm::Vec<vtkm::UInt32, 4>,
                      vtkm::Vec<vtkm::UInt64, 4>>
188 189
{
};
190 191 192 193 194 195

} // namespace internal

/// A list of all vector classes with standard types as components and
/// lengths between 2 and 4.
///
196
struct VTKM_ALWAYS_EXPORT TypeListTagVecAll
197 198 199
  : vtkm::ListTagJoin<vtkm::TypeListTagVecCommon, vtkm::internal::TypeListTagVecUncommon>
{
};
200 201 202 203 204

/// A list of all basic types listed in vtkm/Types.h. Does not include all
/// possible VTK-m types like arbitrarily typed and sized Vecs (only up to
/// length 4) or math types like matrices.
///
205 206
struct VTKM_ALWAYS_EXPORT TypeListTagAll
  : vtkm::ListTagJoin<vtkm::TypeListTagScalarAll, vtkm::TypeListTagVecAll>
207 208
{
};
209

210
/// A list of the most commonly used types across multiple domains. Includes
211
/// integers, floating points, and 3 dimensional vectors of floating points.
212
///
213 214 215 216 217 218 219
struct VTKM_ALWAYS_EXPORT TypeListTagCommon
  : vtkm::ListTagBase<vtkm::Int32,
                      vtkm::Int64,
                      vtkm::Float32,
                      vtkm::Float64,
                      vtkm::Vec<vtkm::Float32, 3>,
                      vtkm::Vec<vtkm::Float64, 3>>
220 221
{
};
222

223 224 225 226
// Special implementation of ListContains for TypeListTagAll to always be
// true. Although TypeListTagAll is necessarily finite, the point is to
// be all inclusive. Besides, this should speed up the compilation when
// checking a list that should contain everything.
227
template<typename Type>
228 229
struct ListContains<vtkm::TypeListTagAll, Type>
{
230
  static constexpr bool value = true;
231 232
};

233 234 235
} // namespace vtkm

#endif //vtk_m_TypeListTag_h