Viskores  1.0
FastVec.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_exec_internal_FastVec_h
19 #define viskores_exec_internal_FastVec_h
20 
21 #include <viskores/Types.h>
22 #include <viskores/VecVariable.h>
23 
24 namespace viskores
25 {
26 namespace exec
27 {
28 namespace internal
29 {
30 
38 template <typename VecType, viskores::IdComponent MaxSize>
39 class FastVec
40 {
41 public:
43 
44  explicit VISKORES_EXEC FastVec(const VecType& vec)
45  : Vec(vec)
46  {
47  }
48 
49  VISKORES_EXEC const Type& Get() const { return this->Vec; }
50 
51 private:
52  Type Vec;
53 };
54 
55 template <typename ComponentType,
56  viskores::IdComponent NumComponents,
57  viskores::IdComponent MaxSize>
58 class FastVec<viskores::Vec<ComponentType, NumComponents>, MaxSize>
59 {
60 public:
62 
63  explicit VISKORES_EXEC FastVec(const Type& vec)
64  : Vec(vec)
65  {
66  VISKORES_ASSERT(vec.GetNumberOfComponents() <= MaxSize);
67  }
68 
69  VISKORES_EXEC const Type& Get() const { return this->Vec; }
70 
71 private:
72  const Type& Vec;
73 };
74 
75 template <typename ComponentType, viskores::IdComponent MaxSize1, viskores::IdComponent MaxSize2>
76 class FastVec<viskores::VecVariable<ComponentType, MaxSize1>, MaxSize2>
77 {
78 public:
80 
81  explicit VISKORES_EXEC FastVec(const Type& vec)
82  : Vec(vec)
83  {
84  VISKORES_ASSERT(vec.GetNumberOfComponents() <= MaxSize2);
85  }
86 
87  VISKORES_EXEC const Type& Get() const { return this->Vec; }
88 
89 private:
90  const Type& Vec;
91 };
92 }
93 }
94 } // viskores::exec::internal
95 
96 #endif // viskores_exec_internal_FastVec_h
Types.h
viskores::VecVariable
A short variable-length array with maximum length.
Definition: VecVariable.h:38
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
VISKORES_ASSERT
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
VecVariable.h
viskores::Get
auto Get(const viskores::Tuple< Ts... > &tuple)
Retrieve the object from a viskores::Tuple at the given index.
Definition: Tuple.h:89
viskores::Vec
A short fixed-length array.
Definition: Types.h:365
VISKORES_EXEC
#define VISKORES_EXEC
Definition: ExportMacros.h:59