Salome HOME
0aa82c84b3e76a35929c64bf6f467ae7477bb4bc
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTableOfReal_i.cxx
1 // Copyright (C) 2007-2014  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_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      throw (SALOMEDS::AttributeTable::IncorrectIndex)
57 {
58   SALOMEDS::Locker lock; 
59   Unexpect aCatch (ATR_IncorrectIndex);
60   CheckLocked();
61   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
62   if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
63   aTable->SetRowTitle(theIndex, std::string(theTitle));
64 }
65
66 char* SALOMEDS_AttributeTableOfReal_i::GetRowTitle(CORBA::Long theIndex)
67      throw (SALOMEDS::AttributeTable::IncorrectIndex)
68 {
69   SALOMEDS::Locker lock;
70   Unexpect aCatch (ATR_IncorrectIndex);
71   CheckLocked();
72   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_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_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
79      throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
80 {
81   SALOMEDS::Locker lock; 
82   Unexpect aCatch (ATR_IncorrectArgumentLength);
83   CheckLocked();
84   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
85   if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
86   for (int i = 0; i < theTitles.length(); i++) {
87     aTable->SetRowTitle(i + 1, (char*)theTitles[i].in());
88   }
89 }
90
91 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles() 
92 {
93   SALOMEDS::Locker lock; 
94   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
95   SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
96   aTitles->length(aTable->GetNbRows());
97   for(int i = 0; i < aTitles->length(); i++)
98     aTitles[i] = CORBA::string_dup(aTable->GetRowTitle(i + 1).c_str());
99   return aTitles._retn();
100 }
101
102 void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
103      throw (SALOMEDS::AttributeTable::IncorrectIndex)
104 {
105   SALOMEDS::Locker lock; 
106   Unexpect aCatch (ATR_IncorrectIndex);
107   CheckLocked();
108   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
109   if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
110   CORBA::String_var aStr = CORBA::string_dup(theTitle);
111   aTable->SetColumnTitle(theIndex, std::string(aStr));
112 }
113
114 char* SALOMEDS_AttributeTableOfReal_i::GetColumnTitle(CORBA::Long theIndex)
115      throw (SALOMEDS::AttributeTable::IncorrectIndex)
116 {
117   SALOMEDS::Locker lock;
118   Unexpect aCatch (ATR_IncorrectIndex);
119   CheckLocked();
120   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
121   if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
122   CORBA::String_var c_s = CORBA::string_dup(aTable->GetColumnTitle(theIndex).c_str());
123   return c_s._retn();
124 }
125
126 void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
127      throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
128 {
129   SALOMEDS::Locker lock; 
130   Unexpect aCatch(ATR_IncorrectArgumentLength);
131   CheckLocked();
132   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
133   if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
134   for (int i = 0; i < theTitles.length(); i++) {
135     aTable->SetColumnTitle(i + 1, (char*)theTitles[i].in());
136   }
137 }
138
139 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles() 
140 {
141   SALOMEDS::Locker lock; 
142   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
143   SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
144   aTitles->length(aTable->GetNbColumns());
145   for(int i = 0; i < aTitles->length(); i++)
146     aTitles[i] = CORBA::string_dup(aTable->GetColumnTitle(i + 1).c_str());
147   return aTitles._retn();
148 }
149
150 //Units support
151 void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
152      throw (SALOMEDS::AttributeTable::IncorrectIndex)
153 {
154   SALOMEDS::Locker lock; 
155   Unexpect aCatch (ATR_IncorrectIndex);
156   CheckLocked();
157   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
158   if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
159   aTable->SetRowUnit(theIndex, std::string(theUnit));
160 }
161
162 char* SALOMEDS_AttributeTableOfReal_i::GetRowUnit(CORBA::Long theIndex)
163      throw (SALOMEDS::AttributeTable::IncorrectIndex)
164 {
165   SALOMEDS::Locker lock;
166   Unexpect aCatch (ATR_IncorrectIndex);
167   CheckLocked();
168   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
169   if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
170   CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowUnit(theIndex).c_str());
171   return c_s._retn();
172 }
173
174 void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
175      throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
176 {
177   SALOMEDS::Locker lock; 
178   Unexpect aCatch (ATR_IncorrectArgumentLength);
179   CheckLocked();
180   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
181   if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
182   for (int i = 0; i < theUnits.length(); i++) {
183     aTable->SetRowUnit(i + 1, (char*)theUnits[i].in());
184   }
185 }
186
187 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowUnits() 
188 {
189   SALOMEDS::Locker lock; 
190   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
191   SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq;
192   aUnits->length(aTable->GetNbRows());
193   for(int i = 0; i < aUnits->length(); i++)
194     aUnits[i] = CORBA::string_dup(aTable->GetRowUnit(i + 1).c_str());
195   return aUnits._retn();
196 }
197
198
199 CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbRows() 
200 {
201   SALOMEDS::Locker lock; 
202   return dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl)->GetNbRows();
203 }
204
205 CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns() 
206 {
207   SALOMEDS::Locker lock; 
208   return dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl)->GetNbColumns();
209 }
210
211 void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData)
212      throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
213 {
214   SALOMEDS::Locker lock; 
215   Unexpect aCatch(ATR_IncorrectArgumentLength);
216   CheckLocked();
217   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
218   
219   std::vector<double> aRow;
220   for (int i = 0; i < theData.length(); i++) aRow.push_back(theData[i]);
221   aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
222 }
223
224 void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData)
225      throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex)
226 {
227   SALOMEDS::Locker lock; 
228   Unexpect aCatch(ATR_IncorrectArgumentLength);
229   CheckLocked();
230   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
231   
232   std::vector<double> aRow;
233   for (int i = 0; i < theData.length(); i++) aRow.push_back(theData[i]);
234   aTable->SetRowData(theRow, aRow);
235 }
236
237 SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow)
238      throw (SALOMEDS::AttributeTable::IncorrectIndex)
239 {
240   SALOMEDS::Locker lock; 
241   Unexpect aCatch(ATR_IncorrectIndex);
242   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
243   if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
244
245   SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq;
246   std::vector<double> aRow = aTable->GetRowData(theRow);
247   CorbaSeq->length(aRow.size());
248   for (int i = 0; i < aRow.size(); i++) {
249     CorbaSeq[i] = aRow[i];
250   }
251   return CorbaSeq._retn();
252 }
253
254 void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData)
255      throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
256 {
257   SALOMEDS::Locker lock; 
258   Unexpect aCatch(ATR_IncorrectArgumentLength);
259   CheckLocked();
260   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
261   
262   std::vector<double> aColumn;
263   for (int i = 0; i < theData.length(); i++) aColumn.push_back(theData[i]);
264   aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
265 }
266
267 void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData)
268      throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex)
269 {
270   SALOMEDS::Locker lock; 
271   Unexpect aCatch(ATR_IncorrectArgumentLength);
272   CheckLocked();
273   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
274   
275   std::vector<double> aColumn;
276   for (int i = 0; i < theData.length(); i++) aColumn.push_back(theData[i]);
277   aTable->SetColumnData(theColumn, aColumn);
278 }
279
280 SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn)
281      throw (SALOMEDS::AttributeTable::IncorrectIndex)
282 {
283   SALOMEDS::Locker lock; 
284   Unexpect aCatch(ATR_IncorrectIndex);
285   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
286   if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
287
288   SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq;
289   std::vector<double> aColumn = aTable->GetColumnData(theColumn);
290   CorbaSeq->length(aColumn.size());
291   for (int i = 0; i < aColumn.size(); i++) {
292     CorbaSeq[i] = aColumn[i];
293   }
294   return CorbaSeq._retn();
295 }
296
297 void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn)
298      throw (SALOMEDS::AttributeTable::IncorrectIndex)
299 {
300   SALOMEDS::Locker lock; 
301   Unexpect aCatch(ATR_IncorrectIndex);
302   CheckLocked();
303   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
304
305   aTable->PutValue(theValue, theRow, theColumn);
306 }
307
308 CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) 
309 {
310   SALOMEDS::Locker lock; 
311   return dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl)->HasValue(theRow, theColumn);
312 }
313
314 CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
315      throw (SALOMEDS::AttributeTable::IncorrectIndex)
316 {
317   SALOMEDS::Locker lock; 
318   Unexpect aCatch(ATR_IncorrectIndex);
319   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
320   if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
321
322   CORBA::Double aValue;
323
324   try {
325     aValue = aTable->GetValue(theRow, theColumn);
326   }
327   catch(...) {
328     throw SALOMEDS::AttributeTable::IncorrectIndex();
329   }
330
331   return aValue;
332 }
333
334 void SALOMEDS_AttributeTableOfReal_i::RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
335   throw (SALOMEDS::AttributeTable::IncorrectIndex)
336 {
337   SALOMEDS::Locker lock;
338   Unexpect aCatch(ATR_IncorrectIndex);
339   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
340   if (theRow    < 1 || theRow    > aTable->GetNbRows())    throw SALOMEDS::AttributeTable::IncorrectIndex();
341   if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
342
343   try {
344     aTable->RemoveValue(theRow, theColumn);
345   }
346   catch(...) {
347     throw SALOMEDS::AttributeTable::IncorrectIndex();
348   }
349 }
350
351 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::GetRowSetIndices(CORBA::Long theRow) 
352 {
353   SALOMEDS::Locker lock; 
354   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
355
356   if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
357
358   SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
359   std::vector<int> aSeq = aTable->GetSetRowIndices(theRow);
360   int len = aSeq.size();
361   CorbaSeq->length(len);
362   for (int i = 0; i < len; i++) {
363     CorbaSeq[i] = aSeq[i];
364   }
365   return CorbaSeq._retn(); 
366 }
367
368 void SALOMEDS_AttributeTableOfReal_i::SetNbColumns(CORBA::Long theNbColumns)
369 {
370   SALOMEDS::Locker lock; 
371   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
372   aTable->SetNbColumns(theNbColumns);
373 }
374
375 bool SALOMEDS_AttributeTableOfReal_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) 
376 {
377   SALOMEDS::Locker lock; 
378   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
379
380   std::string aStream((char*)&theStream[0], theStream.length());
381   aTable->Load(aStream);
382   return true;
383 }
384
385 SALOMEDS::TMPFile*  SALOMEDS_AttributeTableOfReal_i::SaveToFile()
386 {
387   SALOMEDS::Locker lock; 
388   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_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_AttributeTableOfReal_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(ATR_IncorrectIndex);
408   CheckLocked();
409   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_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_AttributeTableOfReal_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(ATR_IncorrectIndex);
435   CheckLocked();
436   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_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_AttributeTableOfReal_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(ATR_IncorrectIndex);
462   CheckLocked();
463   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_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_AttributeTableOfReal_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(ATR_IncorrectIndex);
489   CheckLocked();
490   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_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_AttributeTableOfReal_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(ATR_IncorrectIndex);
515   CheckLocked();
516   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_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_AttributeTableOfReal_i::SwapRows(CORBA::Long theRow1, CORBA::Long theRow2)
531   throw (SALOMEDS::AttributeTable::IncorrectIndex)
532 {
533   SALOMEDS::Locker lock;
534   Unexpect aCatch(ATR_IncorrectIndex);
535   CheckLocked();
536   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_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_AttributeTableOfReal_i::SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2)
549   throw (SALOMEDS::AttributeTable::IncorrectIndex)
550 {
551   SALOMEDS::Locker lock;
552   Unexpect aCatch(ATR_IncorrectIndex);
553   CheckLocked();
554   SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_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 }