4 #include "DF_definitions.hxx"
5 #include "DF_Attribute.hxx"
23 DF_LabelNode* _father;
24 DF_LabelNode* _previous;
26 DF_LabelNode* _firstChild;
27 DF_LabelNode* _lastChild;
28 DF_Document* _document;
29 std::map< std::string, DF_Attribute* > _attributes;
31 friend class DF_Document;
32 friend class DF_Label;
33 friend class DF_ChildIterator;
34 friend class DF_Attribute;
37 //Class DF_Label defines a persistence reference in DF_Document that contains a tree of Labels.
38 //This reference is named "entry" and is a sequence of tags divided by ":". The root entry is "0:".
39 //For example "0:1:1" corresponds the following structure
49 //Returns a Label by its entry, if isCreated true the Label will be created if not exists
50 Standard_EXPORT static DF_Label Label(const DF_Label& theLabel, const std::string& theEntry, bool isCreated = true);
52 //Constructors: creates a root label
53 Standard_EXPORT DF_Label();
56 Standard_EXPORT DF_Label(const DF_Label& theLabel);
58 //Creates a Label from the LabelNode
59 Standard_EXPORT DF_Label(DF_LabelNode* theNode);
62 Standard_EXPORT DF_Label& operator=(const DF_Label& theLabel);
65 Standard_EXPORT ~DF_Label();
67 //Returns a smart pointer to Document which contains this Label
68 Standard_EXPORT DF_Document* GetDocument() const;
70 //Returns true if theLabel equals to this label
71 Standard_EXPORT bool operator==(const DF_Label& theLabel);
73 //Returns true if theLabel doesn't equals to this label
74 Standard_EXPORT bool operator!=(const DF_Label& theLabel);
76 //Returns a tag of this Label
77 Standard_EXPORT int Tag() const;
79 //Returns true if this Label is attached to the tree in the Document.
80 Standard_EXPORT bool IsAttached();
82 //Searches an Attribute with given ID located on this Label.
83 //Returns true if the Attribute is found.
84 Standard_EXPORT DF_Attribute* FindAttribute(const std::string& theID) const;
86 //Returns true if there is an Attribute with given ID on this Label.
87 Standard_EXPORT bool IsAttribute(const std::string& theID) const;
89 //Adds theAttribute to the Label where this Attribute is located.
90 //Returns true if theAttribute was added.
91 Standard_EXPORT bool AddAttribute(DF_Attribute* theAttribute) const;
93 //Forgets an Attribute with given ID located on the this Label.
94 Standard_EXPORT bool ForgetAttribute(const std::string& theID) const;
96 //Forgets all Attributes located on this Label.
97 Standard_EXPORT bool ForgetAllAttributes(bool clearChildren = true) const;
99 //Returns Father of this Label.
100 Standard_EXPORT DF_Label Father() const;
102 //Return true if the label is not initialized
103 Standard_EXPORT bool IsNull() const;
105 //Return true if the label is a Root label
106 Standard_EXPORT bool IsRoot() const;
108 //Returns true if this Label has Attributes.
109 Standard_EXPORT bool HasAttributes() const;
111 //Returns a list of Attributes of this Label.
112 Standard_EXPORT std::vector<DF_Attribute*> GetAttributes() const;
114 //Returns true if this Label has a child Label.
115 Standard_EXPORT bool HasChild() const;
117 //Returns a number of child Labels.
118 Standard_EXPORT int NbChildren() const;
120 //Returns the depth (a number of fathers required to identify the Label) of this Label in the tree.
121 Standard_EXPORT int Depth() const;
123 //Returns true if this Label is a descendant of theLabel.
124 Standard_EXPORT bool IsDescendant(const DF_Label& theLabel);
126 //Returns the root Label of a Label tree to which this Label belongs.
127 Standard_EXPORT DF_Label Root() const;
129 //Finds a child Label of this Label with a given tag. If isCreate = true and there is no child
130 //Label with the given tag, the child Label is created.
131 Standard_EXPORT DF_Label FindChild(int theTag, bool isCreate = true);
133 //Creates a new child Label of this Label.
134 Standard_EXPORT DF_Label NewChild();
136 //Returns a string presentation of the entry
137 Standard_EXPORT std::string Entry() const;
139 //Returns true if theLabel is the same as me
140 Standard_EXPORT bool IsEqual(const DF_Label& theLabel);
142 Standard_EXPORT void dump();
145 //Nullifies the content of the label
148 friend class DF_Document;
149 friend class DF_ChildIterator;