2018-06-08 15:56:40 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-06-08 15:56:40 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
2019-02-28 18:15:27 +00:00
|
|
|
#ifndef vtk_m_cont_SerializableTypeString_h
|
|
|
|
#define vtk_m_cont_SerializableTypeString_h
|
2018-06-08 15:56:40 +00:00
|
|
|
|
|
|
|
#include <vtkm/Types.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
|
|
|
|
/// \brief A traits class that gives a unique name for a type. This class
|
|
|
|
/// should be specialized for every type that has to be serialized by diy.
|
|
|
|
template <typename T>
|
2019-02-28 18:15:27 +00:00
|
|
|
struct SerializableTypeString
|
2018-06-08 15:56:40 +00:00
|
|
|
#ifdef VTKM_DOXYGEN_ONLY
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "TypeName";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
|
|
|
namespace internal
|
|
|
|
{
|
|
|
|
|
|
|
|
template <typename T, typename... Ts>
|
2019-02-28 18:15:27 +00:00
|
|
|
std::string GetVariadicSerializableTypeString(const T&, const Ts&... ts)
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
2019-02-28 18:15:27 +00:00
|
|
|
return SerializableTypeString<T>::Get() + "," + GetVariadicSerializableTypeString(ts...);
|
2018-06-08 15:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2019-02-28 18:15:27 +00:00
|
|
|
std::string GetVariadicSerializableTypeString(const T&)
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
2019-02-28 18:15:27 +00:00
|
|
|
return SerializableTypeString<T>::Get();
|
2018-06-08 15:56:40 +00:00
|
|
|
}
|
|
|
|
|
2020-11-11 15:07:14 +00:00
|
|
|
} // internal
|
2018-06-08 15:56:40 +00:00
|
|
|
|
2020-11-11 15:07:14 +00:00
|
|
|
/// @cond SERIALIZATION
|
2020-11-12 23:38:06 +00:00
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<vtkm::Int8>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "I8";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<vtkm::UInt8>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "U8";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<vtkm::Int16>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "I16";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<vtkm::UInt16>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "U16";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<vtkm::Int32>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "I32";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<vtkm::UInt32>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "U32";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<vtkm::Int64>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "I64";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<vtkm::UInt64>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "U64";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
2018-06-08 15:56:40 +00:00
|
|
|
|
|
|
|
template <>
|
2019-02-28 18:15:27 +00:00
|
|
|
struct SerializableTypeString<vtkm::Float32>
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "F32";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
2019-02-28 18:15:27 +00:00
|
|
|
struct SerializableTypeString<vtkm::Float64>
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "F64";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-07 20:15:48 +00:00
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<bool>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "B8";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-12 23:38:06 +00:00
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<char>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "C8";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<VTKM_UNUSED_INT_TYPE>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "L" + std::to_string(sizeof(VTKM_UNUSED_INT_TYPE) * 8);
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct SerializableTypeString<unsigned VTKM_UNUSED_INT_TYPE>
|
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "UL" + std::to_string(sizeof(unsigned VTKM_UNUSED_INT_TYPE) * 8);
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-06-08 15:56:40 +00:00
|
|
|
template <typename T, vtkm::IdComponent NumComponents>
|
2019-02-28 18:15:27 +00:00
|
|
|
struct SerializableTypeString<vtkm::Vec<T, NumComponents>>
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name =
|
2019-02-28 18:15:27 +00:00
|
|
|
"V<" + SerializableTypeString<T>::Get() + "," + std::to_string(NumComponents) + ">";
|
2018-06-08 15:56:40 +00:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T1, typename T2>
|
2019-02-28 18:15:27 +00:00
|
|
|
struct SerializableTypeString<vtkm::Pair<T1, T2>>
|
2018-06-08 15:56:40 +00:00
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
2019-02-28 18:15:27 +00:00
|
|
|
static std::string name = "vtkm::Pair<" + SerializableTypeString<T1>::Get() + "," +
|
|
|
|
SerializableTypeString<T2>::Get() + ">";
|
2018-06-08 15:56:40 +00:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} // vtkm::cont
|
2019-09-12 21:19:36 +00:00
|
|
|
/// @endcond SERIALIZATION
|
2018-06-08 15:56:40 +00:00
|
|
|
|
2019-02-28 18:15:27 +00:00
|
|
|
#endif // vtk_m_cont_SerializableTypeString_h
|