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_AttributeTableOfString.cxx
23 // Author : Sergey RUIN
26 #include "SALOMEDS_AttributeTableOfString.hxx"
27 #include "SALOMEDS.hxx"
33 SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString
34 (SALOMEDSImpl_AttributeTableOfString* theAttr)
35 :SALOMEDS_GenericAttribute(theAttr)
38 SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString
39 (SALOMEDS::AttributeTableOfString_ptr theAttr)
40 :SALOMEDS_GenericAttribute(theAttr)
43 SALOMEDS_AttributeTableOfString::~SALOMEDS_AttributeTableOfString()
47 void SALOMEDS_AttributeTableOfString::SetTitle(const std::string& theTitle)
51 SALOMEDS::Locker lock;
52 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetTitle(theTitle);
54 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
57 std::string SALOMEDS_AttributeTableOfString::GetTitle()
61 SALOMEDS::Locker lock;
62 aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetTitle();
64 else aStr = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetTitle();
68 void SALOMEDS_AttributeTableOfString::SetRowTitle(int theIndex, const std::string& theTitle)
72 SALOMEDS::Locker lock;
73 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowTitle(theIndex, theTitle);
75 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
78 void SALOMEDS_AttributeTableOfString::SetRowTitles(const std::vector<std::string>& theTitles)
80 int aLength = theTitles.size(), i;
83 SALOMEDS::Locker lock;
84 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowTitles(theTitles);
87 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
88 aSeq->length(aLength);
89 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
90 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitles(aSeq);
94 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowTitles()
96 std::vector<std::string> aVector;
99 SALOMEDS::Locker lock;
100 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowTitles();
103 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowTitles();
104 aLength = aSeq->length();
105 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
110 void SALOMEDS_AttributeTableOfString::SetColumnTitle(int theIndex, const std::string& theTitle)
114 SALOMEDS::Locker lock;
115 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
117 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
120 void SALOMEDS_AttributeTableOfString::SetColumnTitles(const std::vector<std::string>& theTitles)
122 int aLength = theTitles.size(), i;
125 SALOMEDS::Locker lock;
126 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetColumnTitles(theTitles);
129 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
130 aSeq->length(aLength);
131 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
132 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitles(aSeq);
136 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumnTitles()
138 std::vector<std::string> aVector;
141 SALOMEDS::Locker lock;
142 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetColumnTitles();
145 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumnTitles();
146 aLength = aSeq->length();
147 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
152 void SALOMEDS_AttributeTableOfString::SetRowUnit(int theIndex, const std::string& theUnit)
156 SALOMEDS::Locker lock;
157 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowUnit(theIndex, theUnit);
159 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
162 void SALOMEDS_AttributeTableOfString::SetRowUnits(const std::vector<std::string>& theUnits)
164 int aLength = theUnits.size(), i;
167 SALOMEDS::Locker lock;
168 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowUnits(theUnits);
171 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
172 aSeq->length(aLength);
173 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
174 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnits(aSeq);
178 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowUnits()
180 std::vector<std::string> aVector;
183 SALOMEDS::Locker lock;
184 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowUnits();
187 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowUnits();
188 aLength = aSeq->length();
189 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
194 int SALOMEDS_AttributeTableOfString::GetNbRows()
198 SALOMEDS::Locker lock;
199 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetNbRows();
201 else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbRows();
205 int SALOMEDS_AttributeTableOfString::GetNbColumns()
209 SALOMEDS::Locker lock;
210 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetNbColumns();
212 else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbColumns();
216 void SALOMEDS_AttributeTableOfString::AddRow(const std::vector<std::string>& theData)
218 int aLength = theData.size(), i;
221 SALOMEDS::Locker lock;
222 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
224 aTable->SetRowData(aTable->GetNbRows() + 1, theData);
227 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
231 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
232 aSeq->length(aLength);
233 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str();
234 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddRow(aSeq);
238 void SALOMEDS_AttributeTableOfString::SetRow(int theRow, const std::vector<std::string>& theData)
240 int aLength = theData.size(), i;
243 SALOMEDS::Locker lock;
244 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
246 aTable->SetRowData(theRow, theData);
249 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
253 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
254 aSeq->length(aLength);
255 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str();
256 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theRow, aSeq);
260 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRow(int theRow)
262 std::vector<std::string> aVector;
265 SALOMEDS::Locker lock;
266 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowData(theRow);
269 SALOMEDS::StringSeq_var aRow = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRow(theRow);
270 aLength = aRow->length();
271 for (i = 0; i < aLength; i++) aVector.push_back((char*)aRow[i].in());
277 void SALOMEDS_AttributeTableOfString::AddColumn(const std::vector<std::string>& theData)
279 int aLength = theData.size(), i;
282 SALOMEDS::Locker lock;
283 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
285 aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
288 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
292 SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
293 aColumn->length(aLength);
294 for (i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str();
295 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddColumn(aColumn);
299 void SALOMEDS_AttributeTableOfString::SetColumn(int theColumn, const std::vector<std::string>& theData)
301 int aLength = theData.size(), i;
304 SALOMEDS::Locker lock;
305 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
307 aTable->SetColumnData(theColumn, theData);
310 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
314 SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
315 aColumn->length(aLength);
316 for (i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str();
317 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
321 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumn(int theColumn)
323 std::vector<std::string> aVector;
326 SALOMEDS::Locker lock;
327 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetColumnData(theColumn);
330 SALOMEDS::StringSeq_var aColumn =
331 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumn(theColumn);
332 aLength = aColumn->length();
333 for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i].in());
338 void SALOMEDS_AttributeTableOfString::PutValue(const std::string& theValue, int theRow, int theColumn)
342 SALOMEDS::Locker lock;
344 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->PutValue(theValue, theRow, theColumn);
347 throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
351 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->PutValue(theValue.c_str(), theRow, theColumn);
355 bool SALOMEDS_AttributeTableOfString::HasValue(int theRow, int theColumn)
359 SALOMEDS::Locker lock;
360 ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->HasValue(theRow, theColumn);
362 else ret = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->HasValue(theRow, theColumn);
366 std::string SALOMEDS_AttributeTableOfString::GetValue(int theRow, int theColumn)
370 SALOMEDS::Locker lock;
372 aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetValue(theRow, theColumn);
375 throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
379 aValue = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetValue(theRow, theColumn);
384 std::vector<int> SALOMEDS_AttributeTableOfString::GetRowSetIndices(int theRow)
386 std::vector<int> aVector;
389 SALOMEDS::Locker lock;
390 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetSetRowIndices(theRow);
393 SALOMEDS::LongSeq_var aSet =
394 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowSetIndices(theRow);
395 aLength = aSet->length();
396 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
401 void SALOMEDS_AttributeTableOfString::SetNbColumns(int theNbColumns)
404 SALOMEDS::Locker lock;
405 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetNbColumns(theNbColumns);
407 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetNbColumns(theNbColumns);