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_AttributeTableOfInteger.cxx
21 // Author : Sergey RUIN
24 #include "SALOMEDS_AttributeTableOfInteger.hxx"
25 #include "SALOMEDS.hxx"
29 SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger
30 (SALOMEDSImpl_AttributeTableOfInteger* theAttr)
31 :SALOMEDS_GenericAttribute(theAttr)
34 SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger
35 (SALOMEDS::AttributeTableOfInteger_ptr theAttr)
36 :SALOMEDS_GenericAttribute(theAttr)
39 SALOMEDS_AttributeTableOfInteger::~SALOMEDS_AttributeTableOfInteger()
43 void SALOMEDS_AttributeTableOfInteger::SetTitle(const std::string& theTitle)
47 SALOMEDS::Locker lock;
48 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetTitle(theTitle);
50 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
53 std::string SALOMEDS_AttributeTableOfInteger::GetTitle()
57 SALOMEDS::Locker lock;
58 aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetTitle();
60 else aStr = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetTitle();
64 void SALOMEDS_AttributeTableOfInteger::SetRowTitle(int theIndex, const std::string& theTitle)
68 SALOMEDS::Locker lock;
69 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowTitle(theIndex, theTitle);
71 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
74 void SALOMEDS_AttributeTableOfInteger::SetRowTitles(const std::vector<std::string>& theTitles)
76 int aLength = theTitles.size(), i;
79 SALOMEDS::Locker lock;
81 for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
82 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowTitles(aSeq);
85 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
86 aSeq->length(aLength);
87 for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
88 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitles(aSeq);
93 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowTitles()
95 std::vector<std::string> aVector;
98 SALOMEDS::Locker lock;
99 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowTitles();
102 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowTitles();
103 aLength = aSeq->length();
104 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
109 void SALOMEDS_AttributeTableOfInteger::SetColumnTitle(int theIndex, const std::string& theTitle)
113 SALOMEDS::Locker lock;
114 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
116 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
119 void SALOMEDS_AttributeTableOfInteger::SetColumnTitles(const std::vector<std::string>& theTitles)
121 int aLength = theTitles.size(), i;
124 SALOMEDS::Locker lock;
126 for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
127 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetColumnTitles(aSeq);
130 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
131 aSeq->length(aLength);
132 for (i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
133 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitles(aSeq);
137 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetColumnTitles()
139 std::vector<std::string> aVector;
142 SALOMEDS::Locker lock;
143 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetColumnTitles();
146 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitles();
147 aLength = aSeq->length();
148 for (i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
153 void SALOMEDS_AttributeTableOfInteger::SetRowUnit(int theIndex, const std::string& theUnit)
157 SALOMEDS::Locker lock;
158 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowUnit(theIndex, theUnit);
160 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
163 void SALOMEDS_AttributeTableOfInteger::SetRowUnits(const std::vector<std::string>& theUnits)
165 int aLength = theUnits.size(), i;
168 SALOMEDS::Locker lock;
169 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowUnits(theUnits);
172 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
173 aSeq->length(aLength);
174 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
175 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnits(aSeq);
179 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowUnits()
181 std::vector<std::string> aVector;
184 SALOMEDS::Locker lock;
185 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowUnits();
188 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowUnits();
189 aLength = aSeq->length();
190 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
195 int SALOMEDS_AttributeTableOfInteger::GetNbRows()
199 SALOMEDS::Locker lock;
200 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetNbRows();
202 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbRows();
206 int SALOMEDS_AttributeTableOfInteger::GetNbColumns()
210 SALOMEDS::Locker lock;
211 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetNbColumns();
213 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbColumns();
218 void SALOMEDS_AttributeTableOfInteger::AddRow(const std::vector<int>& theData)
220 int aLength = theData.size(), i;
223 SALOMEDS::Locker lock;
224 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
226 aTable->SetRowData(aTable->GetNbRows() + 1, theData);
229 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
233 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
234 aSeq->length(aLength);
235 for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
236 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddRow(aSeq);
240 void SALOMEDS_AttributeTableOfInteger::SetRow(int theRow, const std::vector<int>& theData)
242 int aLength = theData.size(), i;
245 SALOMEDS::Locker lock;
246 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
248 aTable->SetRowData(theRow, theData);
251 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
255 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
256 aSeq->length(aLength);
257 for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
258 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theRow, aSeq);
262 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRow(int theRow)
264 std::vector<int> aVector;
267 SALOMEDS::Locker lock;
268 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowData(theRow);
271 SALOMEDS::LongSeq_var aRow = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRow(theRow);
272 aLength = aRow->length();
273 for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
279 void SALOMEDS_AttributeTableOfInteger::AddColumn(const std::vector<int>& theData)
281 int aLength = theData.size(), i;
284 SALOMEDS::Locker lock;
285 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
287 aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
290 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
294 SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
295 aColumn->length(aLength);
296 for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
297 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddColumn(aColumn);
301 void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vector<int>& theData)
303 int aLength = theData.size(), i;
306 SALOMEDS::Locker lock;
307 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
309 aTable->SetColumnData(theColumn, theData);
312 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
316 SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
317 aColumn->length(aLength);
318 for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
319 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
323 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetColumn(int theColumn)
325 std::vector<int> aVector;
328 SALOMEDS::Locker lock;
329 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetColumnData(theColumn);
332 SALOMEDS::LongSeq_var aColumn = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumn(theColumn);
333 aLength = aColumn->length();
334 for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
339 void SALOMEDS_AttributeTableOfInteger::PutValue(int theValue, int theRow, int theColumn)
343 SALOMEDS::Locker lock;
345 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->PutValue(theValue, theRow, theColumn);
348 throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
352 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
356 bool SALOMEDS_AttributeTableOfInteger::HasValue(int theRow, int theColumn)
360 SALOMEDS::Locker lock;
361 ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->HasValue(theRow, theColumn);
363 else ret = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->HasValue(theRow, theColumn);
367 int SALOMEDS_AttributeTableOfInteger::GetValue(int theRow, int theColumn)
371 SALOMEDS::Locker lock;
373 aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetValue(theRow, theColumn);
376 throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
380 aValue = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetValue(theRow, theColumn);
385 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow)
387 std::vector<int> aVector;
390 SALOMEDS::Locker lock;
391 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetSetRowIndices(theRow);
394 SALOMEDS::LongSeq_var aSet =
395 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow);
396 aLength = aSet->length();
397 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
402 void SALOMEDS_AttributeTableOfInteger::SetNbColumns(int theNbColumns)
405 SALOMEDS::Locker lock;
406 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetNbColumns(theNbColumns);
408 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns);