1 // Copyright (C) 2007-2020 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_AttributeTableOfString.cxx
24 // Author : Sergey RUIN
27 #include "SALOMEDS_AttributeTableOfString.hxx"
28 #include "SALOMEDS.hxx"
32 SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString
33 (SALOMEDSImpl_AttributeTableOfString* theAttr)
34 :SALOMEDS_GenericAttribute(theAttr)
37 SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString
38 (SALOMEDS::AttributeTableOfString_ptr theAttr)
39 :SALOMEDS_GenericAttribute(theAttr)
42 SALOMEDS_AttributeTableOfString::~SALOMEDS_AttributeTableOfString()
46 void SALOMEDS_AttributeTableOfString::SetTitle(const std::string& theTitle)
50 SALOMEDS::Locker lock;
51 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetTitle(theTitle);
53 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
56 std::string SALOMEDS_AttributeTableOfString::GetTitle()
60 SALOMEDS::Locker lock;
61 aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetTitle();
63 else aStr = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetTitle();
67 void SALOMEDS_AttributeTableOfString::SetRowTitle(int theIndex, const std::string& theTitle)
71 SALOMEDS::Locker lock;
72 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowTitle(theIndex, theTitle);
74 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
77 std::string SALOMEDS_AttributeTableOfString::GetRowTitle(int theIndex)
81 SALOMEDS::Locker lock;
83 aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowTitle(theIndex);
86 throw SALOMEDS::AttributeTable::IncorrectIndex();
90 aTitle = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowTitle(theIndex);
95 void SALOMEDS_AttributeTableOfString::SetRowTitles(const std::vector<std::string>& theTitles)
97 int aLength = theTitles.size(), i;
100 SALOMEDS::Locker lock;
101 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowTitles(theTitles);
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::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitles(aSeq);
111 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowTitles()
113 std::vector<std::string> aVector;
116 SALOMEDS::Locker lock;
117 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowTitles();
120 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowTitles();
121 aLength = aSeq->length();
122 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
127 void SALOMEDS_AttributeTableOfString::SetColumnTitle(int theIndex, const std::string& theTitle)
131 SALOMEDS::Locker lock;
132 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
134 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
137 std::string SALOMEDS_AttributeTableOfString::GetColumnTitle(int theIndex)
141 SALOMEDS::Locker lock;
143 aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetColumnTitle(theIndex);
146 throw SALOMEDS::AttributeTable::IncorrectIndex();
150 aTitle = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumnTitle(theIndex);
155 void SALOMEDS_AttributeTableOfString::SetColumnTitles(const std::vector<std::string>& theTitles)
157 int aLength = theTitles.size(), i;
160 SALOMEDS::Locker lock;
161 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetColumnTitles(theTitles);
164 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
165 aSeq->length(aLength);
166 for (i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
167 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitles(aSeq);
171 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumnTitles()
173 std::vector<std::string> aVector;
176 SALOMEDS::Locker lock;
177 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetColumnTitles();
180 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumnTitles();
181 aLength = aSeq->length();
182 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
187 void SALOMEDS_AttributeTableOfString::SetRowUnit(int theIndex, const std::string& theUnit)
191 SALOMEDS::Locker lock;
192 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowUnit(theIndex, theUnit);
194 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
197 std::string SALOMEDS_AttributeTableOfString::GetRowUnit(int theIndex)
201 SALOMEDS::Locker lock;
203 aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowUnit(theIndex);
206 throw SALOMEDS::AttributeTable::IncorrectIndex();
210 aTitle = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowUnit(theIndex);
215 void SALOMEDS_AttributeTableOfString::SetRowUnits(const std::vector<std::string>& theUnits)
217 int aLength = theUnits.size(), i;
220 SALOMEDS::Locker lock;
221 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowUnits(theUnits);
224 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
225 aSeq->length(aLength);
226 for (i = 0; i < aLength; i++) aSeq[i] = theUnits[i].c_str();
227 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnits(aSeq);
231 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowUnits()
233 std::vector<std::string> aVector;
236 SALOMEDS::Locker lock;
237 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowUnits();
240 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowUnits();
241 aLength = aSeq->length();
242 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
247 int SALOMEDS_AttributeTableOfString::GetNbRows()
251 SALOMEDS::Locker lock;
252 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetNbRows();
254 else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbRows();
258 int SALOMEDS_AttributeTableOfString::GetNbColumns()
262 SALOMEDS::Locker lock;
263 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetNbColumns();
265 else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbColumns();
269 void SALOMEDS_AttributeTableOfString::AddRow(const std::vector<std::string>& theData)
271 int aLength = theData.size(), i;
274 SALOMEDS::Locker lock;
275 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
277 aTable->SetRowData(aTable->GetNbRows() + 1, theData);
280 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
284 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
285 aSeq->length(aLength);
286 for (i = 0; i < aLength; i++) aSeq[i] = theData[i].c_str();
287 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddRow(aSeq);
291 void SALOMEDS_AttributeTableOfString::SetRow(int theRow, const std::vector<std::string>& theData)
293 int aLength = theData.size(), i;
296 SALOMEDS::Locker lock;
297 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
299 aTable->SetRowData(theRow, theData);
302 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
306 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
307 aSeq->length(aLength);
308 for (i = 0; i < aLength; i++) aSeq[i] = theData[i].c_str();
309 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theRow, aSeq);
313 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRow(int theRow)
315 std::vector<std::string> aVector;
318 SALOMEDS::Locker lock;
319 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowData(theRow);
322 SALOMEDS::StringSeq_var aRow = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRow(theRow);
323 aLength = aRow->length();
324 for (i = 0; i < aLength; i++) aVector.push_back((char*)aRow[i].in());
330 void SALOMEDS_AttributeTableOfString::AddColumn(const std::vector<std::string>& theData)
332 int aLength = theData.size(), i;
335 SALOMEDS::Locker lock;
336 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
338 aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
341 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
345 SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
346 aColumn->length(aLength);
347 for (i = 0; i < aLength; i++) aColumn[i] = theData[i].c_str();
348 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddColumn(aColumn);
352 void SALOMEDS_AttributeTableOfString::SetColumn(int theColumn, const std::vector<std::string>& theData)
354 int aLength = theData.size(), i;
357 SALOMEDS::Locker lock;
358 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
360 aTable->SetColumnData(theColumn, theData);
363 throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
367 SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
368 aColumn->length(aLength);
369 for (i = 0; i < aLength; i++) aColumn[i] = theData[i].c_str();
370 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
374 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumn(int theColumn)
376 std::vector<std::string> aVector;
379 SALOMEDS::Locker lock;
380 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetColumnData(theColumn);
383 SALOMEDS::StringSeq_var aColumn =
384 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumn(theColumn);
385 aLength = aColumn->length();
386 for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i].in());
391 void SALOMEDS_AttributeTableOfString::PutValue(const std::string& theValue, int theRow, int theColumn)
395 SALOMEDS::Locker lock;
397 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->PutValue(theValue, theRow, theColumn);
400 throw SALOMEDS::AttributeTable::IncorrectIndex();
404 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->PutValue(theValue.c_str(), theRow, theColumn);
408 bool SALOMEDS_AttributeTableOfString::HasValue(int theRow, int theColumn)
412 SALOMEDS::Locker lock;
413 ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->HasValue(theRow, theColumn);
415 else ret = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->HasValue(theRow, theColumn);
419 std::string SALOMEDS_AttributeTableOfString::GetValue(int theRow, int theColumn)
423 SALOMEDS::Locker lock;
425 aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetValue(theRow, theColumn);
428 throw SALOMEDS::AttributeTable::IncorrectIndex();
432 aValue = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetValue(theRow, theColumn);
437 void SALOMEDS_AttributeTableOfString::RemoveValue(int theRow, int theColumn)
440 SALOMEDS::Locker lock;
442 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->RemoveValue(theRow, theColumn);
445 throw SALOMEDS::AttributeTable::IncorrectIndex();
449 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->RemoveValue(theRow, theColumn);
453 std::vector<int> SALOMEDS_AttributeTableOfString::GetRowSetIndices(int theRow)
455 std::vector<int> aVector;
458 SALOMEDS::Locker lock;
459 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetSetRowIndices(theRow);
462 SALOMEDS::LongSeq_var aSet =
463 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowSetIndices(theRow);
464 aLength = aSet->length();
465 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
470 void SALOMEDS_AttributeTableOfString::SetNbColumns(int theNbColumns)
473 SALOMEDS::Locker lock;
474 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetNbColumns(theNbColumns);
476 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
479 std::vector<int> SALOMEDS_AttributeTableOfString::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
481 std::vector<int> aVector;
484 SALOMEDS::Locker lock;
486 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortRow(theRow,
487 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
488 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
491 throw SALOMEDS::AttributeTable::IncorrectIndex();
495 SALOMEDS::LongSeq_var aSet =
496 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortRow(theRow,
497 (SALOMEDS::AttributeTable::SortOrder)theOrder,
498 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
499 aLength = aSet->length();
500 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
505 std::vector<int> SALOMEDS_AttributeTableOfString::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
507 std::vector<int> aVector;
510 SALOMEDS::Locker lock;
512 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortColumn(theColumn,
513 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
514 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
517 throw SALOMEDS::AttributeTable::IncorrectIndex();
521 SALOMEDS::LongSeq_var aSet =
522 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortColumn(theColumn,
523 (SALOMEDS::AttributeTable::SortOrder)theOrder,
524 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
525 aLength = aSet->length();
526 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
531 std::vector<int> SALOMEDS_AttributeTableOfString::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
533 std::vector<int> aVector;
536 SALOMEDS::Locker lock;
538 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortByRow(theRow,
539 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
540 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
543 throw SALOMEDS::AttributeTable::IncorrectIndex();
547 SALOMEDS::LongSeq_var aSet =
548 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByRow(theRow,
549 (SALOMEDS::AttributeTable::SortOrder)theOrder,
550 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
551 aLength = aSet->length();
552 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
557 std::vector<int> SALOMEDS_AttributeTableOfString::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
559 std::vector<int> aVector;
562 SALOMEDS::Locker lock;
564 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortByColumn(theColumn,
565 (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
566 (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
569 throw SALOMEDS::AttributeTable::IncorrectIndex();
573 SALOMEDS::LongSeq_var aSet =
574 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByColumn(theColumn,
575 (SALOMEDS::AttributeTable::SortOrder)theOrder,
576 (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
577 aLength = aSet->length();
578 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
583 void SALOMEDS_AttributeTableOfString::SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2)
586 SALOMEDS::Locker lock;
588 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
591 throw SALOMEDS::AttributeTable::IncorrectIndex();
595 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
599 void SALOMEDS_AttributeTableOfString::SwapRows(int theRow1, int theRow2)
602 SALOMEDS::Locker lock;
604 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SwapRows(theRow1, theRow2);
607 throw SALOMEDS::AttributeTable::IncorrectIndex();
611 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SwapRows(theRow1, theRow2);
615 void SALOMEDS_AttributeTableOfString::SwapColumns(int theColumn1, int theColumn2)
618 SALOMEDS::Locker lock;
620 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SwapColumns(theColumn1, theColumn2);
623 throw SALOMEDS::AttributeTable::IncorrectIndex();
627 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SwapColumns(theColumn1, theColumn2);