[Bf-blender-cvs] [30a1a0bf58a] functions-experimental-refactor: separate some files
Jacques Lucke
noreply at git.blender.org
Sun Nov 3 14:31:00 CET 2019
Commit: 30a1a0bf58a83e946d0138e5a10b0d0e69b5fff2
Author: Jacques Lucke
Date: Sun Nov 3 13:44:31 2019 +0100
Branches: functions-experimental-refactor
https://developer.blender.org/rB30a1a0bf58a83e946d0138e5a10b0d0e69b5fff2
separate some files
===================================================================
M source/blender/functions2/CMakeLists.txt
M source/blender/functions2/FN_multi_function.h
A source/blender/functions2/FN_multi_function_data_type.h
A source/blender/functions2/FN_multi_function_mask.h
A source/blender/functions2/FN_multi_function_param_type.h
===================================================================
diff --git a/source/blender/functions2/CMakeLists.txt b/source/blender/functions2/CMakeLists.txt
index bb7272e192e..e26afdeb3dd 100644
--- a/source/blender/functions2/CMakeLists.txt
+++ b/source/blender/functions2/CMakeLists.txt
@@ -46,7 +46,10 @@ set(SRC
FN_generic_virtual_list_list_ref.h
FN_generic_virtual_list_ref.h
FN_initialize.h
+ FN_multi_function_data_type.h
+ FN_multi_function_mask.h
FN_multi_function_network.h
+ FN_multi_function_param_type.h
FN_multi_function.h
FN_multi_functions.h
FN_vtree_multi_function_network_generation.h
diff --git a/source/blender/functions2/FN_multi_function.h b/source/blender/functions2/FN_multi_function.h
index eee1f59de5a..a5548b82330 100644
--- a/source/blender/functions2/FN_multi_function.h
+++ b/source/blender/functions2/FN_multi_function.h
@@ -5,6 +5,9 @@
#include "FN_generic_vector_array.h"
#include "FN_generic_virtual_list_ref.h"
#include "FN_generic_virtual_list_list_ref.h"
+#include "FN_multi_function_data_type.h"
+#include "FN_multi_function_param_type.h"
+#include "FN_multi_function_mask.h"
#include "BLI_vector.h"
@@ -12,236 +15,6 @@ namespace FN {
using BLI::Vector;
-struct MFDataType {
- public:
- enum Category {
- None,
- Single,
- Vector,
- };
-
- MFDataType() = default;
-
- MFDataType(Category category, const CPPType &type) : m_category(category), m_base_type(&type)
- {
- }
-
- static MFDataType ForNone()
- {
- return MFDataType{};
- }
-
- template<typename T> static MFDataType ForSingle()
- {
- return MFDataType(Category::Single, GET_TYPE<T>());
- }
-
- template<typename T> static MFDataType ForVector()
- {
- return MFDataType(Category::Vector, GET_TYPE<T>());
- }
-
- bool is_none() const
- {
- return m_category == Category::None;
- }
-
- bool is_single() const
- {
- return m_category == Category::Single;
- }
-
- bool is_vector() const
- {
- return m_category == Category::Vector;
- }
-
- Category category() const
- {
- return m_category;
- }
-
- const CPPType &type() const
- {
- BLI_assert(m_category == Category::Single);
- return *m_base_type;
- }
-
- const CPPType &base_type() const
- {
- BLI_assert(m_category == Category::Vector);
- return *m_base_type;
- }
-
- friend bool operator==(MFDataType a, MFDataType b)
- {
- return a.m_category == b.m_category && a.m_base_type == b.m_base_type;
- }
-
- friend bool operator!=(MFDataType a, MFDataType b)
- {
- return !(a == b);
- }
-
- private:
- Category m_category = Category::None;
- const CPPType *m_base_type = nullptr;
-};
-
-struct MFParamType {
- public:
- enum Category {
- None,
- ReadonlySingleInput,
- SingleOutput,
- ReadonlyVectorInput,
- VectorOutput,
- MutableVector,
- };
-
- MFParamType(Category category, const CPPType *base_type = nullptr)
- : m_category(category), m_base_type(base_type)
- {
- }
-
- bool is_none() const
- {
- return m_category == MFParamType::None;
- }
-
- bool is_readonly_single_input() const
- {
- return m_category == ReadonlySingleInput;
- }
-
- bool is_readonly_vector_input() const
- {
- return m_category == ReadonlyVectorInput;
- }
-
- bool is_mutable_vector() const
- {
- return m_category == MutableVector;
- }
-
- bool is_single_output() const
- {
- return m_category == SingleOutput;
- }
-
- bool is_input_or_mutable() const
- {
- return ELEM(m_category, ReadonlySingleInput, ReadonlyVectorInput, MutableVector);
- }
-
- bool is_output_or_mutable() const
- {
- return ELEM(m_category, SingleOutput, VectorOutput, MutableVector);
- }
-
- bool is_vector_output() const
- {
- return m_category == VectorOutput;
- }
-
- MFDataType as_data_type() const
- {
- switch (m_category) {
- case None:
- return {};
- case ReadonlySingleInput:
- case SingleOutput:
- return {MFDataType::Single, *m_base_type};
- case ReadonlyVectorInput:
- case VectorOutput:
- case MutableVector:
- return {MFDataType::Vector, *m_base_type};
- }
- BLI_assert(false);
- return {};
- }
-
- Category category() const
- {
- return m_category;
- }
-
- const CPPType &type() const
- {
- BLI_assert(ELEM(m_category, Category::ReadonlySingleInput, Category::SingleOutput));
- return *m_base_type;
- }
-
- const CPPType &base_type() const
- {
- BLI_assert(ELEM(m_category,
- Category::ReadonlyVectorInput,
- Category::VectorOutput,
- Category::MutableVector));
- return *m_base_type;
- }
-
- private:
- Category m_category = Category::None;
- const CPPType *m_base_type = nullptr;
-};
-
-class MFMask {
- private:
- ArrayRef<uint> m_indices;
-
- public:
- MFMask(ArrayRef<uint> indices) : m_indices(indices)
- {
-#ifdef DEBUG
- for (uint i = 1; i < indices.size(); i++) {
- BLI_assert(indices[i - 1] < indices[i]);
- }
-#endif
- }
-
- uint indices_amount() const
- {
- return m_indices.size();
- }
-
- uint min_array_size() const
- {
- return (m_indices.size() == 0) ? 0 : m_indices.last() + 1;
- }
-
- ArrayRef<uint> indices() const
- {
- return m_indices;
- }
-
- bool is_range() const
- {
- return m_indices.size() > 0 && m_indices.last() - m_indices.first() == m_indices.size() - 1;
- }
-
- IndexRange as_range() const
- {
- BLI_assert(this->is_range());
- return IndexRange{m_indices.first(), m_indices.size()};
- }
-
- template<typename FuncT> void foreach_index(const FuncT &func) const
- {
- if (this->is_range()) {
- IndexRange range = this->as_range();
- for (uint i : range) {
- func(i);
- }
- }
- else {
- for (uint i : m_indices) {
- func(i);
- }
- }
- }
-};
-
class MFContext {
};
diff --git a/source/blender/functions2/FN_multi_function_data_type.h b/source/blender/functions2/FN_multi_function_data_type.h
new file mode 100644
index 00000000000..af4cf02e4dc
--- /dev/null
+++ b/source/blender/functions2/FN_multi_function_data_type.h
@@ -0,0 +1,86 @@
+#ifndef __FN_MULTI_FUNCTION_DATA_TYPE_H__
+#define __FN_MULTI_FUNCTION_DATA_TYPE_H__
+
+#include "FN_cpp_type.h"
+
+namespace FN {
+
+struct MFDataType {
+ public:
+ enum Category {
+ None,
+ Single,
+ Vector,
+ };
+
+ MFDataType() = default;
+
+ MFDataType(Category category, const CPPType &type) : m_category(category), m_base_type(&type)
+ {
+ }
+
+ static MFDataType ForNone()
+ {
+ return MFDataType{};
+ }
+
+ template<typename T> static MFDataType ForSingle()
+ {
+ return MFDataType(Category::Single, GET_TYPE<T>());
+ }
+
+ template<typename T> static MFDataType ForVector()
+ {
+ return MFDataType(Category::Vector, GET_TYPE<T>());
+ }
+
+ bool is_none() const
+ {
+ return m_category == Category::None;
+ }
+
+ bool is_single() const
+ {
+ return m_category == Category::Single;
+ }
+
+ bool is_vector() const
+ {
+ return m_category == Category::Vector;
+ }
+
+ Category category() const
+ {
+ return m_category;
+ }
+
+ const CPPType &type() const
+ {
+ BLI_assert(m_category == Category::Single);
+ return *m_base_type;
+ }
+
+ const CPPType &base_type() const
+ {
+ BLI_assert(m_category == Category::Vector);
+ return *m_base_type;
+ }
+
+ friend bool operator==(MFDataType a, MFDataType b)
+ {
+ return a.m_category == b.m_category && a.m_base_type == b.m_base_type;
+ }
+
+ friend bool operator!=(MFDataType a, MFDataType b)
+ {
+ return !(a == b);
+ }
+
+ private:
+ Category m_category = Category::None;
+ const CPPType *m_base_type = nullptr;
+};
+
+} // namespace FN
+
+#endif /* __FN_MULTI_FUNCTION_DATA_TYPE_H__ */
diff --git a/source/blender/functions2/FN_multi_function_mask.h b/source/blender/functions2/FN_multi_function_mask.h
new file mode 100644
index 00000000000..fe056efdcad
--- /dev/null
+++ b/source/blender/functions2/FN_multi_function_mask.h
@@ -0,0 +1,70 @@
+#ifndef __FN_MULTI_FUNCTION_MASK_H__
+#define __FN_MULTI_FUNCTION_MASK_H__
+
+#include "BLI_index_range.h"
+#include "BLI_array_ref.h"
+
+namespace FN {
+
+using BLI::ArrayRef;
+using BLI::IndexRange;
+
+class MFMask {
+ private:
+ ArrayRef<uint> m_indices;
+
+ public:
+ MFMask(ArrayRef<uint> indices) : m_indices(indices)
+ {
+#ifdef DEBUG
+ for (uint i = 1; i < indices.size(); i++) {
+ BLI_assert(indices[i - 1] < indices[i]);
+ }
+#endif
+ }
+
+ uint indices_amount() const
+ {
+ return m_indices.size();
+ }
+
+ uint min_array_size() const
+ {
+ return (m_indices.size() == 0) ? 0 : m_indices.last() + 1;
+ }
+
+ ArrayRef<uint> indices() const
+ {
+ return m_indices;
+ }
+
+ bool is_range() const
+ {
+ return m_indices.size() > 0 && m_indices.last() - m_indices.first() == m_indices.size() - 1;
+ }
+
+ IndexRange as_range() const
+ {
+ BLI_assert(this->is_range());
+ return IndexRange{m_indices.first(), m_indices.size()};
+ }
+
+ template<typename FuncT> void foreach_index(const FuncT &func) const
+ {
+ if (this->is_range()) {
+ IndexRange range = this->as_range();
+ for (uint i : range) {
+ func(i);
+ }
+ }
+ else {
+ for (uint i : m_indices) {
+ func(i);
+ }
+ }
+ }
+};
+
+} // namespace FN
+
+#endif /* __FN_MULTI_FUNCTION_MASK_H__ */
diff --git a/source/blender/functions2/FN_multi_function_param_type.h b/source/blender/functions2/FN_multi_function_param_type.h
new file mode 100644
index 00000000000..e119bfd4967
--- /dev/null
+++ b/source/blender/functions2/FN_multi_function_param_type.h
@@ -0,0 +1,108 @@
+#ifndef __FN_MULTI_FUNCTION_PARAM_TYPE_H__
+#define __FN_MULTI_FUNCTION_PARAM_TYPE_H__
+
+#include "FN_multi_function_data_type.h"
+
+namespace FN {
+
+struct MFParamType {
+ public:
+ enum Category {
+ None,
+ ReadonlySingleInput,
+ SingleOutput,
+ ReadonlyVectorInput,
+ VectorOutput,
+ MutableVector,
+ };
+
+ MFParamType(Category category, const CPPType *base_type = nullptr)
+ : m_category(category), m_base_type(base_type)
+ {
+ }
+
+ bool is_none() const
+ {
+ return m_category == MFParamType::None;
+ }
+
+ bool is_readonly_single_input() const
+ {
+ return m_category == ReadonlySingleInput;
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list