Salome HOME
Copyright update 2021
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTableOfInteger_i.cxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : SALOMEDS_AttributeTableOfInteger_i.cxx
24 //  Author : Sergey RUIN
25 //  Module : SALOME
26 //
27 #include "SALOMEDS_AttributeTableOfInteger_i.hxx"
28 #include "SALOMEDS.hxx"
29
30 #include "Utils_ExceptHandlers.hxx"
31
32 #include <stdexcept>
33 #include <sstream>
34 #include <string>
35 #include <vector>
36
37 UNEXPECT_CATCH(ATI_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex)
38 UNEXPECT_CATCH(ATI_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength)
39
40 void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle) 
41 {
42   SALOMEDS::Locker lock;
43   CheckLocked();
44   CORBA::String_var aStr = CORBA::string_dup(theTitle);
45   dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl)->SetTitle(std::string(aStr));
46 }
47
48 char* SALOMEDS_AttributeTableOfInteger_i::GetTitle() 
49 {
50   SALOMEDS::Locker lock;
51   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
52   CORBA::String_var c_s = CORBA::string_dup(aTable->GetTitle().c_str());
53   return c_s._retn();
54 }
55
56 void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
57 {
58   SALOMEDS::Locker lock;
59   Unexpect aCatch (ATI_IncorrectIndex);
60   CheckLocked();
61   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
62   if (theIndex < 1 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
63   aTable->SetRowTitle(theIndex, std::string(theTitle));
64 }
65
66 char* SALOMEDS_AttributeTableOfInteger_i::GetRowTitle(CORBA::Long theIndex)
67 {
68   SALOMEDS::Locker lock;
69   Unexpect aCatch (ATI_IncorrectIndex);
70   CheckLocked();
71   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
72   if (theIndex < 1 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
73   CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowTitle(theIndex).c_str());
74   return c_s._retn();
75 }
76
77 void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
78 {
79   SALOMEDS::Locker lock;
80   Unexpect aCatch (ATI_IncorrectArgumentLength);
81   CheckLocked();
82   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
83   if ((int)theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
84   for (int i = 0; i < (int)theTitles.length(); i++) {
85     SetRowTitle(i + 1, theTitles[i]);
86   }
87 }
88
89 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles() 
90 {
91   SALOMEDS::Locker lock;
92   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
93   SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
94   aTitles->length(aTable->GetNbRows());
95   for(int i = 0; i < (int)aTitles->length(); i++)
96     aTitles[i] = CORBA::string_dup(aTable->GetRowTitle(i + 1).c_str());
97   return aTitles._retn();
98 }
99
100 void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
101 {
102   SALOMEDS::Locker lock;
103   Unexpect aCatch (ATI_IncorrectIndex);
104   CheckLocked();
105   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
106   if (theIndex < 1 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
107   CORBA::String_var aStr = CORBA::string_dup(theTitle);
108   aTable->SetColumnTitle(theIndex, std::string(aStr));
109 }
110
111 char* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitle(CORBA::Long theIndex)
112 {
113   SALOMEDS::Locker lock;
114   Unexpect aCatch (ATI_IncorrectIndex);
115   CheckLocked();
116   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
117   if (theIndex < 1 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
118   CORBA::String_var c_s = CORBA::string_dup(aTable->GetColumnTitle(theIndex).c_str());
119   return c_s._retn();
120 }
121
122 void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
123 {
124   SALOMEDS::Locker lock;
125   Unexpect aCatch(ATI_IncorrectArgumentLength);
126   CheckLocked();
127   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
128   if ((int)theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
129   for (int i = 0; i < (int)theTitles.length(); i++) {
130     aTable->SetColumnTitle(i + 1, (char*)theTitles[i].in());
131   }
132 }
133
134 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles() 
135 {
136   SALOMEDS::Locker lock;
137   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
138   SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
139   aTitles->length(aTable->GetNbColumns());
140   for(int i = 0; i < (int)aTitles->length(); i++)
141     aTitles[i] = CORBA::string_dup(aTable->GetColumnTitle(i + 1).c_str());
142   return aTitles._retn();
143 }
144
145 //Units support
146 void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
147 {
148   SALOMEDS::Locker lock;
149   Unexpect aCatch (ATI_IncorrectIndex);
150   CheckLocked();
151   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
152   if (theIndex < 1 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
153   aTable->SetRowUnit(theIndex, std::string(theUnit));
154 }
155
156 char* SALOMEDS_AttributeTableOfInteger_i::GetRowUnit(CORBA::Long theIndex)
157 {
158   SALOMEDS::Locker lock;
159   Unexpect aCatch (ATI_IncorrectIndex);
160   CheckLocked();
161   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
162   if (theIndex < 1 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
163   CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowUnit(theIndex).c_str());
164   return c_s._retn();
165 }
166
167 void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
168 {
169   SALOMEDS::Locker lock;
170   Unexpect aCatch (ATI_IncorrectArgumentLength);
171   CheckLocked();
172   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
173   if ((int)theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
174   for (int i = 0; i < (int)theUnits.length(); i++) {
175     aTable->SetRowUnit(i + 1, (char*)theUnits[i].in());
176   }
177 }
178
179 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowUnits() 
180 {
181   SALOMEDS::Locker lock;
182   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
183   SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq;
184   aUnits->length(aTable->GetNbRows());
185   for(int i = 0; i < (int)aUnits->length(); i++)
186     aUnits[i] = CORBA::string_dup(aTable->GetRowUnit(i + 1).c_str());
187   return aUnits._retn();
188 }
189
190 CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbRows() 
191 {
192   SALOMEDS::Locker lock;
193   return dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl)->GetNbRows();
194 }
195
196 CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbColumns() 
197 {
198   SALOMEDS::Locker lock;
199   return dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl)->GetNbColumns();
200 }
201
202 void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData)
203 {
204   SALOMEDS::Locker lock;
205   Unexpect aCatch(ATI_IncorrectArgumentLength);
206   CheckLocked();
207   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
208   
209   std::vector<int> aRow;
210   for (size_t i = 0; i < theData.length(); i++) aRow.push_back(theData[(CORBA::ULong)i]); //!< TODO: conversion from size_t to CORBA::ULong
211   try {
212     aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
213   }
214   catch(...) {
215     throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
216   }
217 }
218
219 void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData)
220 {
221   SALOMEDS::Locker lock;
222   Unexpect aCatch(ATI_IncorrectArgumentLength);
223   CheckLocked();
224   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
225   
226   std::vector<int> aRow;
227   for (size_t i = 0; i < theData.length(); i++) aRow.push_back(theData[(CORBA::ULong)i]); //!< TODO: conversion from size_t to CORBA::ULong
228   try {
229     aTable->SetRowData(theRow, aRow);
230   }
231   catch(...) {
232     throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
233   }  
234 }
235
236 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow)
237 {
238   SALOMEDS::Locker lock;
239   Unexpect aCatch(ATI_IncorrectIndex);
240   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
241   if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
242
243   SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
244   std::vector<int> aRow = aTable->GetRowData(theRow);
245   CorbaSeq->length((CORBA::ULong)aRow.size()); //!< TODO: conversion from size_t to CORBA::ULong
246   for (int i = 0; i < (int)aRow.size(); i++) {
247     CorbaSeq[i] = aRow[i];
248   }
249   return CorbaSeq._retn();
250 }
251
252 void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theData)
253 {
254   SALOMEDS::Locker lock;
255   Unexpect aCatch(ATI_IncorrectArgumentLength);
256   CheckLocked();
257   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
258   
259   std::vector<int> aColumn;
260   for (size_t i = 0; i < theData.length(); i++) aColumn.push_back(theData[(CORBA::ULong)i]); //!< TODO: conversion from size_t to CORBA::ULong
261   try {
262     aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
263   }
264   catch(...) {
265     throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
266   }  
267 }
268
269 void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData)
270 {
271   SALOMEDS::Locker lock;
272   Unexpect aCatch(ATI_IncorrectArgumentLength);
273   CheckLocked();
274   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
275
276   std::vector<int> aColumn; 
277   for (size_t i = 0; i < theData.length(); i++) aColumn.push_back(theData[(CORBA::ULong)i]); //!< TODO: conversion from size_t to CORBA::ULong
278   try {
279     aTable->SetColumnData(theColumn, aColumn);
280   }
281   catch(...) {
282     throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
283   }
284 }
285
286 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long theColumn)
287 {
288   SALOMEDS::Locker lock;
289   Unexpect aCatch(ATI_IncorrectIndex);
290   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
291   if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
292
293   SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
294   std::vector<int> aColumn = aTable->GetColumnData(theColumn);
295   CorbaSeq->length((CORBA::ULong)aColumn.size()); //!< TODO: conversion from size_t to CORBA::ULong
296   for (int i = 0; i < (int)aColumn.size(); i++) {
297     CorbaSeq[i] = aColumn[i];
298   }
299   return CorbaSeq._retn();
300 }
301
302 void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn)
303 {
304   SALOMEDS::Locker lock;
305   Unexpect aCatch(ATI_IncorrectIndex);
306   CheckLocked();
307   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
308
309   try {
310     aTable->PutValue(theValue, theRow, theColumn);
311   }
312   catch(...) {
313     throw SALOMEDS::AttributeTable::IncorrectIndex();
314   }
315 }
316
317 CORBA::Boolean SALOMEDS_AttributeTableOfInteger_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) 
318 {
319   SALOMEDS::Locker lock;
320   return dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl)->HasValue(theRow, theColumn);
321 }
322
323 CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
324 {
325   SALOMEDS::Locker lock;
326   Unexpect aCatch(ATI_IncorrectIndex);
327   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
328   if (theRow    < 1 || theRow    > aTable->GetNbRows())    throw SALOMEDS::AttributeTable::IncorrectIndex();
329   if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
330
331   CORBA::Long aValue;
332   try {
333     aValue = aTable->GetValue(theRow, theColumn);
334   }
335   catch(...) {
336     throw SALOMEDS::AttributeTable::IncorrectIndex();
337   }
338   return aValue;
339 }
340
341 void SALOMEDS_AttributeTableOfInteger_i::RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
342 {
343   SALOMEDS::Locker lock;
344   Unexpect aCatch(ATI_IncorrectIndex);
345   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
346   if (theRow    < 1 || theRow    > aTable->GetNbRows())    throw SALOMEDS::AttributeTable::IncorrectIndex();
347   if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
348
349   try {
350     aTable->RemoveValue(theRow, theColumn);
351   }
352   catch(...) {
353     throw SALOMEDS::AttributeTable::IncorrectIndex();
354   }
355 }
356
357 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowSetIndices(CORBA::Long theRow) 
358 {
359   SALOMEDS::Locker lock;
360   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
361
362   if(theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
363
364   SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
365   std::vector<int> aSeq = aTable->GetSetRowIndices(theRow);
366   CorbaSeq->length((CORBA::ULong)aSeq.size()); //!< TODO: conversion from size_t to CORBA::ULong
367   for (int i = 0; i < (int)aSeq.size(); i++) { //TODO: mismatch signed/unsigned
368     CorbaSeq[i] = aSeq[i];
369   }
370   return CorbaSeq._retn(); 
371 }
372
373 void SALOMEDS_AttributeTableOfInteger_i::SetNbColumns(CORBA::Long theNbColumns)
374 {
375   SALOMEDS::Locker lock;
376   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
377   aTable->SetNbColumns(theNbColumns);
378 }
379
380 bool SALOMEDS_AttributeTableOfInteger_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) 
381 {
382   SALOMEDS::Locker lock;
383   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
384
385   std::string aStream((char*)&theStream[0], theStream.length());
386   aTable->Load(aStream);
387   return true;
388 }
389
390 SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile()
391 {
392   SALOMEDS::Locker lock;
393   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
394
395   std::string aString = aTable->Save();
396
397   char* aBuffer = (char*)CORBA::string_dup(aString.c_str());
398   int aBufferSize = (int)strlen((char*)aBuffer); //!< TODO: conversion from size_t to int
399
400   CORBA::Octet* anOctetBuf =  (CORBA::Octet*)aBuffer;
401
402   SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
403
404   return aStreamFile._retn();
405 }
406
407 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::SortRow(CORBA::Long theRow,
408                                                                SALOMEDS::AttributeTable::SortOrder sortOrder, 
409                                                                SALOMEDS::AttributeTable::SortPolicy sortPolicy)
410 {
411   SALOMEDS::Locker lock;
412   Unexpect aCatch(ATI_IncorrectIndex);
413   CheckLocked();
414   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
415   if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
416
417   std::vector<int> aSeq;
418   SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
419   try {
420     aSeq = aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, 
421                            (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
422   }
423   catch(...) {
424     throw SALOMEDS::AttributeTable::IncorrectIndex();
425   }
426   CorbaSeq->length((CORBA::ULong)aSeq.size()); //!< TODO: conversion from size_t to CORBA::ULong
427   for (int i = 0; i < (int)aSeq.size(); i++) { //TODO: mismatch signed/unsigned
428     CorbaSeq[i] = aSeq[i];
429   }
430   return CorbaSeq._retn(); 
431 }
432
433 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::SortColumn(CORBA::Long theColumn, 
434                                                                   SALOMEDS::AttributeTable::SortOrder sortOrder,
435                                                                   SALOMEDS::AttributeTable::SortPolicy sortPolicy)
436 {
437   SALOMEDS::Locker lock;
438   Unexpect aCatch(ATI_IncorrectIndex);
439   CheckLocked();
440   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
441   if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
442
443   std::vector<int> aSeq;
444   SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
445   try {
446     aSeq = aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, 
447                               (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
448   }
449   catch(...) {
450     throw SALOMEDS::AttributeTable::IncorrectIndex();
451   }
452   CorbaSeq->length((CORBA::ULong)aSeq.size()); //!< TODO: conversion from size_t to CORBA::ULong
453   for (int i = 0; i < (int)aSeq.size(); i++) { //TODO: mismatch signed/unsigned
454     CorbaSeq[i] = aSeq[i];
455   }
456   return CorbaSeq._retn(); 
457 }
458
459 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::SortByRow(CORBA::Long theRow,
460                                                                  SALOMEDS::AttributeTable::SortOrder sortOrder, 
461                                                                  SALOMEDS::AttributeTable::SortPolicy sortPolicy)
462 {
463   SALOMEDS::Locker lock;
464   Unexpect aCatch(ATI_IncorrectIndex);
465   CheckLocked();
466   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
467   if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
468
469   std::vector<int> aSeq;
470   SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
471   try {
472     aSeq = aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, 
473                              (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
474   }
475   catch(...) {
476     throw SALOMEDS::AttributeTable::IncorrectIndex();
477   }
478   CorbaSeq->length((CORBA::ULong)aSeq.size()); //!< TODO: conversion from size_t to CORBA::ULong
479   for (int i = 0; i < (int)aSeq.size(); i++) { //TODO: mismatch signed/unsigned
480     CorbaSeq[i] = aSeq[i];
481   }
482   return CorbaSeq._retn(); 
483 }
484
485 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::SortByColumn(CORBA::Long theColumn,
486                                                                     SALOMEDS::AttributeTable::SortOrder sortOrder, 
487                                                                     SALOMEDS::AttributeTable::SortPolicy sortPolicy)
488 {
489   SALOMEDS::Locker lock;
490   Unexpect aCatch(ATI_IncorrectIndex);
491   CheckLocked();
492   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
493   if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
494
495   std::vector<int> aSeq;
496   SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
497   try {
498     aSeq = aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, 
499                                 (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
500   }
501   catch(...) {
502     throw SALOMEDS::AttributeTable::IncorrectIndex();
503   }
504   CorbaSeq->length((CORBA::ULong)aSeq.size()); //!< TODO: conversion from size_t to CORBA::ULong
505   for (int i = 0; i < (int)aSeq.size(); i++) { //TODO: mismatch signed/unsigned
506     CorbaSeq[i] = aSeq[i];
507   }
508   return CorbaSeq._retn(); 
509 }
510
511 void SALOMEDS_AttributeTableOfInteger_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1,
512                                                    CORBA::Long theRow2, CORBA::Long theColumn2)
513 {
514   SALOMEDS::Locker lock;
515   Unexpect aCatch(ATI_IncorrectIndex);
516   CheckLocked();
517   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
518   if (theRow1    < 1 || theRow1    > aTable->GetNbRows())    throw SALOMEDS::AttributeTable::IncorrectIndex();
519   if (theColumn1 < 1 || theColumn1 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
520   if (theRow2    < 1 || theRow2    > aTable->GetNbRows())    throw SALOMEDS::AttributeTable::IncorrectIndex();
521   if (theColumn2 < 1 || theColumn2 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
522
523   try {
524     aTable->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
525   }
526   catch(...) {
527     throw SALOMEDS::AttributeTable::IncorrectIndex();
528   }
529 }
530
531 void SALOMEDS_AttributeTableOfInteger_i::SwapRows(CORBA::Long theRow1, CORBA::Long theRow2)
532 {
533   SALOMEDS::Locker lock;
534   Unexpect aCatch(ATI_IncorrectIndex);
535   CheckLocked();
536   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
537   if (theRow1 < 1 || theRow1 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
538   if (theRow2 < 1 || theRow2 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
539
540   try {
541     aTable->SwapRows(theRow1, theRow2);
542   }
543   catch(...) {
544     throw SALOMEDS::AttributeTable::IncorrectIndex();
545   }
546 }
547
548 void SALOMEDS_AttributeTableOfInteger_i::SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2)
549 {
550   SALOMEDS::Locker lock;
551   Unexpect aCatch(ATI_IncorrectIndex);
552   CheckLocked();
553   SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
554   if (theColumn1 < 1 || theColumn1 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
555   if (theColumn2 < 1 || theColumn2 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
556
557   try {
558     aTable->SwapColumns(theColumn1, theColumn2);
559   }
560   catch(...) {
561     throw SALOMEDS::AttributeTable::IncorrectIndex();
562   }
563 }