1 // Created by: DAUTRY Philippe 2 // Copyright (c) 1997-1999 Matra Datavision 3 // Copyright (c) 1999-2014 OPEN CASCADE SAS 4 // 5 // This file is part of Open CASCADE Technology software library. 6 // 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 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. 12 // 13 // Alternatively, this file may be used under the terms of Open CASCADE 14 // commercial license or contractual agreement. 15 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> 22 #include <TDF_HAllocator.hxx> 23 #include <NCollection_DefineAlloc.hxx> 24 25 class TDF_Attribute; 26 class TDF_AttributeIterator; 27 class TDF_ChildIterator; 28 class TDF_Data; 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 Father() const54 inline TDF_LabelNode* Father() const 55 { return myFather; } 56 57 // Brother access Brother() const58 inline TDF_LabelNode* Brother() const 59 { return myBrother; } 60 61 // Child access FirstChild() const62 inline TDF_LabelNode* FirstChild() const 63 { return myFirstChild; } 64 65 // Attribute access Handle(TDF_Attribute)66 inline const Handle(TDF_Attribute)& FirstAttribute() const 67 { return myFirstAttribute; } 68 69 // Tag access Tag() const70 inline Standard_Integer Tag() const 71 { return myTag; } 72 73 // Depth access Depth() const74 inline Standard_Integer Depth() const 75 { return (myFlags & ~TDF_LabelNodeFlagsMsk); } 76 77 // IsRoot IsRoot() const78 inline Standard_Boolean IsRoot() const 79 { return myFather == NULL; } 80 81 // Data 82 Standard_EXPORT TDF_Data * Data() const; 83 84 // Flag AttributesModified access AttributesModified(const Standard_Boolean aStatus)85 inline void AttributesModified(const Standard_Boolean aStatus) 86 { 87 myFlags = (aStatus) ? 88 (myFlags | TDF_LabelNodeAttModMsk) : 89 (myFlags & ~TDF_LabelNodeAttModMsk); 90 if (aStatus) AllMayBeModified(); 91 } 92 AttributesModified() const93 inline Standard_Boolean AttributesModified() const 94 { return ((myFlags & TDF_LabelNodeAttModMsk) != 0); } 95 96 // Flag MayBeModified access MayBeModified(const Standard_Boolean aStatus)97 inline void MayBeModified(const Standard_Boolean aStatus) 98 { myFlags = (aStatus) ? 99 (myFlags | TDF_LabelNodeMayModMsk) : 100 (myFlags & ~TDF_LabelNodeMayModMsk); } 101 MayBeModified() const102 inline Standard_Boolean MayBeModified() const 103 { return ((myFlags & TDF_LabelNodeMayModMsk) != 0); } 104 105 private : 106 107 // Memory management 108 DEFINE_NCOLLECTION_ALLOC 109 110 // Constructor 111 TDF_LabelNode(TDF_Data* Data); 112 113 // Destructor and deallocator 114 void Destroy (const TDF_HAllocator& theAllocator); 115 116 // Public Friends 117 // -------------------------------------------------------------------------- 118 119 friend class TDF_Data; 120 friend class TDF_Label; 121 122 private : 123 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 Tag(const Standard_Integer aTag)144 inline void Tag(const Standard_Integer aTag) 145 { myTag = aTag; } 146 147 // Depth modification Depth(const Standard_Integer aDepth)148 inline void Depth(const Standard_Integer aDepth) 149 { myFlags = ((myFlags & TDF_LabelNodeFlagsMsk) | aDepth); } 150 151 // Flag Imported access Imported(const Standard_Boolean aStatus)152 inline void Imported(const Standard_Boolean aStatus) 153 { myFlags = (aStatus) ? 154 (myFlags | TDF_LabelNodeImportMsk) : 155 (myFlags & ~TDF_LabelNodeImportMsk); } 156 IsImported() const157 inline Standard_Boolean IsImported() const 158 { return ((myFlags & TDF_LabelNodeImportMsk) != 0); } 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 173 #ifdef OCCT_DEBUG 174 TCollection_AsciiString myDebugEntry; 175 #endif 176 }; 177 178 #endif 179