6ba90b9f90e3958e6ab0bb0cc20f35b96e472b24
[occt.git] / src / QANCollection / QANCollection_Common3.hxx
1 // Created on: 2002-05-15
2 // Created by: Alexander KARTOMIN (akm)
3 // Copyright (c) 2002-2014 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 QANCollection_Common3_HeaderFile
17 #define QANCollection_Common3_HeaderFile
18
19 #include <stdio.h>
20 #include <gp_Pnt.hxx>
21
22 #include <QANCollection_Common.hxx>
23
24 // =====================               INSTANTIATIONS               ===========
25 // ===================== The Types must be defined before this line ===========
26 // These are: TheItemType, TheKey1Type, TheKey2Type
27 // So must be defined ::HashCode and ::IsEqual too
28
29 #if defined(ItemType) && defined(Key1Type) && defined(Key2Type)
30
31 #include <NCollection_DefineBaseCollection.hxx>
32 ////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_BaseCol,ItemType)
33 ////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_Key1BaseCol,Key1Type)
34 ////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_Key2BaseCol,Key2Type)
35 DEFINE_BASECOLLECTION(QANCollection_BaseColPerf,ItemType)
36 DEFINE_BASECOLLECTION(QANCollection_Key1BaseColPerf,Key1Type)
37 DEFINE_BASECOLLECTION(QANCollection_Key2BaseColPerf,Key2Type)
38
39 #include <NCollection_DefineArray1.hxx>
40 #include <NCollection_DefineHArray1.hxx>
41 ////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType)
42 ////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1)
43 DEFINE_ARRAY1(QANCollection_Array1Perf,QANCollection_BaseColPerf,ItemType)
44 DEFINE_HARRAY1(QANCollection_HArray1Perf,QANCollection_Array1Perf)
45
46 #include <NCollection_DefineArray2.hxx>
47 #include <NCollection_DefineHArray2.hxx>
48 ////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType)
49 ////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2)
50 DEFINE_ARRAY2(QANCollection_Array2Perf,QANCollection_BaseColPerf,ItemType)
51 DEFINE_HARRAY2(QANCollection_HArray2Perf,QANCollection_Array2Perf)
52
53 #include <NCollection_DefineMap.hxx>
54 #include <NCollection_DefineDataMap.hxx>
55 #include <NCollection_DefineDoubleMap.hxx>
56 #include <NCollection_DefineIndexedMap.hxx>
57 #include <NCollection_DefineIndexedDataMap.hxx>
58 ////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type)
59 ////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType)
60 ////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type)
61 ////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type)
62 ////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType)
63 DEFINE_MAP(QANCollection_MapPerf,QANCollection_Key1BaseColPerf,Key1Type)
64 DEFINE_DATAMAP(QANCollection_DataMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
65 DEFINE_DOUBLEMAP(QANCollection_DoubleMapPerf,QANCollection_Key2BaseColPerf,Key1Type,Key2Type)
66 DEFINE_INDEXEDMAP(QANCollection_IndexedMapPerf,QANCollection_Key1BaseColPerf,Key1Type)
67 DEFINE_INDEXEDDATAMAP(QANCollection_IDMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType)
68
69 #include <NCollection_DefineList.hxx>
70 #include <NCollection_DefineStack.hxx>
71 #include <NCollection_DefineSet.hxx>
72 #include <NCollection_DefineHSet.hxx>
73 ////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType)
74 ////////////////////////////////DEFINE_STACK(QANCollection_Stack,QANCollection_BaseCol,ItemType)
75 ////////////////////////////////DEFINE_SET(QANCollection_Set,QANCollection_Key2BaseCol,Key2Type)
76 ////////////////////////////////DEFINE_HSET(QANCollection_HSet,QANCollection_Set)
77 DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType)
78 DEFINE_STACK(QANCollection_StackPerf,QANCollection_BaseColPerf,ItemType)
79 DEFINE_SET(QANCollection_SetPerf,QANCollection_Key2BaseColPerf,Key2Type)
80 DEFINE_HSET(QANCollection_HSetPerf,QANCollection_SetPerf)
81
82 #include <NCollection_DefineSequence.hxx>
83 #include <NCollection_DefineHSequence.hxx>
84 ////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType)
85 ////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence)
86 DEFINE_SEQUENCE(QANCollection_SequencePerf,QANCollection_BaseColPerf,ItemType)
87 DEFINE_HSEQUENCE(QANCollection_HSequencePerf,QANCollection_SequencePerf)
88
89
90 // ===================== Type independent methods =============================
91 ////////////////////////////////void printCollection (QANCollection_BaseCol& aColl, 
92 #if 0
93 void printCollection (QANCollection_BaseColPerf& aColl, 
94                       const char * str)
95 {
96   printf ("%s:\n",str);
97   Standard_Integer iSize = aColl.Size();
98   ////////////////////////////////QANCollection_BaseCol::Iterator& anIter = aColl.CreateIterator();
99   QANCollection_BaseColPerf::Iterator& anIter = aColl.CreateIterator();
100   if (!anIter.More())
101   {
102     if (iSize==0)
103       printf ("   <Empty collection>\n");
104     else
105       printf ("Error   : empty collection has size==%d",iSize);
106   }
107   else
108   {
109     printf ("   Size==%d\n",iSize);
110     for (; anIter.More(); anIter.Next())
111       PrintItem(anIter.Value());
112   }
113 }
114
115 ////////////////////////////////void printCollection (QANCollection_Key1BaseCol& aColl, 
116 void printCollection (QANCollection_Key1BaseColPerf& aColl, 
117                       const char * str)
118 {
119   printf ("%s:\n",str);
120   Standard_Integer iSize = aColl.Size();
121   ////////////////////////////////QANCollection_Key1BaseCol::Iterator& anIter = aColl.CreateIterator();
122   QANCollection_Key1BaseColPerf::Iterator& anIter = aColl.CreateIterator();
123   if (!anIter.More())
124   {
125     if (iSize==0)
126       printf ("   <Empty collection>\n");
127     else
128       printf ("Error   : empty collection has size==%d",iSize);
129   }
130   else
131   {
132     printf ("   Size==%d\n",iSize);
133     for (; anIter.More(); anIter.Next())
134       PrintItem(anIter.Value());
135   }
136 }
137
138 ////////////////////////////////void printCollection (QANCollection_Key2BaseCol& aColl, 
139 void printCollection (QANCollection_Key2BaseColPerf& aColl, 
140                       const char * str)
141 {
142   printf ("%s:\n",str);
143   Standard_Integer iSize = aColl.Size();
144   ////////////////////////////////QANCollection_Key2BaseCol::Iterator& anIter = aColl.CreateIterator();
145   QANCollection_Key2BaseColPerf::Iterator& anIter = aColl.CreateIterator();
146   if (!anIter.More())
147   {
148     if (iSize==0)
149       printf ("   <Empty collection>\n");
150     else
151       printf ("Error   : empty collection has size==%d",iSize);
152   }
153   else
154   {
155     printf ("   Size==%d\n",iSize);
156     for (; anIter.More(); anIter.Next())
157       PrintItem(anIter.Value());
158   }
159 }
160
161 ////////////////////////////////void AssignCollection (QANCollection_BaseCol& aCollSrc,
162 ////////////////////////////////                       QANCollection_BaseCol& aCollDst)
163 void AssignCollection (QANCollection_BaseColPerf& aCollSrc,
164                        QANCollection_BaseColPerf& aCollDst)
165 {
166   printCollection (aCollSrc,"Source collection");
167   aCollDst.Assign(aCollSrc);
168   printCollection (aCollDst,"Target collection");
169 }
170
171 ////////////////////////////////void AssignCollection (QANCollection_Key1BaseCol& aCollSrc,
172 ////////////////////////////////                       QANCollection_Key1BaseCol& aCollDst)
173 void AssignCollection (QANCollection_Key1BaseColPerf& aCollSrc,
174                        QANCollection_Key1BaseColPerf& aCollDst)
175 {
176   printCollection (aCollSrc,"Source collection");
177   aCollDst.Assign(aCollSrc);
178   printCollection (aCollDst,"Target collection");
179 }
180
181 ////////////////////////////////void AssignCollection (QANCollection_Key2BaseCol& aCollSrc,
182 ////////////////////////////////                       QANCollection_Key2BaseCol& aCollDst)
183 void AssignCollection (QANCollection_Key2BaseColPerf& aCollSrc,
184                        QANCollection_Key2BaseColPerf& aCollDst)
185 {
186   printCollection (aCollSrc,"Source collection");
187   aCollDst.Assign(aCollSrc);
188   printCollection (aCollDst,"Target collection");
189 }
190 #endif
191
192 #endif
193
194 #endif