Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/NOD_node_declaration.hh
| Show All 31 Lines | |||||
| */ | */ | ||||
| class SocketDeclaration { | class SocketDeclaration { | ||||
| protected: | protected: | ||||
| std::string name_; | std::string name_; | ||||
| std::string identifier_; | std::string identifier_; | ||||
| bool hide_label_ = false; | bool hide_label_ = false; | ||||
| bool hide_value_ = false; | bool hide_value_ = false; | ||||
| bool is_multi_input_ = false; | bool is_multi_input_ = false; | ||||
| bool is_field_ = false; | |||||
| friend NodeDeclarationBuilder; | friend NodeDeclarationBuilder; | ||||
| template<typename SocketDecl> friend class SocketDeclarationBuilder; | template<typename SocketDecl> friend class SocketDeclarationBuilder; | ||||
| public: | public: | ||||
| virtual ~SocketDeclaration() = default; | virtual ~SocketDeclaration() = default; | ||||
| virtual bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const = 0; | virtual bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const = 0; | ||||
| virtual bool matches(const bNodeSocket &socket) const = 0; | virtual bool matches(const bNodeSocket &socket) const = 0; | ||||
| virtual bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const; | virtual bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const; | ||||
| StringRefNull name() const; | StringRefNull name() const; | ||||
| StringRefNull identifier() const; | StringRefNull identifier() const; | ||||
| bool is_field() const; | |||||
| protected: | protected: | ||||
| void set_common_flags(bNodeSocket &socket) const; | void set_common_flags(bNodeSocket &socket) const; | ||||
| bool matches_common_data(const bNodeSocket &socket) const; | bool matches_common_data(const bNodeSocket &socket) const; | ||||
| }; | }; | ||||
| class BaseSocketDeclarationBuilder { | class BaseSocketDeclarationBuilder { | ||||
| public: | public: | ||||
| virtual ~BaseSocketDeclarationBuilder() = default; | virtual ~BaseSocketDeclarationBuilder() = default; | ||||
| Show All 26 Lines | Self &hide_value(bool value = true) | ||||
| return *(Self *)this; | return *(Self *)this; | ||||
| } | } | ||||
| Self &multi_input(bool value = true) | Self &multi_input(bool value = true) | ||||
| { | { | ||||
| decl_->is_multi_input_ = value; | decl_->is_multi_input_ = value; | ||||
| return *(Self *)this; | return *(Self *)this; | ||||
| } | } | ||||
| Self &is_field(bool value = true) | |||||
| { | |||||
| decl_->is_field_ = value; | |||||
| return *(Self *)this; | |||||
| } | |||||
| }; | }; | ||||
| using SocketDeclarationPtr = std::unique_ptr<SocketDeclaration>; | using SocketDeclarationPtr = std::unique_ptr<SocketDeclaration>; | ||||
| class NodeDeclaration { | class NodeDeclaration { | ||||
| private: | private: | ||||
| Vector<SocketDeclarationPtr> inputs_; | Vector<SocketDeclarationPtr> inputs_; | ||||
| Vector<SocketDeclarationPtr> outputs_; | Vector<SocketDeclarationPtr> outputs_; | ||||
| Show All 39 Lines | inline StringRefNull SocketDeclaration::name() const | ||||
| return name_; | return name_; | ||||
| } | } | ||||
| inline StringRefNull SocketDeclaration::identifier() const | inline StringRefNull SocketDeclaration::identifier() const | ||||
| { | { | ||||
| return identifier_; | return identifier_; | ||||
| } | } | ||||
| inline bool SocketDeclaration::is_field() const | |||||
| { | |||||
| return is_field_; | |||||
| } | |||||
| /* -------------------------------------------------------------------- | /* -------------------------------------------------------------------- | ||||
| * NodeDeclarationBuilder inline methods. | * NodeDeclarationBuilder inline methods. | ||||
| */ | */ | ||||
| inline NodeDeclarationBuilder::NodeDeclarationBuilder(NodeDeclaration &declaration) | inline NodeDeclarationBuilder::NodeDeclarationBuilder(NodeDeclaration &declaration) | ||||
| : declaration_(declaration) | : declaration_(declaration) | ||||
| { | { | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines | |||||