X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Fsrc%2Fsynfig%2Fvaluenode.h;h=8a1552e792c5e6b14db2bf25fad14560ac784ee9;hb=c318e91118d00d944b39c88eb6a34f6c6a89489e;hp=a7a8f30d339f2a26afccf09bf50d3b71ebd75e8b;hpb=db91521de71f46f2debb4b3ef1edfe351aea3b2d;p=synfig.git diff --git a/synfig-core/src/synfig/valuenode.h b/synfig-core/src/synfig/valuenode.h index a7a8f30..8a1552e 100644 --- a/synfig-core/src/synfig/valuenode.h +++ b/synfig-core/src/synfig/valuenode.h @@ -38,10 +38,8 @@ #include #include #include "guid.h" - -#ifndef SYNFIG_NO_ANGLE #include -#endif +#include "paramdesc.h" #include "node.h" @@ -80,9 +78,10 @@ namespace synfig { class Canvas; class LinkableValueNode; class Layer; +class ParamVocab; /*! \class ValueNode -** \todo writeme +** \brief Base class for all Value Nodes */ class ValueNode : public synfig::Node { @@ -103,9 +102,9 @@ public: typedef etl::rhandle RHandle; - + //!Instantiates the book of ValaueNodes and register all the valid valuenodes on it static bool subsys_init(); - + //!Deletes the book of ValueNodes static bool subsys_stop(); /* @@ -113,9 +112,15 @@ public: */ private: + //! The type of the Value Node + //! \see ValueBase ValueBase::Type type; + //! The name of the Value Node. This is the string that is used in the + //! sif file to define the value type: i.e. String name; + //! The canvas this Value Node belongs to etl::loose_handle canvas_; + //! The root canvas this Value Node belongs to etl::loose_handle root_canvas_; /* @@ -206,10 +211,10 @@ public: virtual String get_description(bool show_exported_name = true)const; - //! \writeme + //! Clones a Value Node virtual ValueNode* clone(const GUID& deriv_guid=GUID())const=0; - //! \writeme + //! Returns \true if the Value Node has an ID (has been exported) bool is_exported()const { return !get_id().empty(); } //! Returns the type of the ValueNode @@ -221,15 +226,20 @@ public: //! Returns a handle to the parent canvas, if it has one. etl::loose_handle get_root_canvas()const { return root_canvas_; } - //! \writeme + //! Sets the parent canvas for the Value Node void set_parent_canvas(etl::loose_handle x); - //! \writeme + //! Sets the root canvas parent for the Value Node void set_root_canvas(etl::loose_handle x); - //! \writeme + //! Returns the relative ID of a Node when accessed form the \x Canvas String get_relative_id(etl::loose_handle x)const; + //! Replaces the Value Node with a given one. It look up all its parents + //! remove it self from them and adds the given Value Node + //! Notice that it is called twice and the second time it uses + //! a replaceable handle to the Node + //! \see etl::rhandle int replace(etl::handle x); protected: @@ -240,7 +250,12 @@ protected: }; // END of class ValueNode /*! \class PlaceholderValueNode -** \todo writeme +** Seems to be a Place to hold a Value Node temporarly. +* +* Doesn't seem to implement any functionality. Seems to be used when the +* value node cannot be created using the Const, Animated or Linkable +* Value Nodes. +* */ class PlaceholderValueNode : public ValueNode { @@ -272,7 +287,12 @@ protected: /*! \class LinkableValueNode -** \todo writeme +** \brief Specialized Class of Value Nodes that has links to other +** Value Nodes +* +* This Value Node is calculated based on a math calculation or a time +* evaluation of the linked Value Nodes. It is commonly known as +* Converted Value Nodes. The derived clases defines the behavior. */ class LinkableValueNode : public ValueNode { @@ -289,11 +309,15 @@ public: //! Type that represents a pointer to a ValueNode's constructor - /*! As a pointer to the constructor, it represents a "factory" of + /*! As a pointer to the constructor, it represents a "factory" of ** objects of this class. */ typedef LinkableValueNode* (*Factory)(const ValueBase&); + //! This represents a pointer to a Type check member fucntion + /*! As a pointer to the member, it represents a fucntion that checks + ** the type of the provided ValueBase + */ typedef bool (*CheckType)(ValueBase::Type); struct BookEntry @@ -305,18 +329,28 @@ public: }; //! Book of types of linkable value nodes indexed by type name. - /*! While the sifz file is read, each time a new LinkableValueNode entry - ** is found, the factory constructor that the "factory" pointer member - ** of the "BookEntry" struct points to, is called, and a new object of + /*! While the sifz file is read, each time a new LinkableValueNode entry + ** is found, the factory constructor that the "factory" pointer member + ** of the "BookEntry" struct points to, is called, and a new object of ** that type is created. ** \sa LinkableValueNode::Factory */ typedef std::map Book; + //! The vocabulary of the children + /*! \see synfig::Paramdesc + */ + typedef ParamVocab Vocab; + static Book& book(); + //! Creates a Linkable Value Node based on the name and the returned + //! value type. Returns a valid Handle if both (name and type) match static Handle create(const String &name, const ValueBase& x); + //! Each derived Linkable Value Node has to implement this fucntion and + //! should return true only if the type matches. \name is the name of + //! the linked value node and \x is the returned value type static bool check_type(const String &name, ValueBase::Type x); public: @@ -324,47 +358,66 @@ public: ValueNode(type) { } protected: + //! Stores the Value Node \x in the sub parameter i after check if the + //! type is the same. + //! It has to be defined by the derived class. virtual bool set_link_vfunc(int i,ValueNode::Handle x)=0; + //! Frees all the subparameters of the Linkable Value Node. + //! Used by the derived classed destructors. void unlink_all(); public: + //! Returns the number of linked Value Nodes virtual int link_count()const=0; - virtual String link_local_name(int i)const=0; + //! Returns the local name of the 'i' linked Value Node + virtual String link_local_name(int i)const; - virtual String link_name(int i)const=0; + //! Returns the name of the 'i' linked Value Node + virtual String link_name(int i)const; - virtual int get_link_index_from_name(const String &name)const=0; + //! Returns the child index Value Node based on the name + virtual int get_link_index_from_name(const String &name)const; + //! Clones a Value Node virtual ValueNode* clone(const GUID& deriv_guid=GUID())const; + //! Sets a new Value Node link by its index bool set_link(int i,ValueNode::Handle x); + //! Sets a new Value Node link by its name bool set_link(const String &name,ValueNode::Handle x) { return set_link(get_link_index_from_name(name),x); } + //! Returns a Loose Handle to the Value Node based on the link's index ValueNode::LooseHandle get_link(int i)const; + //! Returns a Loose Handle to the Value Node based on the link's name ValueNode::LooseHandle get_link(const String &name)const { return get_link(get_link_index_from_name(name)); } + //! Return a full description of the linked ValueNode given by the index + String get_description(int index = -1, bool show_exported_name = true)const; - String - get_description(int index = -1, bool show_exported_name = true)const; + //! Gets the parameter vocabulary for linkable value nodes + virtual Vocab get_param_vocab()const=0; protected: //! Sets the type of the ValueNode void set_type(ValueBase::Type t) { ValueNode::set_type(t); } + //! Virtual member to get the linked Value Node Handle virtual ValueNode::LooseHandle get_link_vfunc(int i)const=0; - // Wrapper for new operator, used by clone() + //! Wrapper for new operator, used by clone() virtual LinkableValueNode* create_new()const=0; + //! Returns the cached times values for all the children (linked Value Nodes) virtual void get_times_vfunc(Node::time_set &set) const; }; // END of class LinkableValueNode /*! \class ValueNodeList ** \brief A searchable value_node list container ** \warning Do not confuse with ValueNode_DynamicList! -** \todo writeme +* +* Used by Canvas class to access to the exported value nodes. */ class ValueNodeList : public std::list {