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/
20 // File : SALOMEDS_AttributeTableOfInteger.cxx
21 // Author : Sergey RUIN
24 #include "SALOMEDS_AttributeTableOfInteger.hxx"
26 #include <TCollection_AsciiString.hxx>
27 #include <TCollection_ExtendedString.hxx>
28 #include <TColStd_HSequenceOfInteger.hxx>
29 #include <TColStd_HSequenceOfExtendedString.hxx>
32 SALOMEDS_AttributeTableOfInteger
33 ::SALOMEDS_AttributeTableOfInteger(const Handle(SALOMEDSImpl_AttributeTableOfInteger)& theAttr)
34 :SALOMEDS_GenericAttribute(theAttr)
37 SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger(SALOMEDS::AttributeTableOfInteger_ptr theAttr)
38 :SALOMEDS_GenericAttribute(theAttr)
41 SALOMEDS_AttributeTableOfInteger::~SALOMEDS_AttributeTableOfInteger()
45 void SALOMEDS_AttributeTableOfInteger::SetTitle(const std::string& theTitle)
48 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str());
49 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
52 std::string SALOMEDS_AttributeTableOfInteger::GetTitle()
56 aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetTitle()).ToCString();
57 else aStr = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetTitle();
61 void SALOMEDS_AttributeTableOfInteger::SetRowTitle(int theIndex, const std::string& theTitle)
64 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowTitle(theIndex,
65 (char*)theTitle.c_str());
66 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
69 void SALOMEDS_AttributeTableOfInteger::SetRowTitles(const std::vector<std::string>& theTitles)
72 int aLength = theTitles.size(), i;
74 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
75 for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
76 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowTitles(aSeq);
79 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
80 aSeq->length(aLength);
81 for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
82 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitles(aSeq);
87 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowTitles()
89 std::vector<std::string> aVector;
92 Handle(TColStd_HSequenceOfExtendedString) aSeq;
93 aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowTitles();
94 aLength = aSeq->Length();
95 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString((aSeq->Value(i))).ToCString());
98 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowTitles();
99 aLength = aSeq->length();
100 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
105 void SALOMEDS_AttributeTableOfInteger::SetColumnTitle(int theIndex, const std::string& theTitle)
109 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetColumnTitle(theIndex,
110 (char*)theTitle.c_str());
111 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
114 void SALOMEDS_AttributeTableOfInteger::SetColumnTitles(const std::vector<std::string>& theTitles)
117 int aLength = theTitles.size(), i;
119 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
120 for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
121 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetColumnTitles(aSeq);
124 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
125 aSeq->length(aLength);
126 for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
127 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitles(aSeq);
131 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetColumnTitles()
133 std::vector<std::string> aVector;
136 Handle(TColStd_HSequenceOfExtendedString) aSeq;
137 aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetColumnTitles();
138 aLength = aSeq->Length();
139 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
142 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitles();
143 aLength = aSeq->length();
144 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
149 void SALOMEDS_AttributeTableOfInteger::SetRowUnit(int theIndex, const std::string& theUnit)
152 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowUnit(theIndex,
153 (char*)theUnit.c_str());
154 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
157 void SALOMEDS_AttributeTableOfInteger::SetRowUnits(const std::vector<std::string>& theUnits)
160 int aLength = theUnits.size(), i;
162 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
163 for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str());
164 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowUnits(aSeq);
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::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnits(aSeq);
174 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowUnits()
176 std::vector<std::string> aVector;
179 Handle(TColStd_HSequenceOfExtendedString) aSeq;
180 aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowUnits();
181 aLength = aSeq->Length();
182 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
185 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_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_AttributeTableOfInteger::GetNbRows()
195 if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbRows();
196 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbRows();
200 int SALOMEDS_AttributeTableOfInteger::GetNbColumns()
203 if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbColumns();
204 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbColumns();
209 void SALOMEDS_AttributeTableOfInteger::AddRow(const std::vector<int>& theData)
212 int aLength = theData.size(), i;
214 Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
215 aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
216 Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
217 for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
219 aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
222 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
226 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
227 aSeq->length(aLength);
228 for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
229 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddRow(aSeq);
233 void SALOMEDS_AttributeTableOfInteger::SetRow(int theRow, const std::vector<int>& theData)
236 int aLength = theData.size(), i;
238 Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
239 aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
240 Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
241 for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
243 aTable->SetRowData(theRow, aRow);
246 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
250 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
251 aSeq->length(aLength);
252 for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
253 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theRow, aSeq);
257 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRow(int theRow)
259 std::vector<int> aVector;
262 Handle(TColStd_HSequenceOfInteger) aRow;
263 aRow = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowData(theRow);
264 aLength = aRow->Length();
265 for(i = 1; i<= aLength; i++) aVector.push_back(aRow->Value(i));
268 SALOMEDS::LongSeq_var aRow = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRow(theRow);
269 for(i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
275 void SALOMEDS_AttributeTableOfInteger::AddColumn(const std::vector<int>& theData)
278 int aLength = theData.size(), i;
280 Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
281 aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
282 Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
283 for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
285 aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
288 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
292 SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
293 aColumn->length(aLength);
294 for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
295 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddColumn(aColumn);
299 void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vector<int>& theData)
302 int aLength = theData.size(), i;
304 Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
305 aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
306 Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
307 for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
309 aTable->SetRowData(theColumn, aColumn);
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)->SetRow(theColumn, aColumn);
323 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetColumn(int theColumn)
325 std::vector<int> aVector;
328 Handle(TColStd_HSequenceOfInteger) aColumn;
329 aColumn = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetColumnData(theColumn);
330 aLength = aColumn->Length();
331 for(i = 1; i<= aLength; i++) aVector.push_back(aColumn->Value(i));
334 SALOMEDS::LongSeq_var aColumn = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumn(theColumn);
335 for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
340 void SALOMEDS_AttributeTableOfInteger::PutValue(int theValue, int theRow, int theColumn)
345 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_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)
359 if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->HasValue(theRow, theColumn);
360 else ret = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->HasValue(theRow, theColumn);
364 int SALOMEDS_AttributeTableOfInteger::GetValue(int theRow, int theColumn)
369 aValue = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetValue(theRow, theColumn);
372 throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
376 aValue = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetValue(theRow, theColumn);
381 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow)
383 std::vector<int> aVector;
386 Handle(TColStd_HSequenceOfInteger) aSet;
387 aSet = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetSetRowIndices(theRow);
388 aLength = aSet->Length();
389 for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i));
392 SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow);
393 for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
398 void SALOMEDS_AttributeTableOfInteger::SetNbColumns(int theNbColumns)
400 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetNbColumns(theNbColumns);
401 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns);