Wildmeshing Toolkit
AttributeType.hpp
Go to the documentation of this file.
1
#pragma once
2
#include <
wmtk/utils/Rational.hpp
>
3
4
namespace
wmtk::attribute
{
5
enum class
AttributeType
{
Char
= 0,
Int64
= 1,
Double
= 2,
Rational
= 3 };
6
7
template
<AttributeType AT>
8
struct
type_from_attribute_type_enum
9
{
10
};
11
template
<>
12
struct
type_from_attribute_type_enum
<
AttributeType
::
Char
>
13
{
14
using
type
= char;
15
};
16
template
<>
17
struct
type_from_attribute_type_enum
<
AttributeType
::
Double
>
18
{
19
using
type
= double;
20
};
21
template
<>
22
struct
type_from_attribute_type_enum
<
AttributeType
::
Int64
>
23
{
24
using
type
= int64_t;
25
};
26
template
<>
27
struct
type_from_attribute_type_enum
<
AttributeType
::
Rational
>
28
{
29
using
type
=
wmtk::Rational
;
30
};
31
32
template
<AttributeType AT>
33
using
type_from_attribute_type_enum_t
=
typename
type_from_attribute_type_enum<AT>::type
;
34
35
template
<
typename
T>
36
inline
constexpr
auto
attribute_type_enum_from_type
() ->
AttributeType
37
{
38
if
constexpr (std::is_same_v<T, char>) {
39
return
AttributeType::Char
;
40
}
else
if
constexpr (std::is_same_v<T, double>) {
41
return
AttributeType::Double
;
42
}
else
if
constexpr (std::is_same_v<T, int64_t>) {
43
return
AttributeType::Int64
;
44
}
else
if
constexpr (std::is_same_v<T, wmtk::Rational>) {
45
return
AttributeType::Rational
;
46
}
47
// If a compiler complains about the potentiality of no return value then a type accepted by the
48
// HAndleVariant is not being represented properly. If the comppiler is simply unhappy to not
49
// see a return then we should hack a default return value in an else statement with an asswert
50
// :(.
51
else
{
52
static_assert(std::is_same_v<T, char>);
53
return
AttributeType::Char
;
54
}
55
}
56
}
// namespace wmtk::attribute
Rational.hpp
wmtk::Rational
Definition:
Rational.hpp:13
wmtk::attribute
Definition:
Accessor.hpp:17
wmtk::attribute::type_from_attribute_type_enum_t
typename type_from_attribute_type_enum< AT >::type type_from_attribute_type_enum_t
Definition:
AttributeType.hpp:33
wmtk::attribute::AttributeType
AttributeType
Definition:
AttributeType.hpp:5
wmtk::attribute::AttributeType::Rational
@ Rational
wmtk::attribute::AttributeType::Char
@ Char
wmtk::attribute::AttributeType::Double
@ Double
wmtk::attribute::AttributeType::Int64
@ Int64
wmtk::attribute::attribute_type_enum_from_type
constexpr auto attribute_type_enum_from_type() -> AttributeType
Definition:
AttributeType.hpp:36
wmtk::attribute::type_from_attribute_type_enum< AttributeType::Char >::type
char type
Definition:
AttributeType.hpp:14
wmtk::attribute::type_from_attribute_type_enum< AttributeType::Double >::type
double type
Definition:
AttributeType.hpp:19
wmtk::attribute::type_from_attribute_type_enum< AttributeType::Int64 >::type
int64_t type
Definition:
AttributeType.hpp:24
wmtk::attribute::type_from_attribute_type_enum
Definition:
AttributeType.hpp:9
src
wmtk
attribute
AttributeType.hpp
Generated by
1.9.1