From 2f52f5683ca8454a32c8f9f9e47c56092070e114 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Sun, 3 Oct 2021 15:24:21 +0200 Subject: Cleanup: move more method definitions out of their class This makes it easier to test the impact of moving them out of the header later. --- source/blender/nodes/NOD_socket_declarations.hh | 241 +++++++++++++++--------- 1 file changed, 147 insertions(+), 94 deletions(-) (limited to 'source') diff --git a/source/blender/nodes/NOD_socket_declarations.hh b/source/blender/nodes/NOD_socket_declarations.hh index 3d0cfdb5d5d..3f7f9e0414e 100644 --- a/source/blender/nodes/NOD_socket_declarations.hh +++ b/source/blender/nodes/NOD_socket_declarations.hh @@ -46,29 +46,10 @@ class Float : public SocketDeclaration { class FloatBuilder : public SocketDeclarationBuilder { public: - FloatBuilder &min(const float value) - { - decl_->soft_min_value_ = value; - return *this; - } - - FloatBuilder &max(const float value) - { - decl_->soft_max_value_ = value; - return *this; - } - - FloatBuilder &default_value(const float value) - { - decl_->default_value_ = value; - return *this; - } - - FloatBuilder &subtype(PropertySubType subtype) - { - decl_->subtype_ = subtype; - return *this; - } + FloatBuilder &min(const float value); + FloatBuilder &max(const float value); + FloatBuilder &default_value(const float value); + FloatBuilder &subtype(PropertySubType subtype); }; class IntBuilder; @@ -92,29 +73,10 @@ class Int : public SocketDeclaration { class IntBuilder : public SocketDeclarationBuilder { public: - IntBuilder &min(const int value) - { - decl_->soft_min_value_ = value; - return *this; - } - - IntBuilder &max(const int value) - { - decl_->soft_max_value_ = value; - return *this; - } - - IntBuilder &default_value(const int value) - { - decl_->default_value_ = value; - return *this; - } - - IntBuilder &subtype(PropertySubType subtype) - { - decl_->subtype_ = subtype; - return *this; - } + IntBuilder &min(const int value); + IntBuilder &max(const int value); + IntBuilder &default_value(const int value); + IntBuilder &subtype(PropertySubType subtype); }; class VectorBuilder; @@ -138,29 +100,10 @@ class Vector : public SocketDeclaration { class VectorBuilder : public SocketDeclarationBuilder { public: - VectorBuilder &default_value(const float3 value) - { - decl_->default_value_ = value; - return *this; - } - - VectorBuilder &subtype(PropertySubType subtype) - { - decl_->subtype_ = subtype; - return *this; - } - - VectorBuilder &min(const float min) - { - decl_->soft_min_value_ = min; - return *this; - } - - VectorBuilder &max(const float max) - { - decl_->soft_max_value_ = max; - return *this; - } + VectorBuilder &default_value(const float3 value); + VectorBuilder &subtype(PropertySubType subtype); + VectorBuilder &min(const float min); + VectorBuilder &max(const float max); }; class BoolBuilder; @@ -179,11 +122,7 @@ class Bool : public SocketDeclaration { class BoolBuilder : public SocketDeclarationBuilder { public: - BoolBuilder &default_value(const bool value) - { - decl_->default_value_ = value; - return *this; - } + BoolBuilder &default_value(const bool value); }; class ColorBuilder; @@ -203,11 +142,7 @@ class Color : public SocketDeclaration { class ColorBuilder : public SocketDeclarationBuilder { public: - ColorBuilder &default_value(const ColorGeometry4f value) - { - decl_->default_value_ = value; - return *this; - } + ColorBuilder &default_value(const ColorGeometry4f value); }; class String : public SocketDeclaration { @@ -223,9 +158,7 @@ class IDSocketDeclaration : public SocketDeclaration { const char *idname_; public: - IDSocketDeclaration(const char *idname) : idname_(idname) - { - } + IDSocketDeclaration(const char *idname); bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override; bool matches(const bNodeSocket &socket) const override; @@ -236,36 +169,28 @@ class Object : public IDSocketDeclaration { public: using Builder = SocketDeclarationBuilder; - Object() : IDSocketDeclaration("NodeSocketObject") - { - } + Object(); }; class Material : public IDSocketDeclaration { public: using Builder = SocketDeclarationBuilder; - Material() : IDSocketDeclaration("NodeSocketMaterial") - { - } + Material(); }; class Collection : public IDSocketDeclaration { public: using Builder = SocketDeclarationBuilder; - Collection() : IDSocketDeclaration("NodeSocketCollection") - { - } + Collection(); }; class Texture : public IDSocketDeclaration { public: using Builder = SocketDeclarationBuilder; - Texture() : IDSocketDeclaration("NodeSocketTexture") - { - } + Texture(); }; class Geometry : public SocketDeclaration { @@ -276,4 +201,132 @@ class Geometry : public SocketDeclaration { bool matches(const bNodeSocket &socket) const override; }; +/* -------------------------------------------------------------------- + * #FloatBuilder inline methods. + */ + +inline FloatBuilder &FloatBuilder::min(const float value) +{ + decl_->soft_min_value_ = value; + return *this; +} + +inline FloatBuilder &FloatBuilder::max(const float value) +{ + decl_->soft_max_value_ = value; + return *this; +} + +inline FloatBuilder &FloatBuilder::default_value(const float value) +{ + decl_->default_value_ = value; + return *this; +} + +inline FloatBuilder &FloatBuilder::subtype(PropertySubType subtype) +{ + decl_->subtype_ = subtype; + return *this; +} + +/* -------------------------------------------------------------------- + * #IntBuilder inline methods. + */ + +inline IntBuilder &IntBuilder::min(const int value) +{ + decl_->soft_min_value_ = value; + return *this; +} + +inline IntBuilder &IntBuilder::max(const int value) +{ + decl_->soft_max_value_ = value; + return *this; +} + +inline IntBuilder &IntBuilder::default_value(const int value) +{ + decl_->default_value_ = value; + return *this; +} + +inline IntBuilder &IntBuilder::subtype(PropertySubType subtype) +{ + decl_->subtype_ = subtype; + return *this; +} + +/* -------------------------------------------------------------------- + * #VectorBuilder inline methods. + */ + +inline VectorBuilder &VectorBuilder::default_value(const float3 value) +{ + decl_->default_value_ = value; + return *this; +} + +inline VectorBuilder &VectorBuilder::subtype(PropertySubType subtype) +{ + decl_->subtype_ = subtype; + return *this; +} + +inline VectorBuilder &VectorBuilder::min(const float min) +{ + decl_->soft_min_value_ = min; + return *this; +} + +inline VectorBuilder &VectorBuilder::max(const float max) +{ + decl_->soft_max_value_ = max; + return *this; +} + +/* -------------------------------------------------------------------- + * #BoolBuilder inline methods. + */ + +inline BoolBuilder &BoolBuilder::default_value(const bool value) +{ + decl_->default_value_ = value; + return *this; +} + +/* -------------------------------------------------------------------- + * #ColorBuilder inline methods. + */ + +inline ColorBuilder &ColorBuilder::default_value(const ColorGeometry4f value) +{ + decl_->default_value_ = value; + return *this; +} + +/* -------------------------------------------------------------------- + * #IDSocketDeclaration and children inline methods. + */ + +inline IDSocketDeclaration::IDSocketDeclaration(const char *idname) : idname_(idname) +{ +} + +inline Object::Object() : IDSocketDeclaration("NodeSocketObject") +{ +} + +inline Material::Material() : IDSocketDeclaration("NodeSocketMaterial") +{ +} + +inline Collection::Collection() : IDSocketDeclaration("NodeSocketCollection") +{ +} + +inline Texture::Texture() : IDSocketDeclaration("NodeSocketTexture") +{ +} + } // namespace blender::nodes::decl -- cgit v1.2.3