Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 09:17:13

0001 // Created by: DAUTRY Philippe
0002 // Copyright (c) 1997-1999 Matra Datavision
0003 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef TDF_LabelNode_HeaderFile
0017 #define TDF_LabelNode_HeaderFile
0018 
0019 #include <TCollection_AsciiString.hxx>
0020 #include <TDF_Attribute.hxx>
0021 #include <TDF_LabelNodePtr.hxx>
0022 #include <TDF_HAllocator.hxx>
0023 #include <NCollection_DefineAlloc.hxx>
0024 
0025 #ifdef Standard_HASATOMIC
0026   #include <atomic>
0027 #endif
0028 
0029 class TDF_Attribute;
0030 class TDF_Data;
0031 
0032 #define KEEP_LOCAL_ROOT
0033 
0034 enum
0035 {
0036   TDF_LabelNodeImportMsk = (int)0x80000000, // Because the sign bit (HP).
0037   TDF_LabelNodeAttModMsk = 0x40000000,
0038   TDF_LabelNodeMayModMsk = 0x20000000,
0039   TDF_LabelNodeFlagsMsk = (TDF_LabelNodeImportMsk | TDF_LabelNodeAttModMsk | TDF_LabelNodeMayModMsk)
0040 };
0041 
0042 //=======================================================================
0043 // class: TDF_LabelNode
0044 //=======================================================================
0045 
0046 class TDF_LabelNode
0047 {
0048 
0049 public:
0050   // Public Methods
0051   // --------------------------------------------------------------------------
0052 
0053   // Father access
0054   inline TDF_LabelNode* Father() const { return myFather; }
0055 
0056   // Brother access
0057   inline TDF_LabelNode* Brother() const { return myBrother; }
0058 
0059   // Child access
0060   inline TDF_LabelNode* FirstChild() const { return myFirstChild; }
0061 
0062   // Attribute access
0063   inline const Handle(TDF_Attribute)& FirstAttribute() const { return myFirstAttribute; }
0064 
0065   // Tag access
0066   inline Standard_Integer Tag() const { return myTag; }
0067 
0068   // Depth access
0069   inline Standard_Integer Depth() const { return (myFlags & ~TDF_LabelNodeFlagsMsk); }
0070 
0071   // IsRoot
0072   inline Standard_Boolean IsRoot() const { return myFather == NULL; }
0073 
0074   // Data
0075   Standard_EXPORT TDF_Data* Data() const;
0076 
0077   // Flag AttributesModified access
0078   inline void AttributesModified(const Standard_Boolean aStatus)
0079   {
0080     myFlags = (aStatus) ? (myFlags | TDF_LabelNodeAttModMsk) : (myFlags & ~TDF_LabelNodeAttModMsk);
0081     if (aStatus)
0082       AllMayBeModified();
0083   }
0084 
0085   inline Standard_Boolean AttributesModified() const
0086   {
0087     return ((myFlags & TDF_LabelNodeAttModMsk) != 0);
0088   }
0089 
0090   // Flag MayBeModified access
0091   inline void MayBeModified(const Standard_Boolean aStatus)
0092   {
0093     myFlags = (aStatus) ? (myFlags | TDF_LabelNodeMayModMsk) : (myFlags & ~TDF_LabelNodeMayModMsk);
0094   }
0095 
0096   inline Standard_Boolean MayBeModified() const
0097   {
0098     return ((myFlags & TDF_LabelNodeMayModMsk) != 0);
0099   }
0100 
0101 private:
0102   // Memory management
0103   DEFINE_NCOLLECTION_ALLOC
0104 
0105   // Constructor
0106   TDF_LabelNode(TDF_Data* Data);
0107 
0108   // Destructor and deallocator
0109   void Destroy(const TDF_HAllocator& theAllocator);
0110 
0111   // Public Friends
0112   // --------------------------------------------------------------------------
0113 
0114   friend class TDF_Data;
0115   friend class TDF_Label;
0116 
0117 private:
0118   // Private Methods
0119   // --------------------------------------------------------------------------
0120 
0121   // Constructor
0122   TDF_LabelNode(const Standard_Integer Tag, TDF_LabelNode* Father);
0123 
0124   // Others
0125   void AddAttribute(const Handle(TDF_Attribute)& afterAtt, const Handle(TDF_Attribute)& newAtt);
0126 
0127   void RemoveAttribute(const Handle(TDF_Attribute)& afterAtt, const Handle(TDF_Attribute)& oldAtt);
0128 
0129   TDF_LabelNode* RootNode();
0130 
0131   const TDF_LabelNode* RootNode() const;
0132 
0133   Standard_EXPORT void AllMayBeModified();
0134 
0135   // Tag modification
0136   inline void Tag(const Standard_Integer aTag) { myTag = aTag; }
0137 
0138   // Depth modification
0139   inline void Depth(const Standard_Integer aDepth)
0140   {
0141     myFlags = ((myFlags & TDF_LabelNodeFlagsMsk) | aDepth);
0142   }
0143 
0144   // Flag Imported access
0145   inline void Imported(const Standard_Boolean aStatus)
0146   {
0147     myFlags = (aStatus) ? (myFlags | TDF_LabelNodeImportMsk) : (myFlags & ~TDF_LabelNodeImportMsk);
0148   }
0149 
0150   inline Standard_Boolean IsImported() const { return ((myFlags & TDF_LabelNodeImportMsk) != 0); }
0151 
0152   // Private Fields
0153   // --------------------------------------------------------------------------
0154 
0155   TDF_LabelNodePtr myFather;
0156   TDF_LabelNodePtr myBrother;
0157   TDF_LabelNodePtr myFirstChild;
0158   Standard_ATOMIC(TDF_LabelNodePtr) myLastFoundChild; // jfa 10.01.2003
0159   Standard_Integer      myTag;
0160   Standard_Integer      myFlags; // Flags & Depth
0161   Handle(TDF_Attribute) myFirstAttribute;
0162 #ifdef KEEP_LOCAL_ROOT
0163   TDF_Data* myData;
0164 #endif
0165 #ifdef OCCT_DEBUG
0166   TCollection_AsciiString myDebugEntry;
0167 #endif
0168 };
0169 
0170 #endif