Blender V4.3
FN_multi_function_param_type.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
24
26
35
36template<ParamCategory Category, typename T> struct ParamTag {
37 static constexpr ParamCategory category = Category;
38 using base_type = T;
39};
40
41class ParamType {
42 public:
48
49 private:
50 InterfaceType interface_type_;
51 DataType data_type_;
52
53 public:
55
56 static ParamType ForSingleInput(const CPPType &type);
57 static ParamType ForVectorInput(const CPPType &base_type);
58 static ParamType ForSingleOutput(const CPPType &type);
59 static ParamType ForVectorOutput(const CPPType &base_type);
60 static ParamType ForMutableSingle(const CPPType &type);
61 static ParamType ForMutableVector(const CPPType &base_type);
62
63 const DataType &data_type() const;
65 ParamCategory category() const;
66
67 bool is_input_or_mutable() const;
68 bool is_output_or_mutable() const;
69 bool is_output() const;
70
71 BLI_STRUCT_EQUALITY_OPERATORS_2(ParamType, interface_type_, data_type_)
72};
73
74/* -------------------------------------------------------------------- */
78inline ParamType::ParamType(InterfaceType interface_type, DataType data_type)
79 : interface_type_(interface_type), data_type_(data_type)
80{
81}
82
87
89{
91}
92
97
99{
101}
102
107
109{
111}
112
113inline const DataType &ParamType::data_type() const
114{
115 return data_type_;
116}
117
119{
120 return interface_type_;
121}
122
124{
125 switch (data_type_.category()) {
126 case DataType::Single: {
127 switch (interface_type_) {
128 case Input:
130 case Output:
132 case Mutable:
134 }
135 break;
136 }
137 case DataType::Vector: {
138 switch (interface_type_) {
139 case Input:
141 case Output:
143 case Mutable:
145 }
146 break;
147 }
148 }
151}
152
154{
155 return ELEM(interface_type_, Input, Mutable);
156}
157
159{
160 return ELEM(interface_type_, Output, Mutable);
161}
162
163inline bool ParamType::is_output() const
164{
165 return interface_type_ == Output;
166}
167
170} // namespace blender::fn::multi_function
#define BLI_assert_unreachable()
Definition BLI_assert.h:97
#define BLI_STRUCT_EQUALITY_OPERATORS_2(Type, m1, m2)
#define ELEM(...)
static ParamType ForVectorInput(const CPPType &base_type)
static ParamType ForSingleOutput(const CPPType &type)
static ParamType ForVectorOutput(const CPPType &base_type)
ParamType(InterfaceType interface_type, DataType data_type)
static ParamType ForMutableSingle(const CPPType &type)
static ParamType ForMutableVector(const CPPType &base_type)
static ParamType ForSingleInput(const CPPType &type)
#define T