1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDS_AttributeTableOfReal.cxx
21 // Author : Sergey RUIN
24 #include "SALOMEDS_AttributeTableOfReal.hxx"
25 #include "SALOMEDS.hxx"
29 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal
30 (SALOMEDSImpl_AttributeTableOfReal* theAttr)
31 :SALOMEDS_GenericAttribute(theAttr)
34 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal(SALOMEDS::AttributeTableOfReal_ptr theAttr)
35 :SALOMEDS_GenericAttribute(theAttr)
38 SALOMEDS_AttributeTableOfReal::~SALOMEDS_AttributeTableOfReal()
42 void SALOMEDS_AttributeTableOfReal::SetTitle(const std::string& theTitle)
46 SALOMEDS::Locker lock;
47 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetTitle(theTitle);
49 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
52 std::string SALOMEDS_AttributeTableOfReal::GetTitle()
56 SALOMEDS::Locker lock;
57 aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetTitle();
59 else aStr = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetTitle();
63 void SALOMEDS_AttributeTableOfReal::SetRowTitle(int theIndex, const std::string& theTitle)
67 SALOMEDS::Locker lock;
68 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitle(theIndex, theTitle);
70 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
73 void SALOMEDS_AttributeTableOfReal::SetRowTitles(const std::vector<std::string>& theTitles)
76 int aLength = theTitles.size(), i;
79 SALOMEDS::Locker lock;
80 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitles(theTitles);
83 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
84 aSeq->length(aLength);
85 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
86 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitles(aSeq);
90 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowTitles()
92 std::vector<std::string> aVector;
95 SALOMEDS::Locker lock;
96 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowTitles();
99 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitles();
100 aLength = aSeq->length();
101 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
106 void SALOMEDS_AttributeTableOfReal::SetColumnTitle(int theIndex, const std::string& theTitle)
110 SALOMEDS::Locker lock;
111 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
113 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
116 void SALOMEDS_AttributeTableOfReal::SetColumnTitles(const std::vector<std::string>& theTitles)
118 int aLength = theTitles.size(), i;
121 SALOMEDS::Locker lock;
122 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitles(theTitles);
125 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
126 aSeq->length(aLength);
127 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
128 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitles(aSeq);
132 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetColumnTitles()
134 std::vector<std::string> aVector;
137 SALOMEDS::Locker lock;
138 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnTitles();
141 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitles();
142 aLength = aSeq->length();
143 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
148 void SALOMEDS_AttributeTableOfReal::SetRowUnit(int theIndex, const std::string& theUnit)
152 SALOMEDS::Locker lock;
153 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnit(theIndex, theUnit);
155 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
158 void SALOMEDS_AttributeTableOfReal::SetRowUnits(const std::vector<std::string>& theUnits)
160 int aLength = theUnits.size(), i;
163 SALOMEDS::Locker lock;
164 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnits(theUnits);
167 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
168 aSeq->length(aLength);
169 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
170 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnits(aSeq);
174 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowUnits()
176 std::vector<std::string> aVector;
179 SALOMEDS::Locker lock;
180 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowUnits();
183 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnits();
184 aLength = aSeq->length();
185 for (i = 0; i < aLength; i++) aVector.push_back(string(aSeq[i].in()));
190 int SALOMEDS_AttributeTableOfReal::GetNbRows()
194 SALOMEDS::Locker lock;
195 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbRows();
197 else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbRows();
201 int SALOMEDS_AttributeTableOfReal::GetNbColumns()
205 SALOMEDS::Locker lock;
206 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbColumns();
208 else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbColumns();
212 void SALOMEDS_AttributeTableOfReal::AddRow(const std::vector<double>& theData)
214 int aLength = theData.size(), i;
217 SALOMEDS::Locker lock;
218 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
220 aTable->SetRowData(aTable->GetNbRows() + 1, theData);
223 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
227 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
228 aSeq->length(aLength);
229 for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
230 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddRow(aSeq);
234 void SALOMEDS_AttributeTableOfReal::SetRow(int theRow, const std::vector<double>& theData)
236 int aLength = theData.size(), i;
239 SALOMEDS::Locker lock;
240 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
242 aTable->SetRowData(theRow, theData);
245 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
249 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
250 aSeq->length(aLength);
251 for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
252 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theRow, aSeq);
256 std::vector<double> SALOMEDS_AttributeTableOfReal::GetRow(int theRow)
258 std::vector<double> aVector;
261 SALOMEDS::Locker lock;
262 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowData(theRow);
265 SALOMEDS::DoubleSeq_var aRow = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRow(theRow);
266 aLength = aRow->length();
267 for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
273 void SALOMEDS_AttributeTableOfReal::AddColumn(const std::vector<double>& theData)
275 int aLength = theData.size(), i;
278 SALOMEDS::Locker lock;
279 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
281 aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
284 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
288 SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
289 aColumn->length(aLength);
290 for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
291 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddColumn(aColumn);
295 void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vector<double>& theData)
297 int aLength = theData.size(), i;
300 SALOMEDS::Locker lock;
301 SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
303 aTable->SetColumnData(theColumn, theData);
306 throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
310 SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
311 aColumn->length(aLength);
312 for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
313 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
317 std::vector<double> SALOMEDS_AttributeTableOfReal::GetColumn(int theColumn)
319 std::vector<double> aVector;
322 SALOMEDS::Locker lock;
323 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnData(theColumn);
326 SALOMEDS::DoubleSeq_var aColumn = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumn(theColumn);
327 aLength = aColumn->length();
328 for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
333 void SALOMEDS_AttributeTableOfReal::PutValue(double theValue, int theRow, int theColumn)
337 SALOMEDS::Locker lock;
339 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->PutValue(theValue, theRow, theColumn);
342 throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
346 SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
350 bool SALOMEDS_AttributeTableOfReal::HasValue(int theRow, int theColumn)
354 SALOMEDS::Locker lock;
355 ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->HasValue(theRow, theColumn);
357 else ret = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->HasValue(theRow, theColumn);
361 double SALOMEDS_AttributeTableOfReal::GetValue(int theRow, int theColumn)
365 SALOMEDS::Locker lock;
367 aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetValue(theRow, theColumn);
370 throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
374 aValue = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetValue(theRow, theColumn);
379 std::vector<int> SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow)
381 std::vector<int> aVector;
384 SALOMEDS::Locker lock;
385 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetSetRowIndices(theRow);
388 SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowSetIndices(theRow);
389 aLength = aSet->length();
390 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
395 void SALOMEDS_AttributeTableOfReal::SetNbColumns(int theNbColumns)
398 SALOMEDS::Locker lock;
399 dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetNbColumns(theNbColumns);
401 else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns);