VTK-m  2.0
SerializableTypeString.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_SerializableTypeString_h
11 #define vtk_m_cont_SerializableTypeString_h
12 
13 #include <vtkm/Types.h>
14 
15 #include <string>
16 
17 namespace vtkm
18 {
19 namespace cont
20 {
21 
24 template <typename T>
25 struct SerializableTypeString
26 #ifdef VTKM_DOXYGEN_ONLY
27 {
28  static VTKM_CONT const std::string& Get()
29  {
30  static std::string name = "TypeName";
31  return name;
32  }
33 }
34 #endif
35 ;
36 
37 namespace internal
38 {
39 
40 template <typename T, typename... Ts>
41 std::string GetVariadicSerializableTypeString(const T&, const Ts&... ts)
42 {
43  return SerializableTypeString<T>::Get() + "," + GetVariadicSerializableTypeString(ts...);
44 }
45 
46 template <typename T>
47 std::string GetVariadicSerializableTypeString(const T&)
48 {
50 }
51 
52 } // internal
53 
55 template <>
56 struct SerializableTypeString<vtkm::Int8>
57 {
58  static VTKM_CONT const std::string& Get()
59  {
60  static std::string name = "I8";
61  return name;
62  }
63 };
64 
65 template <>
66 struct SerializableTypeString<vtkm::UInt8>
67 {
68  static VTKM_CONT const std::string& Get()
69  {
70  static std::string name = "U8";
71  return name;
72  }
73 };
74 
75 template <>
76 struct SerializableTypeString<vtkm::Int16>
77 {
78  static VTKM_CONT const std::string& Get()
79  {
80  static std::string name = "I16";
81  return name;
82  }
83 };
84 
85 template <>
86 struct SerializableTypeString<vtkm::UInt16>
87 {
88  static VTKM_CONT const std::string& Get()
89  {
90  static std::string name = "U16";
91  return name;
92  }
93 };
94 
95 template <>
96 struct SerializableTypeString<vtkm::Int32>
97 {
98  static VTKM_CONT const std::string& Get()
99  {
100  static std::string name = "I32";
101  return name;
102  }
103 };
104 
105 template <>
106 struct SerializableTypeString<vtkm::UInt32>
107 {
108  static VTKM_CONT const std::string& Get()
109  {
110  static std::string name = "U32";
111  return name;
112  }
113 };
114 
115 template <>
116 struct SerializableTypeString<vtkm::Int64>
117 {
118  static VTKM_CONT const std::string& Get()
119  {
120  static std::string name = "I64";
121  return name;
122  }
123 };
124 
125 template <>
126 struct SerializableTypeString<vtkm::UInt64>
127 {
128  static VTKM_CONT const std::string& Get()
129  {
130  static std::string name = "U64";
131  return name;
132  }
133 };
134 
135 template <>
136 struct SerializableTypeString<vtkm::Float32>
137 {
138  static VTKM_CONT const std::string& Get()
139  {
140  static std::string name = "F32";
141  return name;
142  }
143 };
144 
145 template <>
146 struct SerializableTypeString<vtkm::Float64>
147 {
148  static VTKM_CONT const std::string& Get()
149  {
150  static std::string name = "F64";
151  return name;
152  }
153 };
154 
155 template <>
156 struct SerializableTypeString<bool>
157 {
158  static VTKM_CONT const std::string& Get()
159  {
160  static std::string name = "B8";
161  return name;
162  }
163 };
164 
165 template <>
166 struct SerializableTypeString<char>
167 {
168  static VTKM_CONT const std::string& Get()
169  {
170  static std::string name = "C8";
171  return name;
172  }
173 };
174 
175 template <>
176 struct SerializableTypeString<VTKM_UNUSED_INT_TYPE>
177 {
178  static VTKM_CONT const std::string& Get()
179  {
180  static std::string name = "L" + std::to_string(sizeof(VTKM_UNUSED_INT_TYPE) * 8);
181  return name;
182  }
183 };
184 
185 template <>
186 struct SerializableTypeString<unsigned VTKM_UNUSED_INT_TYPE>
187 {
188  static VTKM_CONT const std::string& Get()
189  {
190  static std::string name = "UL" + std::to_string(sizeof(unsigned VTKM_UNUSED_INT_TYPE) * 8);
191  return name;
192  }
193 };
194 
195 template <typename T, vtkm::IdComponent NumComponents>
196 struct SerializableTypeString<vtkm::Vec<T, NumComponents>>
197 {
198  static VTKM_CONT const std::string& Get()
199  {
200  static std::string name =
201  "V<" + SerializableTypeString<T>::Get() + "," + std::to_string(NumComponents) + ">";
202  return name;
203  }
204 };
205 
206 template <typename T1, typename T2>
207 struct SerializableTypeString<vtkm::Pair<T1, T2>>
208 {
209  static VTKM_CONT const std::string& Get()
210  {
211  static std::string name = "vtkm::Pair<" + SerializableTypeString<T1>::Get() + "," +
213  return name;
214  }
215 };
216 }
217 } // vtkm::cont
219 
220 #endif // vtk_m_cont_SerializableTypeString_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
vtkm::Get
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT auto Get(const vtkm::Tuple< Ts... > &tuple) -> decltype(tuple.template Get< Index >())
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:83
vtkm::Int16
int16_t Int16
Definition: Types.h:158
vtkm::Vec
class VTKM_ALWAYS_EXPORT Vec
Definition: Types.h:319
vtkm::Int8
int8_t Int8
Definition: Types.h:156
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::UInt8
uint8_t UInt8
Definition: Types.h:157
vtkm::UInt32
uint32_t UInt32
Definition: Types.h:161
vtkm::Float32
float Float32
Definition: Types.h:154
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::UInt16
uint16_t UInt16
Definition: Types.h:159