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