1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, 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_AttributeTableOfInteger.cxx
24 // Author : Sergey RUIN
27 #include "SALOMEDS_AttributeTableOfInteger.hxx"
28 #include "SALOMEDS.hxx"
30 SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger
31 (SALOMEDSImpl_AttributeTableOfInteger* theAttr)
32 :SALOMEDS_GenericAttribute(theAttr)
35 SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger
36 (SALOMEDS::AttributeTableOfInteger_ptr theAttr)
37 :SALOMEDS_GenericAttribute(theAttr)
40 SALOMEDS_AttributeTableOfInteger::~SALOMEDS_AttributeTableOfInteger()
44 void SALOMEDS_AttributeTableOfInteger::SetTitle(const std::string& theTitle)
48 SALOMEDS::Locker lock;
49 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetTitle(theTitle);
51 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
54 std::string SALOMEDS_AttributeTableOfInteger::GetTitle()
58 SALOMEDS::Locker lock;
59 aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetTitle();
61 else aStr = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetTitle();
65 void SALOMEDS_AttributeTableOfInteger::SetRowTitle(int theIndex, const std::string& theTitle)
69 SALOMEDS::Locker lock;
70 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowTitle(theIndex, theTitle);
72 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
75 std::string SALOMEDS_AttributeTableOfInteger::GetRowTitle(int theIndex)
79 SALOMEDS::Locker lock;
81 aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowTitle(theIndex);
84 throw SALOMEDS::AttributeTable::IncorrectIndex();
88 aTitle = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowTitle(theIndex);
93 void SALOMEDS_AttributeTableOfInteger::SetRowTitles(const std::vector<std::string>& theTitles)
95 int aLength = theTitles.size(), i;
98 SALOMEDS::Locker lock;
99 std::vector<std::string> aSeq;
100 for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
101 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowTitles(aSeq);
104 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
105 aSeq->length(aLength);
106 for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
107 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitles(aSeq);
112 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowTitles()
114 std::vector<std::string> aVector;
117 SALOMEDS::Locker lock;
118 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowTitles();
121 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowTitles();
122 aLength = aSeq->length();
123 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
128 void SALOMEDS_AttributeTableOfInteger::SetColumnTitle(int theIndex, const std::string& theTitle)
132 SALOMEDS::Locker lock;
133 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
135 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
138 std::string SALOMEDS_AttributeTableOfInteger::GetColumnTitle(int theIndex)
142 SALOMEDS::Locker lock;
144 aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetColumnTitle(theIndex);
147 throw SALOMEDS::AttributeTable::IncorrectIndex();
151 aTitle = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitle(theIndex);
156 void SALOMEDS_AttributeTableOfInteger::SetColumnTitles(const std::vector<std::string>& theTitles)
158 int aLength = theTitles.size(), i;
161 SALOMEDS::Locker lock;
162 std::vector<std::string> aSeq;
163 for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
164 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetColumnTitles(aSeq);
167 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
168 aSeq->length(aLength);
169 for (i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
170 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitles(aSeq);
174 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetColumnTitles()
176 std::vector<std::string> aVector;
179 SALOMEDS::Locker lock;
180 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetColumnTitles();
183 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitles();
184 aLength = aSeq->length();
185 for (i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
190 void SALOMEDS_AttributeTableOfInteger::SetRowUnit(int theIndex, const std::string& theUnit)
194 SALOMEDS::Locker lock;
195 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowUnit(theIndex, theUnit);
197 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
200 std::string SALOMEDS_AttributeTableOfInteger::GetRowUnit(int theIndex)
204 SALOMEDS::Locker lock;
206 aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowUnit(theIndex);
209 throw SALOMEDS::AttributeTable::IncorrectIndex();
213 aTitle = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowUnit(theIndex);
218 void SALOMEDS_AttributeTableOfInteger::SetRowUnits(const std::vector<std::string>& theUnits)
220 int aLength = theUnits.size(), i;
223 SALOMEDS::Locker lock;
224 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowUnits(theUnits);
227 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
228 aSeq->length(aLength);
229 for (i = 0; i < aLength; i++) aSeq[i] = theUnits[i].c_str();
230 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnits(aSeq);
234 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowUnits()
236 std::vector<std::string> aVector;
239 SALOMEDS::Locker lock;
240 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowUnits();
243 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowUnits();
244 aLength = aSeq->length();
245 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
250 int SALOMEDS_AttributeTableOfInteger::GetNbRows()
254 SALOMEDS::Locker lock;
255 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetNbRows();
257 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbRows();
261 int SALOMEDS_AttributeTableOfInteger::GetNbColumns()
265 SALOMEDS::Locker lock;
266 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetNbColumns();
268 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbColumns();
273 void SALOMEDS_AttributeTableOfInteger::AddRow(const std::vector<int>& theData)
275 int aLength = theData.size(), i;
278 SALOMEDS::Locker lock;
279 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
281 aTable->SetRowData(aTable->GetNbRows() + 1, theData);
284 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
288 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
289 aSeq->length(aLength);
290 for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
291 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddRow(aSeq);
295 void SALOMEDS_AttributeTableOfInteger::SetRow(int theRow, const std::vector<int>& theData)
297 int aLength = theData.size(), i;
300 SALOMEDS::Locker lock;
301 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
303 aTable->SetRowData(theRow, theData);
306 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
310 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
311 aSeq->length(aLength);
312 for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
313 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theRow, aSeq);
317 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRow(int theRow)
319 std::vector<int> aVector;
322 SALOMEDS::Locker lock;
323 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowData(theRow);
326 SALOMEDS::LongSeq_var aRow = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRow(theRow);
327 aLength = aRow->length();
328 for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
334 void SALOMEDS_AttributeTableOfInteger::AddColumn(const std::vector<int>& theData)
336 int aLength = theData.size(), i;
339 SALOMEDS::Locker lock;
340 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
342 aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
345 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
349 SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
350 aColumn->length(aLength);
351 for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
352 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddColumn(aColumn);
356 void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vector<int>& theData)
358 int aLength = theData.size(), i;
361 SALOMEDS::Locker lock;
362 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
364 aTable->SetColumnData(theColumn, theData);
367 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
371 SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
372 aColumn->length(aLength);
373 for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
374 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
378 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetColumn(int theColumn)
380 std::vector<int> aVector;
383 SALOMEDS::Locker lock;
384 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetColumnData(theColumn);
387 SALOMEDS::LongSeq_var aColumn = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumn(theColumn);
388 aLength = aColumn->length();
389 for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
394 void SALOMEDS_AttributeTableOfInteger::PutValue(int theValue, int theRow, int theColumn)
398 SALOMEDS::Locker lock;
400 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->PutValue(theValue, theRow, theColumn);
403 throw SALOMEDS::AttributeTable::IncorrectIndex();
407 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
411 bool SALOMEDS_AttributeTableOfInteger::HasValue(int theRow, int theColumn)
415 SALOMEDS::Locker lock;
416 ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->HasValue(theRow, theColumn);
418 else ret = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->HasValue(theRow, theColumn);
422 int SALOMEDS_AttributeTableOfInteger::GetValue(int theRow, int theColumn)
426 SALOMEDS::Locker lock;
428 aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetValue(theRow, theColumn);
431 throw SALOMEDS::AttributeTable::IncorrectIndex();
435 aValue = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetValue(theRow, theColumn);
440 void SALOMEDS_AttributeTableOfInteger::RemoveValue(int theRow, int theColumn)
443 SALOMEDS::Locker lock;
445 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->RemoveValue(theRow, theColumn);
448 throw SALOMEDS::AttributeTable::IncorrectIndex();
452 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->RemoveValue(theRow, theColumn);
456 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow)
458 std::vector<int> aVector;
461 SALOMEDS::Locker lock;
462 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetSetRowIndices(theRow);
465 SALOMEDS::LongSeq_var aSet =
466 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow);
467 aLength = aSet->length();
468 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
473 void SALOMEDS_AttributeTableOfInteger::SetNbColumns(int theNbColumns)
476 SALOMEDS::Locker lock;
477 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetNbColumns(theNbColumns);
479 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
482 std::vector<int> SALOMEDS_AttributeTableOfInteger::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
484 std::vector<int> aVector;
487 SALOMEDS::Locker lock;
489 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortRow(theRow,
490 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
491 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
494 throw SALOMEDS::AttributeTable::IncorrectIndex();
498 SALOMEDS::LongSeq_var aSet =
499 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortRow(theRow,
500 (SALOMEDS::AttributeTable::SortOrder)theOrder,
501 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
502 aLength = aSet->length();
503 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
508 std::vector<int> SALOMEDS_AttributeTableOfInteger::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
510 std::vector<int> aVector;
513 SALOMEDS::Locker lock;
515 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortColumn(theColumn,
516 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
517 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
520 throw SALOMEDS::AttributeTable::IncorrectIndex();
524 SALOMEDS::LongSeq_var aSet =
525 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortColumn(theColumn,
526 (SALOMEDS::AttributeTable::SortOrder)theOrder,
527 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
528 aLength = aSet->length();
529 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
534 std::vector<int> SALOMEDS_AttributeTableOfInteger::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
536 std::vector<int> aVector;
539 SALOMEDS::Locker lock;
541 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortByRow(theRow,
542 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
543 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
546 throw SALOMEDS::AttributeTable::IncorrectIndex();
550 SALOMEDS::LongSeq_var aSet =
551 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByRow(theRow,
552 (SALOMEDS::AttributeTable::SortOrder)theOrder,
553 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
554 aLength = aSet->length();
555 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
560 std::vector<int> SALOMEDS_AttributeTableOfInteger::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
562 std::vector<int> aVector;
565 SALOMEDS::Locker lock;
567 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortByColumn(theColumn,
568 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
569 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
572 throw SALOMEDS::AttributeTable::IncorrectIndex();
576 SALOMEDS::LongSeq_var aSet =
577 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByColumn(theColumn,
578 (SALOMEDS::AttributeTable::SortOrder)theOrder,
579 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
580 aLength = aSet->length();
581 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
586 void SALOMEDS_AttributeTableOfInteger::SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2)
589 SALOMEDS::Locker lock;
591 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
594 throw SALOMEDS::AttributeTable::IncorrectIndex();
598 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
602 void SALOMEDS_AttributeTableOfInteger::SwapRows(int theRow1, int theRow2)
605 SALOMEDS::Locker lock;
607 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SwapRows(theRow1, theRow2);
610 throw SALOMEDS::AttributeTable::IncorrectIndex();
614 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SwapRows(theRow1, theRow2);
618 void SALOMEDS_AttributeTableOfInteger::SwapColumns(int theColumn1, int theColumn2)
621 SALOMEDS::Locker lock;
623 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SwapColumns(theColumn1, theColumn2);
626 throw SALOMEDS::AttributeTable::IncorrectIndex();
630 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SwapColumns(theColumn1, theColumn2);