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