Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2017-02-16
0002 // Created by: Sergey NIKONOV
0003 // Copyright (c) 2000-2017 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 _XCAFDoc_AssemblyItemId_HeaderFile
0017 #define _XCAFDoc_AssemblyItemId_HeaderFile
0018 
0019 #include <Standard_GUID.hxx>
0020 #include <TColStd_ListOfAsciiString.hxx>
0021 
0022 //! Unique item identifier in the hierarchical product structure.
0023 //! A full path to an assembly component in the "part-of" graph starting from 
0024 //! the root node. 
0025 class XCAFDoc_AssemblyItemId
0026 {
0027 
0028 public:
0029 
0030   //! Constructs an empty item ID.
0031   Standard_EXPORT XCAFDoc_AssemblyItemId();
0032 
0033   //! Constructs an item ID from a list of strings, where every 
0034   //! string is a label entry.
0035   //! \param [in] thePath - list of label entries.
0036   Standard_EXPORT XCAFDoc_AssemblyItemId(const TColStd_ListOfAsciiString& thePath);
0037 
0038   //! Constructs an item ID from a formatted path, where label entries
0039   //! are separated by '/' symbol.
0040   //! \param [in] theString - formatted full path.
0041   Standard_EXPORT XCAFDoc_AssemblyItemId(const TCollection_AsciiString& theString);
0042 
0043   //! Initializes the item ID from a list of strings, where every 
0044   //! string is a label entry.
0045   //! \param [in] thePath - list of label entries.
0046   Standard_EXPORT void Init(const TColStd_ListOfAsciiString& thePath);
0047 
0048   //! Initializes the item ID from a formatted path, where label entries
0049   //! are separated by '/' symbol.
0050   //! \param [in] theString - formatted full path.
0051   Standard_EXPORT void Init(const TCollection_AsciiString& theString);
0052 
0053   //! Returns true if the full path is empty, otherwise - false.
0054   Standard_EXPORT Standard_Boolean IsNull() const;
0055 
0056   //! Clears the full path.
0057   Standard_EXPORT void Nullify();
0058 
0059   //! Checks if this item is a child of the given item.
0060   //! \param [in] theOther - potentially ancestor item.
0061   //! \return true if the item is a child of theOther item, otherwise - false.
0062   Standard_EXPORT Standard_Boolean IsChild(const XCAFDoc_AssemblyItemId& theOther) const;
0063 
0064   //! Checks if this item is a direct child of the given item.
0065   //! \param [in] theOther - potentially parent item.
0066   //! \return true if the item is a direct child of theOther item, otherwise - false.
0067   Standard_EXPORT Standard_Boolean IsDirectChild(const XCAFDoc_AssemblyItemId& theOther) const;
0068 
0069   //! Checks for item IDs equality.
0070   //! \param [in] theOther - the item ID to check equality with.
0071   //! \return true if this ID is equal to theOther, otherwise - false.
0072   Standard_EXPORT Standard_Boolean IsEqual(const XCAFDoc_AssemblyItemId& theOther) const;
0073 
0074   //! Returns the full path as a list of label entries.
0075   Standard_EXPORT const TColStd_ListOfAsciiString& GetPath() const;
0076 
0077   //! Returns the full pass as a formatted string.
0078   Standard_EXPORT TCollection_AsciiString ToString() const;
0079   
0080   //! Dumps the content of me into the stream
0081   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0082 
0083   bool operator==(const XCAFDoc_AssemblyItemId& theOther) const
0084   {
0085     return IsEqual(theOther);
0086   }
0087 
0088 private:
0089 
0090   TColStd_ListOfAsciiString myPath; ///< List of label entries
0091 
0092 };
0093 
0094 namespace std
0095 {
0096 
0097   template<>
0098   struct hash<XCAFDoc_AssemblyItemId>
0099   {
0100     size_t operator()(const XCAFDoc_AssemblyItemId& theAssemblyItemId) const
0101     {
0102       return std::hash<TCollection_AsciiString>{}(theAssemblyItemId.ToString());
0103     }
0104   };
0105 
0106 }
0107 #endif // _XCAFDoc_AssemblyItemId_HeaderFile