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