Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:21

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   TDF_LabelNodeImportMsk = (int) 0x80000000, // Because the sign bit (HP).
0036   TDF_LabelNodeAttModMsk = 0x40000000,
0037   TDF_LabelNodeMayModMsk = 0x20000000,
0038   TDF_LabelNodeFlagsMsk = (TDF_LabelNodeImportMsk \
0039                          | TDF_LabelNodeAttModMsk \
0040                          | TDF_LabelNodeMayModMsk)
0041 };
0042 
0043 //=======================================================================
0044 //class: TDF_LabelNode
0045 //=======================================================================
0046 
0047 class TDF_LabelNode {
0048 
0049   public :
0050 
0051   // Public Methods
0052   // --------------------------------------------------------------------------
0053 
0054   // Father access
0055   inline TDF_LabelNode* Father() const
0056     { return myFather; }
0057 
0058   // Brother access
0059   inline TDF_LabelNode* Brother() const
0060     { return myBrother; }
0061 
0062   // Child access
0063   inline TDF_LabelNode* FirstChild() const
0064     { return myFirstChild; }
0065 
0066     // Attribute access
0067   inline const Handle(TDF_Attribute)& FirstAttribute() const
0068     { return myFirstAttribute; }
0069 
0070   // Tag access
0071   inline Standard_Integer Tag() const
0072     { return myTag; }
0073 
0074   // Depth access
0075   inline Standard_Integer Depth() const
0076     { return (myFlags & ~TDF_LabelNodeFlagsMsk); }
0077 
0078   // IsRoot
0079   inline Standard_Boolean IsRoot() const
0080     { return myFather == NULL; }
0081 
0082   // Data
0083   Standard_EXPORT TDF_Data * Data() const;
0084 
0085   // Flag AttributesModified access
0086   inline void AttributesModified(const Standard_Boolean aStatus)
0087     {
0088       myFlags = (aStatus) ?
0089         (myFlags | TDF_LabelNodeAttModMsk) :
0090           (myFlags & ~TDF_LabelNodeAttModMsk);
0091       if (aStatus) AllMayBeModified();
0092     }
0093 
0094   inline Standard_Boolean AttributesModified() const
0095     { return ((myFlags & TDF_LabelNodeAttModMsk) != 0); }
0096 
0097   // Flag MayBeModified access
0098   inline void MayBeModified(const Standard_Boolean aStatus)
0099     { myFlags = (aStatus) ?
0100         (myFlags | TDF_LabelNodeMayModMsk) :
0101           (myFlags & ~TDF_LabelNodeMayModMsk); }
0102 
0103   inline Standard_Boolean MayBeModified() const
0104     { return ((myFlags & TDF_LabelNodeMayModMsk) != 0); }
0105 
0106   private :
0107 
0108   // Memory management
0109   DEFINE_NCOLLECTION_ALLOC
0110 
0111   // Constructor
0112   TDF_LabelNode(TDF_Data* Data);
0113   
0114   // Destructor and deallocator
0115   void Destroy (const TDF_HAllocator& theAllocator);
0116 
0117   // Public Friends
0118   // --------------------------------------------------------------------------
0119 
0120   friend class TDF_Data;
0121   friend class TDF_Label;
0122 
0123   private :
0124 
0125   // Private Methods
0126   // --------------------------------------------------------------------------
0127 
0128   // Constructor
0129   TDF_LabelNode(const Standard_Integer Tag, TDF_LabelNode* Father);
0130 
0131   // Others
0132   void AddAttribute(const Handle(TDF_Attribute)& afterAtt,
0133                     const Handle(TDF_Attribute)& newAtt);
0134 
0135   void RemoveAttribute(const Handle(TDF_Attribute)& afterAtt,
0136                        const Handle(TDF_Attribute)& oldAtt);
0137 
0138   TDF_LabelNode* RootNode ();
0139 
0140   const TDF_LabelNode* RootNode () const;
0141 
0142   Standard_EXPORT void AllMayBeModified();
0143 
0144   // Tag modification
0145   inline void Tag(const Standard_Integer aTag)
0146     { myTag = aTag; }
0147 
0148   // Depth modification
0149   inline void Depth(const Standard_Integer aDepth)
0150     { myFlags = ((myFlags & TDF_LabelNodeFlagsMsk) | aDepth); }
0151 
0152   // Flag Imported access
0153   inline void Imported(const Standard_Boolean aStatus)
0154     { myFlags = (aStatus) ?
0155         (myFlags | TDF_LabelNodeImportMsk) :
0156           (myFlags & ~TDF_LabelNodeImportMsk); }
0157 
0158   inline Standard_Boolean IsImported() const
0159     { return ((myFlags & TDF_LabelNodeImportMsk) != 0); }
0160 
0161   // Private Fields
0162   // --------------------------------------------------------------------------
0163 
0164   TDF_LabelNodePtr      myFather; 
0165   TDF_LabelNodePtr      myBrother; 
0166   TDF_LabelNodePtr      myFirstChild;
0167   Standard_ATOMIC(TDF_LabelNodePtr) myLastFoundChild; //jfa 10.01.2003
0168   Standard_Integer      myTag;
0169   Standard_Integer      myFlags; // Flags & Depth
0170   Handle(TDF_Attribute) myFirstAttribute;
0171 #ifdef KEEP_LOCAL_ROOT
0172   TDF_Data *            myData;
0173 #endif
0174 #ifdef OCCT_DEBUG
0175   TCollection_AsciiString myDebugEntry;
0176 #endif
0177 };
0178 
0179 #endif