1 // Copyright (c) 2017-2021, Lawrence Livermore National Security, LLC and
2 // other Axom Project Developers. See the top-level LICENSE file for details.
3 //
4 // SPDX-License-Identifier: (BSD-3-Clause)
5 
6 #ifndef MINT_FIELDTYPES_HPP_
7 #define MINT_FIELDTYPES_HPP_
8 
9 #include "axom/core/Types.hpp"  // for axom type definitions
10 
11 namespace axom
12 {
13 namespace mint
14 {
15 /*!
16  * \brief Enumerates the set of allowable field types.
17  */
18 enum FieldType
19 {
20   UNDEFINED_FIELD_TYPE = -1,  //!< UNDEFINED_FIELD_TYPE
21 
22   FLOAT_FIELD_TYPE,   //!< single-precision floating point field type
23   DOUBLE_FIELD_TYPE,  //!< double-precision floating point field type
24   INT32_FIELD_TYPE,   //!< fixed width 32-bit integer field type
25   INT64_FIELD_TYPE,   //!< fixed width 64-bit integer field type
26 
27   NUMBER_OF_FIELD_TYPES  //!< NUMBER_OF_FIELD_TYPES
28 };
29 
30 /*!
31  * \brief Field traits struct to map a C++ primitive type to a FieldType
32  */
33 template <typename FieldType>
34 struct field_traits
35 {
typeaxom::mint::field_traits36   static constexpr int type() { return UNDEFINED_FIELD_TYPE; };
37 };
38 
39 /// \name Specialization of field_traits
40 /// @{
41 
42 //------------------------------------------------------------------------------
43 template <>
44 struct field_traits<axom::float32>
45 {
typeaxom::mint::field_traits46   static constexpr int type() { return FLOAT_FIELD_TYPE; };
47 };
48 
49 //------------------------------------------------------------------------------
50 template <>
51 struct field_traits<axom::float64>
52 {
typeaxom::mint::field_traits53   static constexpr int type() { return DOUBLE_FIELD_TYPE; };
54 };
55 
56 //------------------------------------------------------------------------------
57 template <>
58 struct field_traits<axom::int32>
59 {
typeaxom::mint::field_traits60   static constexpr int type() { return INT32_FIELD_TYPE; };
61 };
62 
63 //------------------------------------------------------------------------------
64 template <>
65 struct field_traits<axom::int64>
66 {
typeaxom::mint::field_traits67   static constexpr int type() { return INT64_FIELD_TYPE; };
68 };
69 
70 /// @}
71 
72 } /* namespace mint */
73 } /* namespace axom */
74 
75 #endif /* MINT_FIELDTYPES_HPP_ */
76