0023569: Adding NCollection_StdAllocator
[occt.git] / src / QANCollection / QANCollection_Common3.hxx
1 // Created on: 2002-05-15
2 // Created by: Alexander KARTOMIN (akm)
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21
22 #ifndef QANCollection_Common3_HeaderFile
23 #define QANCollection_Common3_HeaderFile
24
25 #include <stdio.h>
26 #include <gp_Pnt.hxx>
27
28 #include <QANCollection_Common.hxx>
29
30 // =====================               INSTANTIATIONS               ===========
31 // ===================== The Types must be defined before this line ===========
32 // These are: TheItemType, TheKey1Type, TheKey2Type
33 // So must be defined ::HashCode and ::IsEqual too
34
35 #if defined(ItemType) && defined(Key1Type) && defined(Key2Type)
36
37 #include <NCollection_DefineBaseCollection.hxx>
38 ////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_BaseCol,ItemType)
39 ////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_Key1BaseCol,Key1Type)
40 ////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_Key2BaseCol,Key2Type)
41 DEFINE_BASECOLLECTION(QANCollection_BaseColPerf,ItemType)
42 DEFINE_BASECOLLECTION(QANCollection_Key1BaseColPerf,Key1Type)
43 DEFINE_BASECOLLECTION(QANCollection_Key2BaseColPerf,Key2Type)
44
45 #include <NCollection_DefineArray1.hxx>
46 #include <NCollection_DefineHArray1.hxx>
47 ////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType)
48 ////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1)
49 DEFINE_ARRAY1(QANCollection_Array1Perf,QANCollection_BaseColPerf,ItemType)
50 DEFINE_HARRAY1(QANCollection_HArray1Perf,QANCollection_Array1Perf)
51
52 #include <NCollection_DefineArray2.hxx>
53 #include <NCollection_DefineHArray2.hxx>
54 ////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType)
55 ////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2)
56 DEFINE_ARRAY2(QANCollection_Array2Perf,QANCollection_BaseColPerf,ItemType)
57 DEFINE_HARRAY2(QANCollection_HArray2Perf,QANCollection_Array2Perf)
58
59 #include <NCollection_DefineMap.hxx>
60 #include <NCollection_DefineDataMap.hxx>
61 #include <NCollection_DefineDoubleMap.hxx>
62 #include <NCollection_DefineIndexedMap.hxx>
63 #include <NCollection_DefineIndexedDataMap.hxx>
64 ////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type)
65 ////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType)
66 ////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type)
67 ////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type)
68 ////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType)
69 DEFINE_MAP(QANCollection_MapPerf,QANCollection_Key1BaseColPerf,Key1Type)
70 DEFINE_DATAMAP(QANCollection_DataMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
71 DEFINE_DOUBLEMAP(QANCollection_DoubleMapPerf,QANCollection_Key2BaseColPerf,Key1Type,Key2Type)
72 DEFINE_INDEXEDMAP(QANCollection_IndexedMapPerf,QANCollection_Key1BaseColPerf,Key1Type)
73 DEFINE_INDEXEDDATAMAP(QANCollection_IDMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
74
75 #include <NCollection_DefineList.hxx>
76 #include <NCollection_DefineQueue.hxx>
77 #include <NCollection_DefineStack.hxx>
78 #include <NCollection_DefineSet.hxx>
79 #include <NCollection_DefineHSet.hxx>
80 ////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
81 ////////////////////////////////DEFINE_QUEUE(QANCollection_Queue,QANCollection_BaseCol,ItemType)
82 ////////////////////////////////DEFINE_STACK(QANCollection_Stack,QANCollection_BaseCol,ItemType)
83 ////////////////////////////////DEFINE_SET(QANCollection_Set,QANCollection_Key2BaseCol,Key2Type)
84 ////////////////////////////////DEFINE_HSET(QANCollection_HSet,QANCollection_Set)
85 DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType)
86 DEFINE_QUEUE(QANCollection_QueuePerf,QANCollection_BaseColPerf,ItemType)
87 DEFINE_STACK(QANCollection_StackPerf,QANCollection_BaseColPerf,ItemType)
88 DEFINE_SET(QANCollection_SetPerf,QANCollection_Key2BaseColPerf,Key2Type)
89 DEFINE_HSET(QANCollection_HSetPerf,QANCollection_SetPerf)
90
91 #include <NCollection_DefineSList.hxx>
92 ////////////////////////////////DEFINE_SLIST(QANCollection_SList,QANCollection_BaseCol,ItemType)
93 DEFINE_SLIST(QANCollection_SListPerf,QANCollection_BaseColPerf,ItemType)
94
95 #include <NCollection_DefineSequence.hxx>
96 #include <NCollection_DefineHSequence.hxx>
97 ////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType)
98 ////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence)
99 DEFINE_SEQUENCE(QANCollection_SequencePerf,QANCollection_BaseColPerf,ItemType)
100 DEFINE_HSEQUENCE(QANCollection_HSequencePerf,QANCollection_SequencePerf)
101
102
103 // ===================== Type independent methods =============================
104 ////////////////////////////////void printCollection (QANCollection_BaseCol& aColl, 
105 #if 0
106 void printCollection (QANCollection_BaseColPerf& aColl, 
107                       const char * str)
108 {
109   printf ("%s:\n",str);
110   Standard_Integer iSize = aColl.Size();
111   ////////////////////////////////QANCollection_BaseCol::Iterator& anIter = aColl.CreateIterator();
112   QANCollection_BaseColPerf::Iterator& anIter = aColl.CreateIterator();
113   if (!anIter.More())
114   {
115     if (iSize==0)
116       printf ("   <Empty collection>\n");
117     else
118       printf ("Error   : empty collection has size==%d",iSize);
119   }
120   else
121   {
122     printf ("   Size==%d\n",iSize);
123     for (; anIter.More(); anIter.Next())
124       PrintItem(anIter.Value());
125   }
126 }
127
128 ////////////////////////////////void printCollection (QANCollection_Key1BaseCol& aColl, 
129 void printCollection (QANCollection_Key1BaseColPerf& aColl, 
130                       const char * str)
131 {
132   printf ("%s:\n",str);
133   Standard_Integer iSize = aColl.Size();
134   ////////////////////////////////QANCollection_Key1BaseCol::Iterator& anIter = aColl.CreateIterator();
135   QANCollection_Key1BaseColPerf::Iterator& anIter = aColl.CreateIterator();
136   if (!anIter.More())
137   {
138     if (iSize==0)
139       printf ("   <Empty collection>\n");
140     else
141       printf ("Error   : empty collection has size==%d",iSize);
142   }
143   else
144   {
145     printf ("   Size==%d\n",iSize);
146     for (; anIter.More(); anIter.Next())
147       PrintItem(anIter.Value());
148   }
149 }
150
151 ////////////////////////////////void printCollection (QANCollection_Key2BaseCol& aColl, 
152 void printCollection (QANCollection_Key2BaseColPerf& aColl, 
153                       const char * str)
154 {
155   printf ("%s:\n",str);
156   Standard_Integer iSize = aColl.Size();
157   ////////////////////////////////QANCollection_Key2BaseCol::Iterator& anIter = aColl.CreateIterator();
158   QANCollection_Key2BaseColPerf::Iterator& anIter = aColl.CreateIterator();
159   if (!anIter.More())
160   {
161     if (iSize==0)
162       printf ("   <Empty collection>\n");
163     else
164       printf ("Error   : empty collection has size==%d",iSize);
165   }
166   else
167   {
168     printf ("   Size==%d\n",iSize);
169     for (; anIter.More(); anIter.Next())
170       PrintItem(anIter.Value());
171   }
172 }
173
174 ////////////////////////////////void AssignCollection (QANCollection_BaseCol& aCollSrc,
175 ////////////////////////////////                       QANCollection_BaseCol& aCollDst)
176 void AssignCollection (QANCollection_BaseColPerf& aCollSrc,
177                        QANCollection_BaseColPerf& aCollDst)
178 {
179   printCollection (aCollSrc,"Source collection");
180   aCollDst.Assign(aCollSrc);
181   printCollection (aCollDst,"Target collection");
182 }
183
184 ////////////////////////////////void AssignCollection (QANCollection_Key1BaseCol& aCollSrc,
185 ////////////////////////////////                       QANCollection_Key1BaseCol& aCollDst)
186 void AssignCollection (QANCollection_Key1BaseColPerf& aCollSrc,
187                        QANCollection_Key1BaseColPerf& aCollDst)
188 {
189   printCollection (aCollSrc,"Source collection");
190   aCollDst.Assign(aCollSrc);
191   printCollection (aCollDst,"Target collection");
192 }
193
194 ////////////////////////////////void AssignCollection (QANCollection_Key2BaseCol& aCollSrc,
195 ////////////////////////////////                       QANCollection_Key2BaseCol& aCollDst)
196 void AssignCollection (QANCollection_Key2BaseColPerf& aCollSrc,
197                        QANCollection_Key2BaseColPerf& aCollDst)
198 {
199   printCollection (aCollSrc,"Source collection");
200   aCollDst.Assign(aCollSrc);
201   printCollection (aCollDst,"Target collection");
202 }
203 #endif
204
205 #endif
206
207 #endif