0023002: empty delete operator in TDF_LabelNode
[occt.git] / src / TDF / TDF_LabelNode.hxx
1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20 #ifndef TDF_LabelNode_HeaderFile
21 #define TDF_LabelNode_HeaderFile
22
23 #include <TCollection_AsciiString.hxx>
24 #include <TDF_Attribute.hxx>
25 #include <TDF_LabelNodePtr.hxx>
26 #include <TDF_HAllocator.hxx>
27 #include <NCollection_DefineAlloc.hxx>
28
29 class TDF_Attribute;
30 class TDF_AttributeIterator;
31 class TDF_ChildIterator;
32 class TDF_Data;
33 class Handle_TDF_Data;
34 class TDF_Label;
35
36 #define KEEP_LOCAL_ROOT
37
38 enum {
39   TDF_LabelNodeImportMsk = (int) 0x80000000, // Because the sign bit (HP).
40   TDF_LabelNodeAttModMsk = 0x40000000,
41   TDF_LabelNodeMayModMsk = 0x20000000,
42   TDF_LabelNodeFlagsMsk = (TDF_LabelNodeImportMsk \
43                          | TDF_LabelNodeAttModMsk \
44                          | TDF_LabelNodeMayModMsk)
45 };
46
47 //=======================================================================
48 //class: TDF_LabelNode
49 //=======================================================================
50
51 class TDF_LabelNode {
52
53   public :
54
55   // Public Methods
56   // --------------------------------------------------------------------------
57
58   // Father access
59   inline TDF_LabelNode* Father() const
60     { return myFather; };
61
62   // Brother access
63   inline TDF_LabelNode* Brother() const
64     { return myBrother; };
65
66   // Child access
67   inline TDF_LabelNode* FirstChild() const
68     { return myFirstChild; };
69
70     // Attribute access
71   inline const Handle(TDF_Attribute)& FirstAttribute() const
72     { return myFirstAttribute; };
73
74   // Tag access
75   inline Standard_Integer Tag() const
76     { return myTag; };
77
78   // Depth access
79   inline Standard_Integer Depth() const
80     { return (myFlags & ~TDF_LabelNodeFlagsMsk); };
81
82   // IsRoot
83   inline Standard_Boolean IsRoot() const
84     { return myFather == NULL; };
85
86   // Data
87   Standard_EXPORT TDF_Data * Data() const;
88
89   // Flag AttributesModified access
90   inline void AttributesModified(const Standard_Boolean aStatus)
91     {
92       myFlags = (aStatus) ?
93         (myFlags | TDF_LabelNodeAttModMsk) :
94           (myFlags & ~TDF_LabelNodeAttModMsk);
95       if (aStatus) AllMayBeModified();
96     };
97
98   inline Standard_Boolean AttributesModified() const
99     { return ((myFlags & TDF_LabelNodeAttModMsk) != 0); };
100
101   // Flag MayBeModified access
102   inline void MayBeModified(const Standard_Boolean aStatus)
103     { myFlags = (aStatus) ?
104         (myFlags | TDF_LabelNodeMayModMsk) :
105           (myFlags & ~TDF_LabelNodeMayModMsk); };
106
107   inline Standard_Boolean MayBeModified() const
108     { return ((myFlags & TDF_LabelNodeMayModMsk) != 0); };
109
110   private :
111
112   // Memory management
113   DEFINE_NCOLLECTION_ALLOC
114
115   // Constructor
116   TDF_LabelNode(TDF_Data* Data);
117   
118   // Destructor and deallocator
119   void Destroy (const TDF_HAllocator& theAllocator);
120
121   // Public Friends
122   // --------------------------------------------------------------------------
123
124   friend class TDF_Data;
125   friend class TDF_Label;
126
127   private :
128
129   // Private Methods
130   // --------------------------------------------------------------------------
131
132   // Constructor
133   TDF_LabelNode(const Standard_Integer Tag, TDF_LabelNode* Father);
134
135   // Others
136   void AddAttribute(const Handle(TDF_Attribute)& afterAtt,
137                     const Handle(TDF_Attribute)& newAtt);
138
139   void RemoveAttribute(const Handle(TDF_Attribute)& afterAtt,
140                        const Handle(TDF_Attribute)& oldAtt);
141
142   TDF_LabelNode* RootNode ();
143
144   const TDF_LabelNode* RootNode () const;
145
146   Standard_EXPORT void AllMayBeModified();
147
148   // Tag modification
149   inline void Tag(const Standard_Integer aTag)
150     { myTag = aTag; };
151
152   // Depth modification
153   inline void Depth(const Standard_Integer aDepth)
154     { myFlags = ((myFlags & TDF_LabelNodeFlagsMsk) | aDepth); };
155
156   // Flag Imported access
157   inline void Imported(const Standard_Boolean aStatus)
158     { myFlags = (aStatus) ?
159         (myFlags | TDF_LabelNodeImportMsk) :
160           (myFlags & ~TDF_LabelNodeImportMsk); };
161
162   inline Standard_Boolean IsImported() const
163     { return ((myFlags & TDF_LabelNodeImportMsk) != 0); };
164
165   // Private Fields
166   // --------------------------------------------------------------------------
167
168   TDF_LabelNodePtr       myFather; 
169   TDF_LabelNodePtr       myBrother; 
170   TDF_LabelNodePtr       myFirstChild;
171   TDF_LabelNodePtr       myLastFoundChild; //jfa 10.01.2003
172   Standard_Integer       myTag;
173   Standard_Integer       myFlags; // Flags & Depth
174   Handle(TDF_Attribute)  myFirstAttribute;
175 #ifdef KEEP_LOCAL_ROOT
176   TDF_Data *             myData;
177 #endif
178 #ifdef DEB
179   TCollection_AsciiString myDebugEntry;
180 #endif
181 };
182
183 #endif