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_AttributeTableOfInteger.cxx
23 // Author : Sergey RUIN
26 #include "SALOMEDS_AttributeTableOfInteger.hxx"
27 #include "SALOMEDS.hxx"
31 SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger
32 (SALOMEDSImpl_AttributeTableOfInteger* theAttr)
33 :SALOMEDS_GenericAttribute(theAttr)
36 SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger
37 (SALOMEDS::AttributeTableOfInteger_ptr theAttr)
38 :SALOMEDS_GenericAttribute(theAttr)
41 SALOMEDS_AttributeTableOfInteger::~SALOMEDS_AttributeTableOfInteger()
45 void SALOMEDS_AttributeTableOfInteger::SetTitle(const std::string& theTitle)
49 SALOMEDS::Locker lock;
50 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetTitle(theTitle);
52 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
55 std::string SALOMEDS_AttributeTableOfInteger::GetTitle()
59 SALOMEDS::Locker lock;
60 aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetTitle();
62 else aStr = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetTitle();
66 void SALOMEDS_AttributeTableOfInteger::SetRowTitle(int theIndex, const std::string& theTitle)
70 SALOMEDS::Locker lock;
71 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowTitle(theIndex, theTitle);
73 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
76 void SALOMEDS_AttributeTableOfInteger::SetRowTitles(const std::vector<std::string>& theTitles)
78 int aLength = theTitles.size(), i;
81 SALOMEDS::Locker lock;
83 for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
84 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowTitles(aSeq);
87 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
88 aSeq->length(aLength);
89 for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
90 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitles(aSeq);
95 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowTitles()
97 std::vector<std::string> aVector;
100 SALOMEDS::Locker lock;
101 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowTitles();
104 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowTitles();
105 aLength = aSeq->length();
106 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
111 void SALOMEDS_AttributeTableOfInteger::SetColumnTitle(int theIndex, const std::string& theTitle)
115 SALOMEDS::Locker lock;
116 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
118 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
121 void SALOMEDS_AttributeTableOfInteger::SetColumnTitles(const std::vector<std::string>& theTitles)
123 int aLength = theTitles.size(), i;
126 SALOMEDS::Locker lock;
128 for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
129 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetColumnTitles(aSeq);
132 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
133 aSeq->length(aLength);
134 for (i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
135 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitles(aSeq);
139 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetColumnTitles()
141 std::vector<std::string> aVector;
144 SALOMEDS::Locker lock;
145 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetColumnTitles();
148 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitles();
149 aLength = aSeq->length();
150 for (i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
155 void SALOMEDS_AttributeTableOfInteger::SetRowUnit(int theIndex, const std::string& theUnit)
159 SALOMEDS::Locker lock;
160 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowUnit(theIndex, theUnit);
162 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
165 void SALOMEDS_AttributeTableOfInteger::SetRowUnits(const std::vector<std::string>& theUnits)
167 int aLength = theUnits.size(), i;
170 SALOMEDS::Locker lock;
171 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowUnits(theUnits);
174 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
175 aSeq->length(aLength);
176 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
177 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnits(aSeq);
181 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowUnits()
183 std::vector<std::string> aVector;
186 SALOMEDS::Locker lock;
187 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowUnits();
190 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowUnits();
191 aLength = aSeq->length();
192 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
197 int SALOMEDS_AttributeTableOfInteger::GetNbRows()
201 SALOMEDS::Locker lock;
202 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetNbRows();
204 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbRows();
208 int SALOMEDS_AttributeTableOfInteger::GetNbColumns()
212 SALOMEDS::Locker lock;
213 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetNbColumns();
215 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbColumns();
220 void SALOMEDS_AttributeTableOfInteger::AddRow(const std::vector<int>& theData)
222 int aLength = theData.size(), i;
225 SALOMEDS::Locker lock;
226 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
228 aTable->SetRowData(aTable->GetNbRows() + 1, theData);
231 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
235 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
236 aSeq->length(aLength);
237 for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
238 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddRow(aSeq);
242 void SALOMEDS_AttributeTableOfInteger::SetRow(int theRow, const std::vector<int>& theData)
244 int aLength = theData.size(), i;
247 SALOMEDS::Locker lock;
248 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
250 aTable->SetRowData(theRow, theData);
253 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
257 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
258 aSeq->length(aLength);
259 for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
260 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theRow, aSeq);
264 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRow(int theRow)
266 std::vector<int> aVector;
269 SALOMEDS::Locker lock;
270 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowData(theRow);
273 SALOMEDS::LongSeq_var aRow = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRow(theRow);
274 aLength = aRow->length();
275 for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
281 void SALOMEDS_AttributeTableOfInteger::AddColumn(const std::vector<int>& theData)
283 int aLength = theData.size(), i;
286 SALOMEDS::Locker lock;
287 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
289 aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
292 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
296 SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
297 aColumn->length(aLength);
298 for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
299 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddColumn(aColumn);
303 void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vector<int>& theData)
305 int aLength = theData.size(), i;
308 SALOMEDS::Locker lock;
309 SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
311 aTable->SetColumnData(theColumn, theData);
314 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
318 SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
319 aColumn->length(aLength);
320 for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
321 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
325 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetColumn(int theColumn)
327 std::vector<int> aVector;
330 SALOMEDS::Locker lock;
331 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetColumnData(theColumn);
334 SALOMEDS::LongSeq_var aColumn = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumn(theColumn);
335 aLength = aColumn->length();
336 for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
341 void SALOMEDS_AttributeTableOfInteger::PutValue(int theValue, int theRow, int theColumn)
345 SALOMEDS::Locker lock;
347 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->PutValue(theValue, theRow, theColumn);
350 throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
354 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
358 bool SALOMEDS_AttributeTableOfInteger::HasValue(int theRow, int theColumn)
362 SALOMEDS::Locker lock;
363 ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->HasValue(theRow, theColumn);
365 else ret = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->HasValue(theRow, theColumn);
369 int SALOMEDS_AttributeTableOfInteger::GetValue(int theRow, int theColumn)
373 SALOMEDS::Locker lock;
375 aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetValue(theRow, theColumn);
378 throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
382 aValue = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetValue(theRow, theColumn);
387 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow)
389 std::vector<int> aVector;
392 SALOMEDS::Locker lock;
393 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetSetRowIndices(theRow);
396 SALOMEDS::LongSeq_var aSet =
397 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow);
398 aLength = aSet->length();
399 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
404 void SALOMEDS_AttributeTableOfInteger::SetNbColumns(int theNbColumns)
407 SALOMEDS::Locker lock;
408 dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetNbColumns(theNbColumns);
410 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns);