Salome HOME
ae34c57f9c86c37fdbb63bb84c9bcedb31b0f09e
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTableOfString_i.cxx
1 // Copyright (C) 2007-2023  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_AttributeTableOfString_i.cxx
24 //  Author : Sergey RUIN
25 //  Module : SALOME
26 //
27 #include "SALOMEDS_AttributeTableOfString_i.hxx"
28 #include "SALOMEDS.hxx"
29
30 #include <sstream>
31 #include <string>
32 #include <vector>
33
34 #include "Utils_ExceptHandlers.hxx"
35
36 UNEXPECT_CATCH(ATS_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex)
37 UNEXPECT_CATCH(ATS_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength)
38
39 void SALOMEDS_AttributeTableOfString_i::SetTitle(const char* theTitle) 
40 {
41   SALOMEDS::Locker lock;
42   CheckLocked();
43   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
44   CORBA::String_var aStr = CORBA::string_dup(theTitle);
45   aTable->SetTitle(std::string(aStr));
46 }
47
48 char* SALOMEDS_AttributeTableOfString_i::GetTitle() 
49 {
50   SALOMEDS::Locker lock;
51   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
52   CORBA::String_var c_s = CORBA::string_dup(aTable->GetTitle().c_str());
53   return c_s._retn();
54 }
55
56 void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
57 {
58   SALOMEDS::Locker lock;
59   Unexpect aCatch(ATS_IncorrectIndex);
60   CheckLocked();
61   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
62   if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
63
64   aTable->SetRowTitle(theIndex, std::string(theTitle));
65 }
66
67 char* SALOMEDS_AttributeTableOfString_i::GetRowTitle(CORBA::Long theIndex)
68 {
69   SALOMEDS::Locker lock;
70   Unexpect aCatch (ATS_IncorrectIndex);
71   CheckLocked();
72   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
73   if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
74   CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowTitle(theIndex).c_str());
75   return c_s._retn();
76 }
77
78 void SALOMEDS_AttributeTableOfString_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
79 {
80   SALOMEDS::Locker lock;
81   Unexpect aCatch(ATS_IncorrectArgumentLength);
82   CheckLocked();
83   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
84   if ((int)theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
85   for (int i = 0; i < (int)theTitles.length(); i++) {
86     aTable->SetRowTitle(i + 1, std::string((char*)theTitles[i].in()));
87   }
88 }
89
90 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowTitles() 
91 {
92   SALOMEDS::Locker lock;
93   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
94   SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
95   aTitles->length(aTable->GetNbRows());
96   for(int i = 0; i < (int)aTitles->length(); i++)
97     aTitles[i] =CORBA::string_dup(aTable->GetRowTitle(i + 1).c_str());
98   return aTitles._retn();
99 }
100
101 void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
102 {
103   SALOMEDS::Locker lock;
104   Unexpect aCatch(ATS_IncorrectIndex);
105   CheckLocked();
106   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
107   if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
108   aTable->SetColumnTitle(theIndex, std::string((char*)theTitle));
109 }
110
111 char* SALOMEDS_AttributeTableOfString_i::GetColumnTitle(CORBA::Long theIndex)
112 {
113   SALOMEDS::Locker lock;
114   Unexpect aCatch (ATS_IncorrectIndex);
115   CheckLocked();
116   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
117   if (theIndex <= 0 || 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_AttributeTableOfString_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
123 {
124   SALOMEDS::Locker lock;
125   Unexpect aCatch(ATS_IncorrectArgumentLength);
126   CheckLocked();
127   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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, std::string((char*)theTitles[i].in()));
131   }
132 }
133
134 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumnTitles() 
135 {
136   SALOMEDS::Locker lock;
137   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
147 {
148   SALOMEDS::Locker lock;
149   Unexpect aCatch(ATS_IncorrectIndex);
150   CheckLocked();
151   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
152   if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
153   aTable->SetRowUnit(theIndex, std::string((char*)theUnit));
154 }
155
156 char* SALOMEDS_AttributeTableOfString_i::GetRowUnit(CORBA::Long theIndex)
157 {
158   SALOMEDS::Locker lock;
159   Unexpect aCatch (ATS_IncorrectIndex);
160   CheckLocked();
161   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
162   if (theIndex <= 0 || 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_AttributeTableOfString_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
168 {
169   SALOMEDS::Locker lock;
170   Unexpect aCatch(ATS_IncorrectArgumentLength);
171   CheckLocked();
172   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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, std::string((char*)theUnits[i].in()));
176   }
177 }
178
179 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowUnits() 
180 {
181   SALOMEDS::Locker lock;
182   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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
191 CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbRows() 
192 {
193   SALOMEDS::Locker lock;
194   return dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl)->GetNbRows();
195 }
196
197 CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbColumns() 
198 {
199   SALOMEDS::Locker lock;
200   return dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl)->GetNbColumns();
201 }
202
203 void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theData)
204 {
205   SALOMEDS::Locker lock;
206   Unexpect aCatch(ATS_IncorrectArgumentLength);
207   CheckLocked();
208   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
209   
210   std::vector<std::string> aRow;
211   for (size_t i = 0; i < theData.length(); i++) aRow.push_back(std::string(CORBA::string_dup(theData[(CORBA::ULong)i]))); //!< TODO: conversion from size_t to CORBA::ULong
212   aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
213 }
214
215 void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData)
216 {
217   SALOMEDS::Locker lock;
218   Unexpect aCatch(ATS_IncorrectArgumentLength);
219   CheckLocked();
220   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
221   
222   std::vector<std::string> aRow;
223   for (size_t i = 0; i < theData.length(); i++) aRow.push_back(std::string(CORBA::string_dup(theData[(CORBA::ULong)i].in()))); //!< TODO: conversion from size_t to CORBA::ULong
224   aTable->SetRowData(theRow, aRow);
225 }
226
227 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRow)
228 {
229   SALOMEDS::Locker lock;
230   Unexpect aCatch(ATS_IncorrectIndex);
231   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
232   if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
233
234   SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
235   std::vector<std::string> aRow = aTable->GetRowData(theRow);
236   CorbaSeq->length((CORBA::ULong)aRow.size()); //!< TODO: conversion from size_t to CORBA::ULong
237   for (int i = 0; i < (int)aRow.size(); i++) { //TODO: mismatch signed/unsigned
238     CorbaSeq[i] = CORBA::string_dup(aRow[i].c_str());
239   }
240   return CorbaSeq._retn();
241 }
242
243 void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& theData)
244 {
245   SALOMEDS::Locker lock;
246   Unexpect aCatch(ATS_IncorrectArgumentLength);
247   CheckLocked();
248   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
249   
250   std::vector<std::string> aColumn;
251   for (size_t i = 0; i < theData.length(); i++) aColumn.push_back(std::string(CORBA::string_dup(theData[(CORBA::ULong)i]))); //!< TODO: conversion from size_t to CORBA::ULong
252   aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
253 }
254
255 void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData)
256 {
257   SALOMEDS::Locker lock;
258   Unexpect aCatch(ATS_IncorrectArgumentLength);
259   CheckLocked();
260   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
261   
262   std::vector<std::string> aColumn;
263   for (size_t i = 0; i < theData.length(); i++) aColumn.push_back(std::string(CORBA::string_dup(theData[(CORBA::ULong)i]))); //!< TODO: conversion from size_t to CORBA::ULong
264   aTable->SetColumnData(theColumn, aColumn);
265 }
266
267 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long theColumn)
268 {
269   SALOMEDS::Locker lock;
270   Unexpect aCatch(ATS_IncorrectIndex);
271   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
272   if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
273
274   SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
275   std::vector<std::string> aColumn = aTable->GetColumnData(theColumn);
276   CorbaSeq->length((CORBA::ULong)aColumn.size()); //!< TODO: conversion from size_t to CORBA::ULong
277   for (int i = 0; i < (int)aColumn.size(); i++) { //TODO: mismatch signed/unsigned
278     CorbaSeq[i] = CORBA::string_dup(aColumn[i].c_str());
279   }
280   return CorbaSeq._retn();
281 }
282
283 void SALOMEDS_AttributeTableOfString_i::PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn)
284 {
285   SALOMEDS::Locker lock;
286   Unexpect aCatch(ATS_IncorrectIndex);
287   CheckLocked();
288   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
289   char* aValue = CORBA::string_dup(theValue);
290
291   aTable->PutValue(aValue, theRow, theColumn);
292 }
293
294 CORBA::Boolean SALOMEDS_AttributeTableOfString_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) 
295 {
296   SALOMEDS::Locker lock;
297   return dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl)->HasValue(theRow, theColumn);
298 }
299
300 char* SALOMEDS_AttributeTableOfString_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
301 {
302   SALOMEDS::Locker lock;
303   Unexpect aCatch(ATS_IncorrectIndex);
304   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
305   if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
306
307   std::string aValue;
308   try {
309     aValue = aTable->GetValue(theRow, theColumn);
310   }
311   catch(...) {
312     throw SALOMEDS::AttributeTable::IncorrectIndex();
313   }
314
315   return CORBA::string_dup(aValue.c_str());
316 }
317
318 void SALOMEDS_AttributeTableOfString_i::RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
319 {
320   SALOMEDS::Locker lock;
321   Unexpect aCatch(ATS_IncorrectIndex);
322   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
323   if (theRow    < 1 || theRow    > aTable->GetNbRows())    throw SALOMEDS::AttributeTable::IncorrectIndex();
324   if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
325
326   try {
327     aTable->RemoveValue(theRow, theColumn);
328   }
329   catch(...) {
330     throw SALOMEDS::AttributeTable::IncorrectIndex();
331   }
332 }
333
334 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfString_i::GetRowSetIndices(CORBA::Long theRow) 
335 {
336   SALOMEDS::Locker lock;
337   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
338
339   if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
340
341   SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
342   std::vector<int> aSeq = aTable->GetSetRowIndices(theRow);
343   CorbaSeq->length((CORBA::ULong)aSeq.size()); //!< TODO: conversion from size_t to CORBA::ULong
344   for (int i = 0; i < (int)aSeq.size(); i++) { //TODO: mismatch signed/unsigned
345     CorbaSeq[i] = aSeq[i];
346   }
347   return CorbaSeq._retn(); 
348 }
349
350 void SALOMEDS_AttributeTableOfString_i::SetNbColumns(CORBA::Long theNbColumns)
351 {
352   SALOMEDS::Locker lock;
353   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
354   aTable->SetNbColumns(theNbColumns);
355 }
356
357 bool SALOMEDS_AttributeTableOfString_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) 
358 {
359   SALOMEDS::Locker lock;
360   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
361
362   std::string aStream((char*)&theStream[0], theStream.length());
363   aTable->Load(aStream);
364   return true;
365 }
366
367 SALOMEDS::TMPFile*  SALOMEDS_AttributeTableOfString_i::SaveToFile()
368 {
369   SALOMEDS::Locker lock;
370   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SortRow(CORBA::Long theRow,
384                                                               SALOMEDS::AttributeTable::SortOrder sortOrder, 
385                                                               SALOMEDS::AttributeTable::SortPolicy sortPolicy)
386 {
387   SALOMEDS::Locker lock;
388   Unexpect aCatch(ATS_IncorrectIndex);
389   CheckLocked();
390   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SortColumn(CORBA::Long theColumn, 
410                                                                  SALOMEDS::AttributeTable::SortOrder sortOrder,
411                                                                  SALOMEDS::AttributeTable::SortPolicy sortPolicy)
412 {
413   SALOMEDS::Locker lock;
414   Unexpect aCatch(ATS_IncorrectIndex);
415   CheckLocked();
416   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SortByRow(CORBA::Long theRow,
436                                                                 SALOMEDS::AttributeTable::SortOrder sortOrder, 
437                                                                 SALOMEDS::AttributeTable::SortPolicy sortPolicy)
438 {
439   SALOMEDS::Locker lock;
440   Unexpect aCatch(ATS_IncorrectIndex);
441   CheckLocked();
442   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SortByColumn(CORBA::Long theColumn,
462                                                                    SALOMEDS::AttributeTable::SortOrder sortOrder, 
463                                                                    SALOMEDS::AttributeTable::SortPolicy sortPolicy)
464 {
465   SALOMEDS::Locker lock;
466   Unexpect aCatch(ATS_IncorrectIndex);
467   CheckLocked();
468   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1,
488                                                   CORBA::Long theRow2, CORBA::Long theColumn2)
489 {
490   SALOMEDS::Locker lock;
491   Unexpect aCatch(ATS_IncorrectIndex);
492   CheckLocked();
493   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SwapRows(CORBA::Long theRow1, CORBA::Long theRow2)
508 {
509   SALOMEDS::Locker lock;
510   Unexpect aCatch(ATS_IncorrectIndex);
511   CheckLocked();
512   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2)
525 {
526   SALOMEDS::Locker lock;
527   Unexpect aCatch(ATS_IncorrectIndex);
528   CheckLocked();
529   SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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 }