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