024d6f77 |
1 | // Created on: 2017-02-16 |
2 | // Created by: Sergey NIKONOV |
3 | // Copyright (c) 2000-2017 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 _XCAFDoc_AssemblyItemId_HeaderFile |
17 | #define _XCAFDoc_AssemblyItemId_HeaderFile |
18 | |
19 | #include <Standard_GUID.hxx> |
20 | #include <TColStd_ListOfAsciiString.hxx> |
21 | |
22 | //! Unique item identifier in the hierarchical product structure. |
fcd9a94e |
23 | //! A full path to an assembly component in the "part-of" graph starting from |
024d6f77 |
24 | //! the root node. |
25 | class XCAFDoc_AssemblyItemId |
26 | { |
27 | |
28 | public: |
29 | |
30 | //! Constructs an empty item ID. |
31 | Standard_EXPORT XCAFDoc_AssemblyItemId(); |
32 | |
33 | //! Constructs an item ID from a list of strings, where every |
34 | //! string is a label entry. |
35 | //! \param [in] thePath - list of label entries. |
36 | Standard_EXPORT XCAFDoc_AssemblyItemId(const TColStd_ListOfAsciiString& thePath); |
37 | |
38 | //! Constructs an item ID from a formatted path, where label entries |
39 | //! are separated by '/' symbol. |
40 | //! \param [in] theString - formatted full path. |
41 | Standard_EXPORT XCAFDoc_AssemblyItemId(const TCollection_AsciiString& theString); |
42 | |
43 | //! Initializes the item ID from a list of strings, where every |
44 | //! string is a label entry. |
45 | //! \param [in] thePath - list of label entries. |
46 | Standard_EXPORT void Init(const TColStd_ListOfAsciiString& thePath); |
47 | |
48 | //! Initializes the item ID from a formatted path, where label entries |
49 | //! are separated by '/' symbol. |
50 | //! \param [in] theString - formatted full path. |
51 | Standard_EXPORT void Init(const TCollection_AsciiString& theString); |
52 | |
53 | //! Returns true if the full path is empty, otherwise - false. |
54 | Standard_EXPORT Standard_Boolean IsNull() const; |
55 | |
56 | //! Clears the full path. |
57 | Standard_EXPORT void Nullify(); |
58 | |
59 | //! Checks if this item is a child of the given item. |
60 | //! \param [in] theOther - potentially ancestor item. |
61 | //! \return true if the item is a child of theOther item, otherwise - false. |
62 | Standard_EXPORT Standard_Boolean IsChild(const XCAFDoc_AssemblyItemId& theOther) const; |
63 | |
64 | //! Checks if this item is a direct child of the given item. |
65 | //! \param [in] theOther - potentially parent item. |
66 | //! \return true if the item is a direct child of theOther item, otherwise - false. |
67 | Standard_EXPORT Standard_Boolean IsDirectChild(const XCAFDoc_AssemblyItemId& theOther) const; |
68 | |
69 | //! Checks for item IDs equality. |
70 | //! \param [in] theOther - the item ID to check equality with. |
71 | //! \return true if this ID is equal to theOther, otherwise - false. |
72 | Standard_EXPORT Standard_Boolean IsEqual(const XCAFDoc_AssemblyItemId& theOther) const; |
73 | |
74 | //! Returns the full path as a list of label entries. |
75 | Standard_EXPORT const TColStd_ListOfAsciiString& GetPath() const; |
76 | |
77 | //! Returns the full pass as a formatted string. |
78 | Standard_EXPORT TCollection_AsciiString ToString() const; |
79 | |
80 | struct Hasher |
81 | { |
2b2be3fb |
82 | |
83 | //! Computes a hash code for the given value of the XCAFDoc_AssemblyItemId, in range [1, theUpperBound] |
84 | //! @param theAssemblyItemId the value of the XCAFDoc_AssemblyItemId type which hash code is to be computed |
85 | //! @param theUpperBound the upper bound of the range a computing hash code must be within |
86 | //! @return a computed hash code, in range [1, theUpperBound] |
87 | static Standard_Integer HashCode (const XCAFDoc_AssemblyItemId& theAssemblyItemId, |
88 | const Standard_Integer theUpperBound) |
024d6f77 |
89 | { |
2b2be3fb |
90 | return ::HashCode (theAssemblyItemId.ToString(), theUpperBound); |
024d6f77 |
91 | } |
92 | |
93 | static int IsEqual(const XCAFDoc_AssemblyItemId& theItem1, |
94 | const XCAFDoc_AssemblyItemId& theItem2) |
95 | { |
96 | return theItem1.IsEqual(theItem2); |
97 | } |
98 | }; |
99 | |
100 | private: |
101 | |
102 | TColStd_ListOfAsciiString myPath; ///< List of label entries |
103 | |
104 | }; |
105 | |
106 | #endif // _XCAFDoc_AssemblyItemId_HeaderFile |