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_AttributeTableOfString.cxx
21 // Author : Sergey RUIN
24 #include "SALOMEDS_AttributeTableOfString.hxx"
25 #include "SALOMEDS.hxx"
31 SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString
32 (SALOMEDSImpl_AttributeTableOfString* theAttr)
33 :SALOMEDS_GenericAttribute(theAttr)
36 SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString
37 (SALOMEDS::AttributeTableOfString_ptr theAttr)
38 :SALOMEDS_GenericAttribute(theAttr)
41 SALOMEDS_AttributeTableOfString::~SALOMEDS_AttributeTableOfString()
45 void SALOMEDS_AttributeTableOfString::SetTitle(const std::string& theTitle)
49 SALOMEDS::Locker lock;
50 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetTitle(theTitle);
52 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
55 std::string SALOMEDS_AttributeTableOfString::GetTitle()
59 SALOMEDS::Locker lock;
60 aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetTitle();
62 else aStr = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetTitle();
66 void SALOMEDS_AttributeTableOfString::SetRowTitle(int theIndex, const std::string& theTitle)
70 SALOMEDS::Locker lock;
71 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowTitle(theIndex, theTitle);
73 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
76 void SALOMEDS_AttributeTableOfString::SetRowTitles(const std::vector<std::string>& theTitles)
78 int aLength = theTitles.size(), i;
81 SALOMEDS::Locker lock;
82 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitles(aSeq);
92 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowTitles()
94 std::vector<std::string> aVector;
97 SALOMEDS::Locker lock;
98 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowTitles();
101 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_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_AttributeTableOfString::SetColumnTitle(int theIndex, const std::string& theTitle)
112 SALOMEDS::Locker lock;
113 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
115 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
118 void SALOMEDS_AttributeTableOfString::SetColumnTitles(const std::vector<std::string>& theTitles)
120 int aLength = theTitles.size(), i;
123 SALOMEDS::Locker lock;
124 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitles(aSeq);
134 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumnTitles()
136 std::vector<std::string> aVector;
139 SALOMEDS::Locker lock;
140 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetColumnTitles();
143 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_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_AttributeTableOfString::SetRowUnit(int theIndex, const std::string& theUnit)
154 SALOMEDS::Locker lock;
155 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetRowUnit(theIndex, theUnit);
157 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
160 void SALOMEDS_AttributeTableOfString::SetRowUnits(const std::vector<std::string>& theUnits)
162 int aLength = theUnits.size(), i;
165 SALOMEDS::Locker lock;
166 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnits(aSeq);
176 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRowUnits()
178 std::vector<std::string> aVector;
181 SALOMEDS::Locker lock;
182 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowUnits();
185 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowUnits();
186 aLength = aSeq->length();
187 for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
192 int SALOMEDS_AttributeTableOfString::GetNbRows()
196 SALOMEDS::Locker lock;
197 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetNbRows();
199 else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbRows();
203 int SALOMEDS_AttributeTableOfString::GetNbColumns()
207 SALOMEDS::Locker lock;
208 aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetNbColumns();
210 else aNb = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetNbColumns();
214 void SALOMEDS_AttributeTableOfString::AddRow(const std::vector<std::string>& theData)
216 int aLength = theData.size(), i;
219 SALOMEDS::Locker lock;
220 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
222 aTable->SetRowData(aTable->GetNbRows() + 1, theData);
225 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
229 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
230 aSeq->length(aLength);
231 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str();
232 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddRow(aSeq);
236 void SALOMEDS_AttributeTableOfString::SetRow(int theRow, const std::vector<std::string>& theData)
238 int aLength = theData.size(), i;
241 SALOMEDS::Locker lock;
242 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
244 aTable->SetRowData(theRow, theData);
247 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
251 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
252 aSeq->length(aLength);
253 for (i = 0; i < aLength; i++) aSeq[i] = (char*)theData[i].c_str();
254 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRow(theRow, aSeq);
258 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetRow(int theRow)
260 std::vector<std::string> aVector;
263 SALOMEDS::Locker lock;
264 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowData(theRow);
267 SALOMEDS::StringSeq_var aRow = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRow(theRow);
268 aLength = aRow->length();
269 for (i = 0; i < aLength; i++) aVector.push_back((char*)aRow[i].in());
275 void SALOMEDS_AttributeTableOfString::AddColumn(const std::vector<std::string>& theData)
277 int aLength = theData.size(), i;
280 SALOMEDS::Locker lock;
281 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
283 aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
286 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
290 SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
291 aColumn->length(aLength);
292 for (i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str();
293 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->AddColumn(aColumn);
297 void SALOMEDS_AttributeTableOfString::SetColumn(int theColumn, const std::vector<std::string>& theData)
299 int aLength = theData.size(), i;
302 SALOMEDS::Locker lock;
303 SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl);
305 aTable->SetColumnData(theColumn, theData);
308 throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
312 SALOMEDS::StringSeq_var aColumn = new SALOMEDS::StringSeq();
313 aColumn->length(aLength);
314 for (i = 0; i < aLength; i++) aColumn[i] = (char*)theData[i].c_str();
315 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
319 std::vector<std::string> SALOMEDS_AttributeTableOfString::GetColumn(int theColumn)
321 std::vector<std::string> aVector;
324 SALOMEDS::Locker lock;
325 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetColumnData(theColumn);
328 SALOMEDS::StringSeq_var aColumn =
329 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumn(theColumn);
330 aLength = aColumn->length();
331 for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i].in());
336 void SALOMEDS_AttributeTableOfString::PutValue(const std::string& theValue, int theRow, int theColumn)
340 SALOMEDS::Locker lock;
342 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->PutValue(theValue, theRow, theColumn);
345 throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
349 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->PutValue(theValue.c_str(), theRow, theColumn);
353 bool SALOMEDS_AttributeTableOfString::HasValue(int theRow, int theColumn)
357 SALOMEDS::Locker lock;
358 ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->HasValue(theRow, theColumn);
360 else ret = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->HasValue(theRow, theColumn);
364 std::string SALOMEDS_AttributeTableOfString::GetValue(int theRow, int theColumn)
368 SALOMEDS::Locker lock;
370 aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetValue(theRow, theColumn);
373 throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
377 aValue = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetValue(theRow, theColumn);
382 std::vector<int> SALOMEDS_AttributeTableOfString::GetRowSetIndices(int theRow)
384 std::vector<int> aVector;
387 SALOMEDS::Locker lock;
388 aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetSetRowIndices(theRow);
391 SALOMEDS::LongSeq_var aSet =
392 SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowSetIndices(theRow);
393 aLength = aSet->length();
394 for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
399 void SALOMEDS_AttributeTableOfString::SetNbColumns(int theNbColumns)
402 SALOMEDS::Locker lock;
403 dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SetNbColumns(theNbColumns);
405 else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetNbColumns(theNbColumns);