b311480e |
1 | // Created by: DAUTRY Philippe |
2 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
973c2be1 |
7 | // This library is free software; you can redistribute it and / or modify it |
8 | // under the terms of the GNU Lesser General Public version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
7fd59977 |
16 | #ifndef TDF_LabelNode_HeaderFile |
17 | #define TDF_LabelNode_HeaderFile |
18 | |
19 | #include <TCollection_AsciiString.hxx> |
20 | #include <TDF_Attribute.hxx> |
21 | #include <TDF_LabelNodePtr.hxx> |
60d4560d |
22 | #include <TDF_HAllocator.hxx> |
23 | #include <NCollection_DefineAlloc.hxx> |
7fd59977 |
24 | |
25 | class TDF_Attribute; |
26 | class TDF_AttributeIterator; |
27 | class TDF_ChildIterator; |
28 | class TDF_Data; |
29 | class Handle_TDF_Data; |
30 | class TDF_Label; |
31 | |
32 | #define KEEP_LOCAL_ROOT |
33 | |
34 | enum { |
35 | TDF_LabelNodeImportMsk = (int) 0x80000000, // Because the sign bit (HP). |
36 | TDF_LabelNodeAttModMsk = 0x40000000, |
37 | TDF_LabelNodeMayModMsk = 0x20000000, |
38 | TDF_LabelNodeFlagsMsk = (TDF_LabelNodeImportMsk \ |
39 | | TDF_LabelNodeAttModMsk \ |
40 | | TDF_LabelNodeMayModMsk) |
41 | }; |
42 | |
43 | //======================================================================= |
44 | //class: TDF_LabelNode |
45 | //======================================================================= |
46 | |
47 | class TDF_LabelNode { |
48 | |
49 | public : |
50 | |
51 | // Public Methods |
52 | // -------------------------------------------------------------------------- |
53 | |
54 | // Father access |
55 | inline TDF_LabelNode* Father() const |
5640d653 |
56 | { return myFather; } |
7fd59977 |
57 | |
58 | // Brother access |
59 | inline TDF_LabelNode* Brother() const |
5640d653 |
60 | { return myBrother; } |
7fd59977 |
61 | |
62 | // Child access |
63 | inline TDF_LabelNode* FirstChild() const |
5640d653 |
64 | { return myFirstChild; } |
7fd59977 |
65 | |
66 | // Attribute access |
67 | inline const Handle(TDF_Attribute)& FirstAttribute() const |
5640d653 |
68 | { return myFirstAttribute; } |
7fd59977 |
69 | |
70 | // Tag access |
71 | inline Standard_Integer Tag() const |
5640d653 |
72 | { return myTag; } |
7fd59977 |
73 | |
74 | // Depth access |
75 | inline Standard_Integer Depth() const |
5640d653 |
76 | { return (myFlags & ~TDF_LabelNodeFlagsMsk); } |
7fd59977 |
77 | |
78 | // IsRoot |
79 | inline Standard_Boolean IsRoot() const |
5640d653 |
80 | { return myFather == NULL; } |
7fd59977 |
81 | |
82 | // Data |
83 | Standard_EXPORT TDF_Data * Data() const; |
84 | |
85 | // Flag AttributesModified access |
86 | inline void AttributesModified(const Standard_Boolean aStatus) |
87 | { |
88 | myFlags = (aStatus) ? |
89 | (myFlags | TDF_LabelNodeAttModMsk) : |
90 | (myFlags & ~TDF_LabelNodeAttModMsk); |
91 | if (aStatus) AllMayBeModified(); |
5640d653 |
92 | } |
7fd59977 |
93 | |
94 | inline Standard_Boolean AttributesModified() const |
5640d653 |
95 | { return ((myFlags & TDF_LabelNodeAttModMsk) != 0); } |
7fd59977 |
96 | |
97 | // Flag MayBeModified access |
98 | inline void MayBeModified(const Standard_Boolean aStatus) |
99 | { myFlags = (aStatus) ? |
100 | (myFlags | TDF_LabelNodeMayModMsk) : |
5640d653 |
101 | (myFlags & ~TDF_LabelNodeMayModMsk); } |
7fd59977 |
102 | |
103 | inline Standard_Boolean MayBeModified() const |
5640d653 |
104 | { return ((myFlags & TDF_LabelNodeMayModMsk) != 0); } |
7fd59977 |
105 | |
60d4560d |
106 | private : |
107 | |
108 | // Memory management |
109 | DEFINE_NCOLLECTION_ALLOC |
110 | |
7fd59977 |
111 | // Constructor |
60d4560d |
112 | TDF_LabelNode(TDF_Data* Data); |
7fd59977 |
113 | |
60d4560d |
114 | // Destructor and deallocator |
115 | void Destroy (const TDF_HAllocator& theAllocator); |
7fd59977 |
116 | |
7fd59977 |
117 | // Public Friends |
118 | // -------------------------------------------------------------------------- |
119 | |
120 | friend class TDF_Data; |
121 | friend class TDF_Label; |
122 | |
123 | private : |
124 | |
7fd59977 |
125 | // Private Methods |
126 | // -------------------------------------------------------------------------- |
127 | |
128 | // Constructor |
129 | TDF_LabelNode(const Standard_Integer Tag, TDF_LabelNode* Father); |
130 | |
131 | // Others |
132 | void AddAttribute(const Handle(TDF_Attribute)& afterAtt, |
133 | const Handle(TDF_Attribute)& newAtt); |
134 | |
135 | void RemoveAttribute(const Handle(TDF_Attribute)& afterAtt, |
136 | const Handle(TDF_Attribute)& oldAtt); |
137 | |
138 | TDF_LabelNode* RootNode (); |
139 | |
140 | const TDF_LabelNode* RootNode () const; |
141 | |
142 | Standard_EXPORT void AllMayBeModified(); |
143 | |
144 | // Tag modification |
145 | inline void Tag(const Standard_Integer aTag) |
5640d653 |
146 | { myTag = aTag; } |
7fd59977 |
147 | |
148 | // Depth modification |
149 | inline void Depth(const Standard_Integer aDepth) |
5640d653 |
150 | { myFlags = ((myFlags & TDF_LabelNodeFlagsMsk) | aDepth); } |
7fd59977 |
151 | |
152 | // Flag Imported access |
153 | inline void Imported(const Standard_Boolean aStatus) |
154 | { myFlags = (aStatus) ? |
155 | (myFlags | TDF_LabelNodeImportMsk) : |
5640d653 |
156 | (myFlags & ~TDF_LabelNodeImportMsk); } |
7fd59977 |
157 | |
158 | inline Standard_Boolean IsImported() const |
5640d653 |
159 | { return ((myFlags & TDF_LabelNodeImportMsk) != 0); } |
7fd59977 |
160 | |
161 | // Private Fields |
162 | // -------------------------------------------------------------------------- |
163 | |
164 | TDF_LabelNodePtr myFather; |
165 | TDF_LabelNodePtr myBrother; |
166 | TDF_LabelNodePtr myFirstChild; |
167 | TDF_LabelNodePtr myLastFoundChild; //jfa 10.01.2003 |
168 | Standard_Integer myTag; |
169 | Standard_Integer myFlags; // Flags & Depth |
170 | Handle(TDF_Attribute) myFirstAttribute; |
171 | #ifdef KEEP_LOCAL_ROOT |
172 | TDF_Data * myData; |
173 | #endif |
174 | #ifdef DEB |
175 | TCollection_AsciiString myDebugEntry; |
176 | #endif |
177 | }; |
178 | |
eb7e2b67 |
179 | #endif |