1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_AttributeTableOfReal_i.cxx
24 // Author : Sergey RUIN
27 #include "SALOMEDS_AttributeTableOfReal_i.hxx"
28 #include "SALOMEDS.hxx"
34 #include "Utils_ExceptHandlers.hxx"
35 UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex)
36 UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength)
38 void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle)
40 SALOMEDS::Locker lock;
42 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
43 CORBA::String_var aStr = CORBA::string_dup(theTitle);
44 aTable->SetTitle(std::string(aStr));
47 char* SALOMEDS_AttributeTableOfReal_i::GetTitle()
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());
55 void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
57 SALOMEDS::Locker lock;
58 Unexpect aCatch (ATR_IncorrectIndex);
60 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
61 if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
62 aTable->SetRowTitle(theIndex, std::string(theTitle));
65 char* SALOMEDS_AttributeTableOfReal_i::GetRowTitle(CORBA::Long theIndex)
67 SALOMEDS::Locker lock;
68 Unexpect aCatch (ATR_IncorrectIndex);
70 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
71 if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
72 CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowTitle(theIndex).c_str());
76 void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
78 SALOMEDS::Locker lock;
79 Unexpect aCatch (ATR_IncorrectArgumentLength);
81 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
82 if ((int)theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
83 for (int i = 0; i < (int)theTitles.length(); i++) {
84 aTable->SetRowTitle(i + 1, (char*)theTitles[i].in());
88 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles()
90 SALOMEDS::Locker lock;
91 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
92 SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
93 aTitles->length(aTable->GetNbRows());
94 for(int i = 0; i < (int)aTitles->length(); i++)
95 aTitles[i] = CORBA::string_dup(aTable->GetRowTitle(i + 1).c_str());
96 return aTitles._retn();
99 void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
101 SALOMEDS::Locker lock;
102 Unexpect aCatch (ATR_IncorrectIndex);
104 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
105 if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
106 CORBA::String_var aStr = CORBA::string_dup(theTitle);
107 aTable->SetColumnTitle(theIndex, std::string(aStr));
110 char* SALOMEDS_AttributeTableOfReal_i::GetColumnTitle(CORBA::Long theIndex)
112 SALOMEDS::Locker lock;
113 Unexpect aCatch (ATR_IncorrectIndex);
115 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
116 if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
117 CORBA::String_var c_s = CORBA::string_dup(aTable->GetColumnTitle(theIndex).c_str());
121 void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
123 SALOMEDS::Locker lock;
124 Unexpect aCatch(ATR_IncorrectArgumentLength);
126 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
127 if ((int)theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
128 for (int i = 0; i < (int)theTitles.length(); i++) {
129 aTable->SetColumnTitle(i + 1, (char*)theTitles[i].in());
133 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles()
135 SALOMEDS::Locker lock;
136 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
137 SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
138 aTitles->length(aTable->GetNbColumns());
139 for(int i = 0; i < (int)aTitles->length(); i++)
140 aTitles[i] = CORBA::string_dup(aTable->GetColumnTitle(i + 1).c_str());
141 return aTitles._retn();
145 void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
147 SALOMEDS::Locker lock;
148 Unexpect aCatch (ATR_IncorrectIndex);
150 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
151 if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
152 aTable->SetRowUnit(theIndex, std::string(theUnit));
155 char* SALOMEDS_AttributeTableOfReal_i::GetRowUnit(CORBA::Long theIndex)
157 SALOMEDS::Locker lock;
158 Unexpect aCatch (ATR_IncorrectIndex);
160 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
161 if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
162 CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowUnit(theIndex).c_str());
166 void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
168 SALOMEDS::Locker lock;
169 Unexpect aCatch (ATR_IncorrectArgumentLength);
171 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
172 if ((int)theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
173 for (int i = 0; i < (int)theUnits.length(); i++) {
174 aTable->SetRowUnit(i + 1, (char*)theUnits[i].in());
178 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowUnits()
180 SALOMEDS::Locker lock;
181 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
182 SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq;
183 aUnits->length(aTable->GetNbRows());
184 for(int i = 0; i < (int)aUnits->length(); i++)
185 aUnits[i] = CORBA::string_dup(aTable->GetRowUnit(i + 1).c_str());
186 return aUnits._retn();
190 CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbRows()
192 SALOMEDS::Locker lock;
193 return dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl)->GetNbRows();
196 CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns()
198 SALOMEDS::Locker lock;
199 return dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl)->GetNbColumns();
202 void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData)
204 SALOMEDS::Locker lock;
205 Unexpect aCatch(ATR_IncorrectArgumentLength);
207 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
209 std::vector<double> aRow;
210 for (size_t i = 0; i < theData.length(); i++) aRow.push_back(theData[(CORBA::ULong)i]); //!< TODO: conversion from size_t to CORBA::ULong
211 aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
214 void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData)
216 SALOMEDS::Locker lock;
217 Unexpect aCatch(ATR_IncorrectArgumentLength);
219 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
221 std::vector<double> aRow;
222 for (size_t i = 0; i < theData.length(); i++) aRow.push_back(theData[(CORBA::ULong)i]); //!< TODO: conversion from size_t to CORBA::ULong
223 aTable->SetRowData(theRow, aRow);
226 SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow)
228 SALOMEDS::Locker lock;
229 Unexpect aCatch(ATR_IncorrectIndex);
230 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
231 if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
233 SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq;
234 std::vector<double> aRow = aTable->GetRowData(theRow);
235 CorbaSeq->length((CORBA::ULong)aRow.size()); //!< TODO: conversion from size_t to CORBA::ULong
236 for (int i = 0; i < (int)aRow.size(); i++) {
237 CorbaSeq[i] = aRow[i];
239 return CorbaSeq._retn();
242 void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData)
244 SALOMEDS::Locker lock;
245 Unexpect aCatch(ATR_IncorrectArgumentLength);
247 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
249 std::vector<double> aColumn;
250 for (size_t i = 0; i < theData.length(); i++) aColumn.push_back(theData[(CORBA::ULong)i]); //!< TODO: conversion from size_t to CORBA::ULong
251 aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
254 void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData)
256 SALOMEDS::Locker lock;
257 Unexpect aCatch(ATR_IncorrectArgumentLength);
259 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
261 std::vector<double> aColumn;
262 for (size_t i = 0; i < theData.length(); i++) aColumn.push_back(theData[(CORBA::ULong)i]); //!< TODO: conversion from size_t to CORBA::ULong
263 aTable->SetColumnData(theColumn, aColumn);
266 SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn)
268 SALOMEDS::Locker lock;
269 Unexpect aCatch(ATR_IncorrectIndex);
270 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
271 if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
273 SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq;
274 std::vector<double> aColumn = aTable->GetColumnData(theColumn);
275 CorbaSeq->length((CORBA::ULong)aColumn.size()); //!< TODO: conversion from size_t to CORBA::ULong
276 for (int i = 0; i < (int)aColumn.size(); i++) {
277 CorbaSeq[i] = aColumn[i];
279 return CorbaSeq._retn();
282 void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn)
284 SALOMEDS::Locker lock;
285 Unexpect aCatch(ATR_IncorrectIndex);
287 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
289 aTable->PutValue(theValue, theRow, theColumn);
292 CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn)
294 SALOMEDS::Locker lock;
295 return dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl)->HasValue(theRow, theColumn);
298 CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
300 SALOMEDS::Locker lock;
301 Unexpect aCatch(ATR_IncorrectIndex);
302 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
303 if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
305 CORBA::Double aValue;
308 aValue = aTable->GetValue(theRow, theColumn);
311 throw SALOMEDS::AttributeTable::IncorrectIndex();
317 void SALOMEDS_AttributeTableOfReal_i::RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
319 SALOMEDS::Locker lock;
320 Unexpect aCatch(ATR_IncorrectIndex);
321 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
322 if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
323 if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
326 aTable->RemoveValue(theRow, theColumn);
329 throw SALOMEDS::AttributeTable::IncorrectIndex();
333 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::GetRowSetIndices(CORBA::Long theRow)
335 SALOMEDS::Locker lock;
336 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
338 if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
340 SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
341 std::vector<int> aSeq = aTable->GetSetRowIndices(theRow);
342 int len = (int)aSeq.size(); //!< TODO: conversion from size_t to int
343 CorbaSeq->length(len);
344 for (int i = 0; i < len; i++) {
345 CorbaSeq[i] = aSeq[i];
347 return CorbaSeq._retn();
350 void SALOMEDS_AttributeTableOfReal_i::SetNbColumns(CORBA::Long theNbColumns)
352 SALOMEDS::Locker lock;
353 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
354 aTable->SetNbColumns(theNbColumns);
357 bool SALOMEDS_AttributeTableOfReal_i::ReadFromFile(const SALOMEDS::TMPFile& theStream)
359 SALOMEDS::Locker lock;
360 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
362 std::string aStream((char*)&theStream[0], theStream.length());
363 aTable->Load(aStream);
367 SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile()
369 SALOMEDS::Locker lock;
370 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
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
376 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
378 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
380 return aStreamFile._retn();
383 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortRow(CORBA::Long theRow,
384 SALOMEDS::AttributeTable::SortOrder sortOrder,
385 SALOMEDS::AttributeTable::SortPolicy sortPolicy)
387 SALOMEDS::Locker lock;
388 Unexpect aCatch(ATR_IncorrectIndex);
390 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
391 if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
393 std::vector<int> aSeq;
394 SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
396 aSeq = aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
397 (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
400 throw SALOMEDS::AttributeTable::IncorrectIndex();
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];
406 return CorbaSeq._retn();
409 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortColumn(CORBA::Long theColumn,
410 SALOMEDS::AttributeTable::SortOrder sortOrder,
411 SALOMEDS::AttributeTable::SortPolicy sortPolicy)
413 SALOMEDS::Locker lock;
414 Unexpect aCatch(ATR_IncorrectIndex);
416 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
417 if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
419 std::vector<int> aSeq;
420 SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
422 aSeq = aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
423 (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
426 throw SALOMEDS::AttributeTable::IncorrectIndex();
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];
432 return CorbaSeq._retn();
435 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortByRow(CORBA::Long theRow,
436 SALOMEDS::AttributeTable::SortOrder sortOrder,
437 SALOMEDS::AttributeTable::SortPolicy sortPolicy)
439 SALOMEDS::Locker lock;
440 Unexpect aCatch(ATR_IncorrectIndex);
442 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
443 if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
445 std::vector<int> aSeq;
446 SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
448 aSeq = aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
449 (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
452 throw SALOMEDS::AttributeTable::IncorrectIndex();
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];
458 return CorbaSeq._retn();
461 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortByColumn(CORBA::Long theColumn,
462 SALOMEDS::AttributeTable::SortOrder sortOrder,
463 SALOMEDS::AttributeTable::SortPolicy sortPolicy)
465 SALOMEDS::Locker lock;
466 Unexpect aCatch(ATR_IncorrectIndex);
468 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
469 if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
471 std::vector<int> aSeq;
472 SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
474 aSeq = aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
475 (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
478 throw SALOMEDS::AttributeTable::IncorrectIndex();
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];
484 return CorbaSeq._retn();
487 void SALOMEDS_AttributeTableOfReal_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1,
488 CORBA::Long theRow2, CORBA::Long theColumn2)
490 SALOMEDS::Locker lock;
491 Unexpect aCatch(ATR_IncorrectIndex);
493 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
494 if (theRow1 < 1 || theRow1 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
495 if (theColumn1 < 1 || theColumn1 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
496 if (theRow2 < 1 || theRow2 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
497 if (theColumn2 < 1 || theColumn2 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
500 aTable->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
503 throw SALOMEDS::AttributeTable::IncorrectIndex();
507 void SALOMEDS_AttributeTableOfReal_i::SwapRows(CORBA::Long theRow1, CORBA::Long theRow2)
509 SALOMEDS::Locker lock;
510 Unexpect aCatch(ATR_IncorrectIndex);
512 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
513 if (theRow1 < 1 || theRow1 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
514 if (theRow2 < 1 || theRow2 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
517 aTable->SwapRows(theRow1, theRow2);
520 throw SALOMEDS::AttributeTable::IncorrectIndex();
524 void SALOMEDS_AttributeTableOfReal_i::SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2)
526 SALOMEDS::Locker lock;
527 Unexpect aCatch(ATR_IncorrectIndex);
529 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
530 if (theColumn1 < 1 || theColumn1 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
531 if (theColumn2 < 1 || theColumn2 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
534 aTable->SwapColumns(theColumn1, theColumn2);
537 throw SALOMEDS::AttributeTable::IncorrectIndex();