Blender  V2.93
FN_multi_function_param_type.hh
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
36 
37 namespace blender::fn {
38 
39 class MFParamType {
40  public:
45  };
46 
47  enum Category {
54  };
55 
56  private:
57  InterfaceType interface_type_;
58  MFDataType data_type_;
59 
60  public:
62  : interface_type_(interface_type), data_type_(data_type)
63  {
64  }
65 
67  {
68  return MFParamType(InterfaceType::Input, MFDataType::ForSingle(type));
69  }
70 
71  static MFParamType ForVectorInput(const CPPType &base_type)
72  {
73  return MFParamType(InterfaceType::Input, MFDataType::ForVector(base_type));
74  }
75 
77  {
79  }
80 
81  static MFParamType ForVectorOutput(const CPPType &base_type)
82  {
84  }
85 
87  {
88  return MFParamType(InterfaceType::Mutable, MFDataType::ForSingle(type));
89  }
90 
91  static MFParamType ForMutableVector(const CPPType &base_type)
92  {
93  return MFParamType(InterfaceType::Mutable, MFDataType::ForVector(base_type));
94  }
95 
97  {
98  return data_type_;
99  }
100 
102  {
103  return interface_type_;
104  }
105 
107  {
108  switch (data_type_.category()) {
109  case MFDataType::Single: {
110  switch (interface_type_) {
111  case Input:
112  return SingleInput;
113  case Output:
114  return SingleOutput;
115  case Mutable:
116  return SingleMutable;
117  }
118  break;
119  }
120  case MFDataType::Vector: {
121  switch (interface_type_) {
122  case Input:
123  return VectorInput;
124  case Output:
125  return VectorOutput;
126  case Mutable:
127  return VectorMutable;
128  }
129  break;
130  }
131  }
132  BLI_assert(false);
133  return SingleInput;
134  }
135 
136  bool is_input_or_mutable() const
137  {
138  return ELEM(interface_type_, Input, Mutable);
139  }
140 
141  bool is_output_or_mutable() const
142  {
143  return ELEM(interface_type_, Output, Mutable);
144  }
145 
146  bool is_output() const
147  {
148  return interface_type_ == Output;
149  }
150 
151  friend bool operator==(const MFParamType &a, const MFParamType &b);
152  friend bool operator!=(const MFParamType &a, const MFParamType &b);
153 };
154 
155 inline bool operator==(const MFParamType &a, const MFParamType &b)
156 {
157  return a.interface_type_ == b.interface_type_ && a.data_type_ == b.data_type_;
158 }
159 
160 inline bool operator!=(const MFParamType &a, const MFParamType &b)
161 {
162  return !(a == b);
163 }
164 
165 } // namespace blender::fn
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define ELEM(...)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Group Output
static MFParamType ForVectorInput(const CPPType &base_type)
static MFParamType ForSingleOutput(const CPPType &type)
static MFParamType ForMutableSingle(const CPPType &type)
friend bool operator!=(const MFParamType &a, const MFParamType &b)
static MFParamType ForVectorOutput(const CPPType &base_type)
friend bool operator==(const MFParamType &a, const MFParamType &b)
static MFParamType ForMutableVector(const CPPType &base_type)
MFParamType(InterfaceType interface_type, MFDataType data_type)
static MFParamType ForSingleInput(const CPPType &type)
static unsigned a[3]
Definition: RandGen.cpp:92
bool operator!=(const MFDataType &a, const MFDataType &b)
bool operator==(const MFDataType &a, const MFDataType &b)