13 #pragma warning(disable:2586)
17 using PropBase = std::variant<int64, double, bool, string, DVect2,
22 using PropBase::PropBase;
24 enum class Type { Int, Double, Bool, String, DVect2,
25 DVect3, I64Vect2, I64Vect3,
Matrix, DAVect2,
28 Type type()
const {
return static_cast<Type
>(index()); }
35 bool canConvert()
const { static_assert(
sizeof(T)==0);
return false; }
40 bool canConvertType()
const {
return canConvert<decltype(std::get<static_cast<int>(t)>(*this))>(); }
44 T to()
const { static_assert(
sizeof(T)==0);
return false; }
48 auto toType()
const {
return to<decltype(std::get<static_cast<int>(t)>(*this))>(); }
53 typename std::tuple<T,bool> toTest()
const;
57 typename std::variant_alternative_t<static_cast<int>(t),
Property> toTestType()
const;
63 template <>
BASE_EXPORT bool Property::canConvert<int64>()
const;
64 template <>
BASE_EXPORT bool Property::canConvert<double>()
const;
65 template <>
BASE_EXPORT bool Property::canConvert<bool>()
const;
66 template <>
BASE_EXPORT bool Property::canConvert<string>()
const;
67 template <>
BASE_EXPORT bool Property::canConvert<DVect2>()
const;
68 template <>
BASE_EXPORT bool Property::canConvert<DVect3>()
const;
69 template <>
BASE_EXPORT bool Property::canConvert<I64Vect2>()
const;
70 template <>
BASE_EXPORT bool Property::canConvert<I64Vect3>()
const;
71 template <>
BASE_EXPORT bool Property::canConvert<itasca::Mat>()
const;
72 template <>
BASE_EXPORT bool Property::canConvert<DAVect2>()
const;
73 template <>
BASE_EXPORT bool Property::canConvert<DAVect3>()
const;
74 template <>
BASE_EXPORT bool Property::canConvert<Quat2>()
const;
75 template <>
BASE_EXPORT bool Property::canConvert<Quat3>()
const;
76 template <>
BASE_EXPORT bool Property::canConvert<SymTensor>()
const;
78 template <>
BASE_EXPORT int64 Property::to<int64>()
const;
79 template <>
BASE_EXPORT double Property::to<double>()
const;
80 template <>
BASE_EXPORT bool Property::to<bool>()
const;
81 template <>
BASE_EXPORT string Property::to<string>()
const;
82 template <>
BASE_EXPORT DVect2 Property::to<DVect2>()
const;
83 template <>
BASE_EXPORT DVect3 Property::to<DVect3>()
const;
84 template <>
BASE_EXPORT I64Vect2 Property::to<I64Vect2>()
const;
85 template <>
BASE_EXPORT I64Vect3 Property::to<I64Vect3>()
const;
87 template <>
BASE_EXPORT DAVect2 Property::to<DAVect2>()
const;
88 template <>
BASE_EXPORT DAVect3 Property::to<DAVect3>()
const;
91 template <>
BASE_EXPORT SymTensor Property::to<SymTensor>()
const;
96 typename std::tuple<T,bool> Property::toTest()
const {
97 bool b = canConvert<T>();
103 template <Property::Type t>
104 typename std::variant_alternative_t<static_cast<int>(t),Property> Property::toTestType()
const {
105 using target_type = decltype(std::get<
static_cast<int>(t)>(*
this));
106 using return_type = std::tuple<target_type,bool>;
107 bool b = canConvert<target_type>();
108 if (b)
return return_type(to<target_type>(),
true);
109 return return_type(target_type{},
false);
122 template <Property::Type t>
123 const auto &get(
const Property &v) {
return std::get<static_cast<int>(t)>(v); }
132 PropDesc(
const string &name,Property::Type type,UVect2 size) : name_(name), type_(type), size_(size) { }
135 Property::Type type_ = Property::Type::Int;
136 UVect2 size_ = UVect2(0);
QString helper functions, plus some additions.
A template-based matrix class, size fixed at compile time. Defaults to symmetric sized matrix.
Definition: matrix.h:22
2D quaternion-like utility class. In this case only the angle (in radians) is stored as opposed to th...
Definition: quat.h:20
3D quaternion utility class.
Definition: quat.h:109
Definition: property.h:20
#define BASE_EXPORT
Definition: basedef.h:24
2D and 3D quaternion utility classes.
Definition: property.h:130
2D and 3D vector utility classes.