1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 #include "DF_definitions.hxx"
26 #include "DF_Attribute.hxx"
44 DF_LabelNode* _father;
45 DF_LabelNode* _previous;
47 DF_LabelNode* _firstChild;
48 DF_LabelNode* _lastChild;
49 DF_Document* _document;
50 std::map< std::string, DF_Attribute* > _attributes;
52 friend class DF_Document;
53 friend class DF_Label;
54 friend class DF_ChildIterator;
55 friend class DF_Attribute;
58 //Class DF_Label defines a persistence reference in DF_Document that contains a tree of Labels.
59 //This reference is named "entry" and is a sequence of tags divided by ":". The root entry is "0:".
60 //For example "0:1:1" corresponds the following structure
70 //Returns a Label by its entry, if isCreated true the Label will be created if not exists
71 Standard_EXPORT static DF_Label Label(const DF_Label& theLabel, const std::string& theEntry, bool isCreated = true);
73 //Constructors: creates a root label
74 Standard_EXPORT DF_Label();
77 Standard_EXPORT DF_Label(const DF_Label& theLabel);
79 //Creates a Label from the LabelNode
80 Standard_EXPORT DF_Label(DF_LabelNode* theNode);
83 Standard_EXPORT DF_Label& operator=(const DF_Label& theLabel);
86 Standard_EXPORT ~DF_Label();
88 //Returns a smart pointer to Document which contains this Label
89 Standard_EXPORT DF_Document* GetDocument() const;
91 //Returns true if theLabel equals to this label
92 Standard_EXPORT bool operator==(const DF_Label& theLabel);
94 //Returns true if theLabel doesn't equals to this label
95 Standard_EXPORT bool operator!=(const DF_Label& theLabel);
97 //Returns a tag of this Label
98 Standard_EXPORT int Tag() const;
100 //Returns true if this Label is attached to the tree in the Document.
101 Standard_EXPORT bool IsAttached();
103 //Searches an Attribute with given ID located on this Label.
104 //Returns true if the Attribute is found.
105 Standard_EXPORT DF_Attribute* FindAttribute(const std::string& theID) const;
107 //Returns true if there is an Attribute with given ID on this Label.
108 Standard_EXPORT bool IsAttribute(const std::string& theID) const;
110 //Adds theAttribute to the Label where this Attribute is located.
111 //Returns true if theAttribute was added.
112 Standard_EXPORT bool AddAttribute(DF_Attribute* theAttribute) const;
114 //Forgets an Attribute with given ID located on the this Label.
115 Standard_EXPORT bool ForgetAttribute(const std::string& theID) const;
117 //Forgets all Attributes located on this Label.
118 Standard_EXPORT bool ForgetAllAttributes(bool clearChildren = true) const;
120 //Returns Father of this Label.
121 Standard_EXPORT DF_Label Father() const;
123 //Return true if the label is not initialized
124 Standard_EXPORT bool IsNull() const;
126 //Return true if the label is a Root label
127 Standard_EXPORT bool IsRoot() const;
129 //Returns true if this Label has Attributes.
130 Standard_EXPORT bool HasAttributes() const;
132 //Returns a list of Attributes of this Label.
133 Standard_EXPORT std::vector<DF_Attribute*> GetAttributes() const;
135 //Returns true if this Label has a child Label.
136 Standard_EXPORT bool HasChild() const;
138 //Returns a number of child Labels.
139 Standard_EXPORT int NbChildren() const;
141 //Returns the depth (a number of fathers required to identify the Label) of this Label in the tree.
142 Standard_EXPORT int Depth() const;
144 //Returns true if this Label is a descendant of theLabel.
145 Standard_EXPORT bool IsDescendant(const DF_Label& theLabel);
147 //Returns the root Label of a Label tree to which this Label belongs.
148 Standard_EXPORT DF_Label Root() const;
150 //Finds a child Label of this Label with a given tag. If isCreate = true and there is no child
151 //Label with the given tag, the child Label is created.
152 Standard_EXPORT DF_Label FindChild(int theTag, bool isCreate = true);
154 //Creates a new child Label of this Label.
155 Standard_EXPORT DF_Label NewChild();
157 //Returns a string presentation of the entry
158 Standard_EXPORT std::string Entry() const;
160 //Returns true if theLabel is the same as me
161 Standard_EXPORT bool IsEqual(const DF_Label& theLabel);
163 Standard_EXPORT void dump();
166 //Nullifies the content of the label
169 friend class DF_Document;
170 friend class DF_ChildIterator;