42cf5bc1 |
1 | // Created on: 1992-02-03 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Transfer_TransferMapOfProcessForFinder_HeaderFile |
18 | #define _Transfer_TransferMapOfProcessForFinder_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <TCollection_BasicMap.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <Standard_Address.hxx> |
28 | class Standard_DomainError; |
29 | class Standard_OutOfRange; |
30 | class Standard_NoSuchObject; |
31 | class Transfer_Finder; |
32 | class Transfer_Binder; |
33 | class Transfer_FindHasher; |
34 | class Transfer_IndexedDataMapNodeOfTransferMapOfProcessForFinder; |
35 | |
36 | |
37 | |
38 | class Transfer_TransferMapOfProcessForFinder : public TCollection_BasicMap |
39 | { |
40 | public: |
41 | |
42 | DEFINE_STANDARD_ALLOC |
43 | |
44 | |
36b9ff75 |
45 | //! Constructs an IndexedDataMap with NbBuckets |
46 | //! (defaulted to 1) buckets. |
47 | //! Note that the map will be automatically redimensioned |
48 | //! during its use if the number of entries becomes too large. |
49 | //! Use: |
50 | //! - the function Add to add an entry (key, item, index) in the map, |
51 | //! - operator() to read an item from an index, or to |
52 | //! assign a new value to this item, |
53 | //! - the function FindFromKey or ChangeFromKey to |
54 | //! read an item from a key, or to assign a new value to this item, |
55 | //! - the function RemoveLast to remove the last entry from the map, |
56 | //! - and other available edition and querying functions. |
42cf5bc1 |
57 | Standard_EXPORT Transfer_TransferMapOfProcessForFinder(const Standard_Integer NbBuckets = 1); |
58 | |
36b9ff75 |
59 | //! Replace the content of this map by the content of |
60 | //! the map <Other>. |
42cf5bc1 |
61 | Standard_EXPORT Transfer_TransferMapOfProcessForFinder& Assign (const Transfer_TransferMapOfProcessForFinder& Other); |
62 | Transfer_TransferMapOfProcessForFinder& operator = (const Transfer_TransferMapOfProcessForFinder& Other) |
63 | { |
64 | return Assign(Other); |
65 | } |
66 | |
36b9ff75 |
67 | //! Changes the number of buckets of <me> to be |
68 | //! <NbBuckets>. The entries (key + item + index) already |
69 | //! stored in this map are maintained. |
42cf5bc1 |
70 | Standard_EXPORT void ReSize (const Standard_Integer NbBuckets); |
71 | |
36b9ff75 |
72 | //! Removes all keys in the map. |
42cf5bc1 |
73 | Standard_EXPORT void Clear(); |
74 | ~Transfer_TransferMapOfProcessForFinder() |
75 | { |
76 | Clear(); |
77 | } |
78 | |
36b9ff75 |
79 | //! Adds the Key <K> to the Map <me>. Returns the |
80 | //! index of the Key. The key is new in the map if |
81 | //! Extent has been incremented. The Item <I> is |
82 | //! stored with the key. If the key was already in the |
83 | //! map the previous item is not replaced by <I>. |
42cf5bc1 |
84 | Standard_EXPORT Standard_Integer Add (const Handle(Transfer_Finder)& K, const Handle(Transfer_Binder)& I); |
85 | |
36b9ff75 |
86 | //! Substitutes the Key at index <I> with <K>. <I> |
87 | //! must be a valid index, <K> must be a new key. <T> |
88 | //! becomes the Item stored with <K>. |
89 | //! Trigger: Raises OutOfRange if I < 1 or I > Extent. |
90 | //! Raises DomainError if Contains(K). |
42cf5bc1 |
91 | Standard_EXPORT void Substitute (const Standard_Integer I, const Handle(Transfer_Finder)& K, const Handle(Transfer_Binder)& T); |
92 | |
36b9ff75 |
93 | //! Removes the last key entered in the map, i.e the |
94 | //! key of index Extent(). |
95 | //! I must be a valid index and K must be a new key. |
96 | //! Exceptions |
97 | //! - Standard_OutOfRange if the index I is less than 1 or |
98 | //! greater than the number of entries in this map. |
99 | //! - Standard_DomainError if the key K is already in this map. |
42cf5bc1 |
100 | Standard_EXPORT void RemoveLast(); |
101 | |
36b9ff75 |
102 | //! Returns True if the key <K> is stored in the map <me>. |
42cf5bc1 |
103 | Standard_EXPORT Standard_Boolean Contains (const Handle(Transfer_Finder)& K) const; |
104 | |
36b9ff75 |
105 | //! Returns the Key of index <I>. |
106 | //! Exceptions |
107 | //! Standard_OutOfRange if I is less than 1 or greater than |
108 | //! the number of entries in this map. |
42cf5bc1 |
109 | Standard_EXPORT const Handle(Transfer_Finder)& FindKey (const Standard_Integer I) const; |
110 | |
36b9ff75 |
111 | //! Returns the Item of index <I>. |
42cf5bc1 |
112 | Standard_EXPORT const Handle(Transfer_Binder)& FindFromIndex (const Standard_Integer I) const; |
113 | const Handle(Transfer_Binder)& operator () (const Standard_Integer I) const |
114 | { |
115 | return FindFromIndex(I); |
116 | } |
117 | |
36b9ff75 |
118 | //! Returns the Item of index <I>. The Item can be |
119 | //! modified with the syntax aMap(Index) = newItem. |
42cf5bc1 |
120 | Standard_EXPORT Handle(Transfer_Binder)& ChangeFromIndex (const Standard_Integer I); |
121 | Handle(Transfer_Binder)& operator () (const Standard_Integer I) |
122 | { |
123 | return ChangeFromIndex(I); |
124 | } |
125 | |
36b9ff75 |
126 | //! Returns the index of the key <K>. |
127 | //! Returns 0 if K is not in the map. |
42cf5bc1 |
128 | Standard_EXPORT Standard_Integer FindIndex (const Handle(Transfer_Finder)& K) const; |
129 | |
36b9ff75 |
130 | //! Returns the Item of the key <K> |
131 | //! Trigger: Raises NoSuchObject if K is not in the map. |
42cf5bc1 |
132 | Standard_EXPORT const Handle(Transfer_Binder)& FindFromKey (const Handle(Transfer_Finder)& K) const; |
133 | |
36b9ff75 |
134 | //! Returns the Item of the key <K> |
135 | //! Trigger: Raises NoSuchObject if K is not in the map. |
42cf5bc1 |
136 | Standard_EXPORT Handle(Transfer_Binder)& ChangeFromKey (const Handle(Transfer_Finder)& K); |
137 | |
36b9ff75 |
138 | //! Returns the address of Item of the key <K> |
139 | //! or NULL if K is not in the map. |
42cf5bc1 |
140 | Standard_EXPORT Standard_Address FindFromKey1 (const Handle(Transfer_Finder)& K) const; |
141 | |
36b9ff75 |
142 | //! Returns the address of Item of the key <K> |
143 | //! or NULL if K is not in the map. |
42cf5bc1 |
144 | Standard_EXPORT Standard_Address ChangeFromKey1 (const Handle(Transfer_Finder)& K); |
145 | |
146 | |
147 | |
148 | |
149 | protected: |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | private: |
156 | |
157 | |
36b9ff75 |
158 | //! As copying Map is an expensive operation it is |
159 | //! incorrect to do it implicitly. This constructor |
160 | //! will raise an error if the Map is not empty. To copy the |
161 | //! content of a Map use the Assign method (operator =). |
42cf5bc1 |
162 | Standard_EXPORT Transfer_TransferMapOfProcessForFinder(const Transfer_TransferMapOfProcessForFinder& Other); |
163 | |
164 | |
165 | |
166 | |
167 | }; |
168 | |
169 | |
170 | |
171 | |
172 | |
173 | |
174 | |
175 | #endif // _Transfer_TransferMapOfProcessForFinder_HeaderFile |