0023024: Update headers of OCCT files
[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 //              ------------------
21
22 // Version:     0.0
23 //Version Date            Purpose
24 //              0.0     Feb  6 1997     Creation
25
26 //#include <TDF_Data.hxx>
27
28 #ifndef TDF_LabelNode_HeaderFile
29 #define TDF_LabelNode_HeaderFile
30
31 #include <TCollection_AsciiString.hxx>
32 #include <TDF_Attribute.hxx>
33 #include <TDF_LabelNodePtr.hxx>
34 #include <NCollection_IncAllocator.hxx>
35
36 class TDF_Attribute;
37 class TDF_AttributeIterator;
38 class TDF_ChildIterator;
39 class TDF_Data;
40 class Handle_TDF_Data;
41 class TDF_Label;
42
43 #define KEEP_LOCAL_ROOT
44
45 enum {
46   TDF_LabelNodeImportMsk = (int) 0x80000000, // Because the sign bit (HP).
47   TDF_LabelNodeAttModMsk = 0x40000000,
48   TDF_LabelNodeMayModMsk = 0x20000000,
49   TDF_LabelNodeFlagsMsk = (TDF_LabelNodeImportMsk \
50                          | TDF_LabelNodeAttModMsk \
51                          | TDF_LabelNodeMayModMsk)
52 };
53
54 //=======================================================================
55 //class: TDF_LabelNode
56 //=======================================================================
57
58 class TDF_LabelNode {
59
60   public :
61
62   // Public Methods
63   // --------------------------------------------------------------------------
64
65   // Father access
66   inline TDF_LabelNode* Father() const
67     { return myFather; };
68
69   // Brother access
70   inline TDF_LabelNode* Brother() const
71     { return myBrother; };
72
73   // Child access
74   inline TDF_LabelNode* FirstChild() const
75     { return myFirstChild; };
76
77     // Attribute access
78   inline const Handle(TDF_Attribute)& FirstAttribute() const
79     { return myFirstAttribute; };
80
81   // Tag access
82   inline Standard_Integer Tag() const
83     { return myTag; };
84
85   // Depth access
86   inline Standard_Integer Depth() const
87     { return (myFlags & ~TDF_LabelNodeFlagsMsk); };
88
89   // IsRoot
90   inline Standard_Boolean IsRoot() const
91     { return myFather == NULL; };
92
93   // Data
94   Standard_EXPORT TDF_Data * Data() const;
95
96   // Flag AttributesModified access
97   inline void AttributesModified(const Standard_Boolean aStatus)
98     {
99       myFlags = (aStatus) ?
100         (myFlags | TDF_LabelNodeAttModMsk) :
101           (myFlags & ~TDF_LabelNodeAttModMsk);
102       if (aStatus) AllMayBeModified();
103     };
104
105   inline Standard_Boolean AttributesModified() const
106     { return ((myFlags & TDF_LabelNodeAttModMsk) != 0); };
107
108   // Flag MayBeModified access
109   inline void MayBeModified(const Standard_Boolean aStatus)
110     { myFlags = (aStatus) ?
111         (myFlags | TDF_LabelNodeMayModMsk) :
112           (myFlags & ~TDF_LabelNodeMayModMsk); };
113
114   inline Standard_Boolean MayBeModified() const
115     { return ((myFlags & TDF_LabelNodeMayModMsk) != 0); };
116
117   // Constructor
118   TDF_LabelNode(TDF_Data* Data); // Useful for root node.
119   
120   // Destructor
121   ~TDF_LabelNode();
122
123   // Memory management
124   void * operator new (size_t aSize,
125                        const Handle(NCollection_IncAllocator)& anAlloc)
126         { return anAlloc -> Allocate (aSize); }
127 #if !defined(__BORLANDC__) && (!defined(__SUNPRO_CC) || (__SUNPRO_CC > 0x530))
128   void  operator delete (void* theAddress,
129                          const Handle(NCollection_IncAllocator)& anAlloc)
130   {
131   }
132 #endif 
133   void  operator delete(void *) { }
134         // nothing to do in operator delete since IncAllocator does not need it
135   // Public Friends
136   // --------------------------------------------------------------------------
137
138   friend class TDF_Data;
139   friend class TDF_Label;
140
141   private :
142
143   void* operator new(size_t);
144
145   // Private Methods
146   // --------------------------------------------------------------------------
147
148   // Constructor
149   TDF_LabelNode(const Standard_Integer Tag, TDF_LabelNode* Father);
150
151   // Others
152   void AddAttribute(const Handle(TDF_Attribute)& afterAtt,
153                     const Handle(TDF_Attribute)& newAtt);
154
155   void RemoveAttribute(const Handle(TDF_Attribute)& afterAtt,
156                        const Handle(TDF_Attribute)& oldAtt);
157
158   TDF_LabelNode* RootNode ();
159
160   const TDF_LabelNode* RootNode () const;
161
162   Standard_EXPORT void AllMayBeModified();
163
164   // Tag modification
165   inline void Tag(const Standard_Integer aTag)
166     { myTag = aTag; };
167
168   // Depth modification
169   inline void Depth(const Standard_Integer aDepth)
170     { myFlags = ((myFlags & TDF_LabelNodeFlagsMsk) | aDepth); };
171
172   // Flag Imported access
173   inline void Imported(const Standard_Boolean aStatus)
174     { myFlags = (aStatus) ?
175         (myFlags | TDF_LabelNodeImportMsk) :
176           (myFlags & ~TDF_LabelNodeImportMsk); };
177
178   inline Standard_Boolean IsImported() const
179     { return ((myFlags & TDF_LabelNodeImportMsk) != 0); };
180
181   // Private Fields
182   // --------------------------------------------------------------------------
183
184   TDF_LabelNodePtr       myFather; 
185   TDF_LabelNodePtr       myBrother; 
186   TDF_LabelNodePtr       myFirstChild;
187   TDF_LabelNodePtr       myLastFoundChild; //jfa 10.01.2003
188   Standard_Integer       myTag;
189   Standard_Integer       myFlags; // Flags & Depth
190   Handle(TDF_Attribute)  myFirstAttribute;
191 #ifdef KEEP_LOCAL_ROOT
192   TDF_Data *             myData;
193 #endif
194 #ifdef DEB
195   TCollection_AsciiString myDebugEntry;
196 #endif
197 };
198
199 #endif