1 // Copyright (C) 2007-2008 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.
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
22 // File : SALOMEDS_AttributeTableOfReal.cxx
23 // Author : Sergey RUIN
26 #include "SALOMEDS_AttributeTableOfReal.hxx"
27 #include "SALOMEDS.hxx"
31 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal
32 (SALOMEDSImpl_AttributeTableOfReal* theAttr)
33 :SALOMEDS_GenericAttribute(theAttr)
36 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal(SALOMEDS::AttributeTableOfReal_ptr theAttr)
37 :SALOMEDS_GenericAttribute(theAttr)
40 SALOMEDS_AttributeTableOfReal::~SALOMEDS_AttributeTableOfReal()
44 void SALOMEDS_AttributeTableOfReal::SetTitle(const std::string& theTitle)
48 SALOMEDS::Locker lock;
49 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetTitle(theTitle);
51 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
54 std::string SALOMEDS_AttributeTableOfReal::GetTitle()
58 SALOMEDS::Locker lock;
59 aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetTitle();
61 else aStr = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetTitle();
65 void SALOMEDS_AttributeTableOfReal::SetRowTitle(int theIndex, const std::string& theTitle)
69 SALOMEDS::Locker lock;
70 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitle(theIndex, theTitle);
72 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
75 void SALOMEDS_AttributeTableOfReal::SetRowTitles(const std::vector<std::string>& theTitles)
78 int aLength = theTitles.size(), i;
81 SALOMEDS::Locker lock;
82 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitles(theTitles);
85 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
86 aSeq->length(aLength);
87 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
88 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitles(aSeq);
92 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowTitles()
94 std::vector<std::string> aVector;
97 SALOMEDS::Locker lock;
98 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowTitles();
101 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitles();
102 aLength = aSeq->length();
103 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
108 void SALOMEDS_AttributeTableOfReal::SetColumnTitle(int theIndex, const std::string& theTitle)
112 SALOMEDS::Locker lock;
113 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
115 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
118 void SALOMEDS_AttributeTableOfReal::SetColumnTitles(const std::vector<std::string>& theTitles)
120 int aLength = theTitles.size(), i;
123 SALOMEDS::Locker lock;
124 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitles(theTitles);
127 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
128 aSeq->length(aLength);
129 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
130 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitles(aSeq);
134 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetColumnTitles()
136 std::vector<std::string> aVector;
139 SALOMEDS::Locker lock;
140 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnTitles();
143 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitles();
144 aLength = aSeq->length();
145 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
150 void SALOMEDS_AttributeTableOfReal::SetRowUnit(int theIndex, const std::string& theUnit)
154 SALOMEDS::Locker lock;
155 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnit(theIndex, theUnit);
157 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
160 void SALOMEDS_AttributeTableOfReal::SetRowUnits(const std::vector<std::string>& theUnits)
162 int aLength = theUnits.size(), i;
165 SALOMEDS::Locker lock;
166 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnits(theUnits);
169 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
170 aSeq->length(aLength);
171 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
172 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnits(aSeq);
176 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowUnits()
178 std::vector<std::string> aVector;
181 SALOMEDS::Locker lock;
182 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowUnits();
185 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnits();
186 aLength = aSeq->length();
187 for (i = 0; i < aLength; i++) aVector.push_back(string(aSeq[i].in()));
192 int SALOMEDS_AttributeTableOfReal::GetNbRows()
196 SALOMEDS::Locker lock;
197 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbRows();
199 else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbRows();
203 int SALOMEDS_AttributeTableOfReal::GetNbColumns()
207 SALOMEDS::Locker lock;
208 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbColumns();
210 else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbColumns();
214 void SALOMEDS_AttributeTableOfReal::AddRow(const std::vector<double>& theData)
216 int aLength = theData.size(), i;
219 SALOMEDS::Locker lock;
220 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
222 aTable->SetRowData(aTable->GetNbRows() + 1, theData);
225 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
229 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
230 aSeq->length(aLength);
231 for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
232 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddRow(aSeq);
236 void SALOMEDS_AttributeTableOfReal::SetRow(int theRow, const std::vector<double>& theData)
238 int aLength = theData.size(), i;
241 SALOMEDS::Locker lock;
242 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
244 aTable->SetRowData(theRow, theData);
247 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
251 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
252 aSeq->length(aLength);
253 for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
254 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theRow, aSeq);
258 std::vector<double> SALOMEDS_AttributeTableOfReal::GetRow(int theRow)
260 std::vector<double> aVector;
263 SALOMEDS::Locker lock;
264 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowData(theRow);
267 SALOMEDS::DoubleSeq_var aRow = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRow(theRow);
268 aLength = aRow->length();
269 for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
275 void SALOMEDS_AttributeTableOfReal::AddColumn(const std::vector<double>& theData)
277 int aLength = theData.size(), i;
280 SALOMEDS::Locker lock;
281 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
283 aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
286 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
290 SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
291 aColumn->length(aLength);
292 for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
293 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddColumn(aColumn);
297 void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vector<double>& theData)
299 int aLength = theData.size(), i;
302 SALOMEDS::Locker lock;
303 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
305 aTable->SetColumnData(theColumn, theData);
308 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
312 SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
313 aColumn->length(aLength);
314 for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
315 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
319 std::vector<double> SALOMEDS_AttributeTableOfReal::GetColumn(int theColumn)
321 std::vector<double> aVector;
324 SALOMEDS::Locker lock;
325 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnData(theColumn);
328 SALOMEDS::DoubleSeq_var aColumn = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumn(theColumn);
329 aLength = aColumn->length();
330 for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
335 void SALOMEDS_AttributeTableOfReal::PutValue(double theValue, int theRow, int theColumn)
339 SALOMEDS::Locker lock;
341 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->PutValue(theValue, theRow, theColumn);
344 throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
348 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
352 bool SALOMEDS_AttributeTableOfReal::HasValue(int theRow, int theColumn)
356 SALOMEDS::Locker lock;
357 ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->HasValue(theRow, theColumn);
359 else ret = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->HasValue(theRow, theColumn);
363 double SALOMEDS_AttributeTableOfReal::GetValue(int theRow, int theColumn)
367 SALOMEDS::Locker lock;
369 aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetValue(theRow, theColumn);
372 throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
376 aValue = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetValue(theRow, theColumn);
381 std::vector<int> SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow)
383 std::vector<int> aVector;
386 SALOMEDS::Locker lock;
387 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetSetRowIndices(theRow);
390 SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowSetIndices(theRow);
391 aLength = aSet->length();
392 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
397 void SALOMEDS_AttributeTableOfReal::SetNbColumns(int theNbColumns)
400 SALOMEDS::Locker lock;
401 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetNbColumns(theNbColumns);
403 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns);