18 #ifndef viskores_cont_Storage_h
19 #define viskores_cont_Storage_h
21 #define VISKORES_STORAGE_ERROR -2
22 #define VISKORES_STORAGE_UNDEFINED -1
23 #define VISKORES_STORAGE_BASIC 1
25 #ifndef VISKORES_STORAGE
26 #define VISKORES_STORAGE VISKORES_STORAGE_BASIC
45 #ifdef VISKORES_DOXYGEN_ONLY
46 struct VISKORES_ALWAYS_EXPORT StorageTag___
78 #endif // VISKORES_DOXYGEN_ONLY
83 struct UndefinedStorage
95 struct UndefinedArrayPortal
105 template <
typename T,
class StorageTag>
107 #ifndef VISKORES_DOXYGEN_ONLY
108 :
public viskores::cont::internal::UndefinedStorage
111 using ReadPortalType = viskores::cont::internal::detail::UndefinedArrayPortal<T>;
112 using WritePortalType = viskores::cont::internal::detail::UndefinedArrayPortal<T>;
114 #else //VISKORES_DOXYGEN_ONLY
123 using ReadPortalType = viskores::internal::ArrayPortalBasicRead<T>;
127 using WritePortalType = viskores::internal::ArrayPortalBasicWrite<T>;
135 VISKORES_CONT static std::vector<viskores::cont::internal::Buffer> CreateBuffers();
143 const std::vector<viskores::cont::internal::Buffer>& buffers,
149 const std::vector<viskores::cont::internal::Buffer>& buffers);
153 VISKORES_CONT static void Fill(
const std::vector<viskores::cont::internal::Buffer>& buffers,
154 const ValueType& fillValue,
162 const std::vector<viskores::cont::internal::Buffer>& buffers,
169 const std::vector<viskores::cont::internal::Buffer>& buffers,
173 #endif // VISKORES_DOXYGEN_ONLY
178 VISKORES_CONT_EXPORT
void StorageNoResizeImpl(
viskores::Id currentNumValues,
180 std::string storageTagName);
184 template <
typename StorageType>
185 struct StorageTraits;
187 template <
typename T,
typename S>
188 struct StorageTraits<
viskores::cont::internal::Storage<T, S>>
194 #define VISKORES_STORAGE_NO_RESIZE \
195 VISKORES_CONT static void ResizeBuffers( \
196 viskores::Id numValues, \
197 const std::vector<viskores::cont::internal::Buffer>& buffers, \
198 viskores::CopyFlag, \
199 viskores::cont::Token&) \
201 viskores::cont::internal::detail::StorageNoResizeImpl( \
202 GetNumberOfValues(buffers), \
204 viskores::cont::TypeToString< \
205 typename viskores::cont::internal::StorageTraits<Storage>::Tag>()); \
207 using ResizeBuffersEatComma = void
209 #define VISKORES_STORAGE_NO_WRITE_PORTAL \
210 using WritePortalType = viskores::internal::ArrayPortalDummy< \
211 typename viskores::cont::internal::StorageTraits<Storage>::ValueType>; \
212 VISKORES_CONT static void Fill( \
213 const std::vector<viskores::cont::internal::Buffer>&, \
214 const typename viskores::cont::internal::StorageTraits<Storage>::ValueType&, \
217 viskores::cont::Token&) \
219 throw viskores::cont::ErrorBadAllocation( \
220 "Cannot write to arrays with storage type of " + \
221 viskores::cont::TypeToString< \
222 typename viskores::cont::internal::StorageTraits<Storage>::Tag>()); \
224 VISKORES_CONT static WritePortalType CreateWritePortal( \
225 const std::vector<viskores::cont::internal::Buffer>&, \
226 viskores::cont::DeviceAdapterId, \
227 viskores::cont::Token&) \
229 throw viskores::cont::ErrorBadAllocation( \
230 "Cannot write to arrays with storage type of " + \
231 viskores::cont::TypeToString< \
232 typename viskores::cont::internal::StorageTraits<Storage>::Tag>()); \
234 using CreateWritePortalEatComma = void
240 #endif //viskores_cont_Storage_h