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 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
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; |
7fd59977 |
29 | class TDF_Label; |
30 | |
31 | #define KEEP_LOCAL_ROOT |
32 | |
33 | enum { |
34 | TDF_LabelNodeImportMsk = (int) 0x80000000, // Because the sign bit (HP). |
35 | TDF_LabelNodeAttModMsk = 0x40000000, |
36 | TDF_LabelNodeMayModMsk = 0x20000000, |
37 | TDF_LabelNodeFlagsMsk = (TDF_LabelNodeImportMsk \ |
38 | | TDF_LabelNodeAttModMsk \ |
39 | | TDF_LabelNodeMayModMsk) |
40 | }; |
41 | |
42 | //======================================================================= |
43 | //class: TDF_LabelNode |
44 | //======================================================================= |
45 | |
46 | class TDF_LabelNode { |
47 | |
48 | public : |
49 | |
50 | // Public Methods |
51 | // -------------------------------------------------------------------------- |
52 | |
53 | // Father access |
54 | inline TDF_LabelNode* Father() const |
5640d653 |
55 | { return myFather; } |
7fd59977 |
56 | |
57 | // Brother access |
58 | inline TDF_LabelNode* Brother() const |
5640d653 |
59 | { return myBrother; } |
7fd59977 |
60 | |
61 | // Child access |
62 | inline TDF_LabelNode* FirstChild() const |
5640d653 |
63 | { return myFirstChild; } |
7fd59977 |
64 | |
65 | // Attribute access |
66 | inline const Handle(TDF_Attribute)& FirstAttribute() const |
5640d653 |
67 | { return myFirstAttribute; } |
7fd59977 |
68 | |
69 | // Tag access |
70 | inline Standard_Integer Tag() const |
5640d653 |
71 | { return myTag; } |
7fd59977 |
72 | |
73 | // Depth access |
74 | inline Standard_Integer Depth() const |
5640d653 |
75 | { return (myFlags & ~TDF_LabelNodeFlagsMsk); } |
7fd59977 |
76 | |
77 | // IsRoot |
78 | inline Standard_Boolean IsRoot() const |
5640d653 |
79 | { return myFather == NULL; } |
7fd59977 |
80 | |
81 | // Data |
82 | Standard_EXPORT TDF_Data * Data() const; |
83 | |
84 | // Flag AttributesModified access |
85 | inline void AttributesModified(const Standard_Boolean aStatus) |
86 | { |
87 | myFlags = (aStatus) ? |
88 | (myFlags | TDF_LabelNodeAttModMsk) : |
89 | (myFlags & ~TDF_LabelNodeAttModMsk); |
90 | if (aStatus) AllMayBeModified(); |
5640d653 |
91 | } |
7fd59977 |
92 | |
93 | inline Standard_Boolean AttributesModified() const |
5640d653 |
94 | { return ((myFlags & TDF_LabelNodeAttModMsk) != 0); } |
7fd59977 |
95 | |
96 | // Flag MayBeModified access |
97 | inline void MayBeModified(const Standard_Boolean aStatus) |
98 | { myFlags = (aStatus) ? |
99 | (myFlags | TDF_LabelNodeMayModMsk) : |
5640d653 |
100 | (myFlags & ~TDF_LabelNodeMayModMsk); } |
7fd59977 |
101 | |
102 | inline Standard_Boolean MayBeModified() const |
5640d653 |
103 | { return ((myFlags & TDF_LabelNodeMayModMsk) != 0); } |
7fd59977 |
104 | |
60d4560d |
105 | private : |
106 | |
107 | // Memory management |
108 | DEFINE_NCOLLECTION_ALLOC |
109 | |
7fd59977 |
110 | // Constructor |
60d4560d |
111 | TDF_LabelNode(TDF_Data* Data); |
7fd59977 |
112 | |
60d4560d |
113 | // Destructor and deallocator |
114 | void Destroy (const TDF_HAllocator& theAllocator); |
7fd59977 |
115 | |
7fd59977 |
116 | // Public Friends |
117 | // -------------------------------------------------------------------------- |
118 | |
119 | friend class TDF_Data; |
120 | friend class TDF_Label; |
121 | |
122 | private : |
123 | |
7fd59977 |
124 | // Private Methods |
125 | // -------------------------------------------------------------------------- |
126 | |
127 | // Constructor |
128 | TDF_LabelNode(const Standard_Integer Tag, TDF_LabelNode* Father); |
129 | |
130 | // Others |
131 | void AddAttribute(const Handle(TDF_Attribute)& afterAtt, |
132 | const Handle(TDF_Attribute)& newAtt); |
133 | |
134 | void RemoveAttribute(const Handle(TDF_Attribute)& afterAtt, |
135 | const Handle(TDF_Attribute)& oldAtt); |
136 | |
137 | TDF_LabelNode* RootNode (); |
138 | |
139 | const TDF_LabelNode* RootNode () const; |
140 | |
141 | Standard_EXPORT void AllMayBeModified(); |
142 | |
143 | // Tag modification |
144 | inline void Tag(const Standard_Integer aTag) |
5640d653 |
145 | { myTag = aTag; } |
7fd59977 |
146 | |
147 | // Depth modification |
148 | inline void Depth(const Standard_Integer aDepth) |
5640d653 |
149 | { myFlags = ((myFlags & TDF_LabelNodeFlagsMsk) | aDepth); } |
7fd59977 |
150 | |
151 | // Flag Imported access |
152 | inline void Imported(const Standard_Boolean aStatus) |
153 | { myFlags = (aStatus) ? |
154 | (myFlags | TDF_LabelNodeImportMsk) : |
5640d653 |
155 | (myFlags & ~TDF_LabelNodeImportMsk); } |
7fd59977 |
156 | |
157 | inline Standard_Boolean IsImported() const |
5640d653 |
158 | { return ((myFlags & TDF_LabelNodeImportMsk) != 0); } |
7fd59977 |
159 | |
160 | // Private Fields |
161 | // -------------------------------------------------------------------------- |
162 | |
163 | TDF_LabelNodePtr myFather; |
164 | TDF_LabelNodePtr myBrother; |
165 | TDF_LabelNodePtr myFirstChild; |
166 | TDF_LabelNodePtr myLastFoundChild; //jfa 10.01.2003 |
167 | Standard_Integer myTag; |
168 | Standard_Integer myFlags; // Flags & Depth |
169 | Handle(TDF_Attribute) myFirstAttribute; |
170 | #ifdef KEEP_LOCAL_ROOT |
171 | TDF_Data * myData; |
172 | #endif |
0797d9d3 |
173 | #ifdef OCCT_DEBUG |
7fd59977 |
174 | TCollection_AsciiString myDebugEntry; |
175 | #endif |
176 | }; |
177 | |
eb7e2b67 |
178 | #endif |