1 // File : SALOMEDS_AttributeTableOfInteger.cxx
2 // Author : Sergey RUIN
5 #include "SALOMEDS_AttributeTableOfInteger.hxx"
7 #include <TCollection_AsciiString.hxx>
8 #include <TCollection_ExtendedString.hxx>
9 #include <TColStd_HSequenceOfInteger.hxx>
10 #include <TColStd_HSequenceOfExtendedString.hxx>
13 SALOMEDS_AttributeTableOfInteger
14 ::SALOMEDS_AttributeTableOfInteger(const Handle(SALOMEDSImpl_AttributeTableOfInteger)& theAttr)
15 :SALOMEDS_GenericAttribute(theAttr)
18 SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger(SALOMEDS::AttributeTableOfInteger_ptr theAttr)
19 :SALOMEDS_GenericAttribute(theAttr)
22 SALOMEDS_AttributeTableOfInteger::~SALOMEDS_AttributeTableOfInteger()
26 void SALOMEDS_AttributeTableOfInteger::SetTitle(const std::string& theTitle)
29 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str());
30 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
33 std::string SALOMEDS_AttributeTableOfInteger::GetTitle()
37 aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetTitle()).ToCString();
38 else aStr = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetTitle();
42 void SALOMEDS_AttributeTableOfInteger::SetRowTitle(int theIndex, const std::string& theTitle)
45 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowTitle(theIndex,
46 (char*)theTitle.c_str());
47 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
50 void SALOMEDS_AttributeTableOfInteger::SetRowTitles(const std::vector<std::string>& theTitles)
53 int aLength = theTitles.size(), i;
55 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
56 for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
57 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowTitles(aSeq);
60 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
61 aSeq->length(aLength);
62 for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
63 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitles(aSeq);
68 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowTitles()
70 std::vector<std::string> aVector;
73 Handle(TColStd_HSequenceOfExtendedString) aSeq;
74 aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowTitles();
75 aLength = aSeq->Length();
76 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString((aSeq->Value(i))).ToCString());
79 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowTitles();
80 aLength = aSeq->length();
81 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
86 void SALOMEDS_AttributeTableOfInteger::SetColumnTitle(int theIndex, const std::string& theTitle)
90 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetColumnTitle(theIndex,
91 (char*)theTitle.c_str());
92 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
95 void SALOMEDS_AttributeTableOfInteger::SetColumnTitles(const std::vector<std::string>& theTitles)
98 int aLength = theTitles.size(), i;
100 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
101 for(i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
102 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetColumnTitles(aSeq);
105 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
106 aSeq->length(aLength);
107 for(i = 0; i < aLength; i++) aSeq[i] = theTitles[i].c_str();
108 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitles(aSeq);
112 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetColumnTitles()
114 std::vector<std::string> aVector;
117 Handle(TColStd_HSequenceOfExtendedString) aSeq;
118 aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetColumnTitles();
119 aLength = aSeq->Length();
120 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
123 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitles();
124 aLength = aSeq->length();
125 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
130 void SALOMEDS_AttributeTableOfInteger::SetRowUnit(int theIndex, const std::string& theUnit)
133 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowUnit(theIndex,
134 (char*)theUnit.c_str());
135 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
138 void SALOMEDS_AttributeTableOfInteger::SetRowUnits(const std::vector<std::string>& theUnits)
141 int aLength = theUnits.size(), i;
143 Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
144 for(i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str());
145 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowUnits(aSeq);
148 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
149 aSeq->length(aLength);
150 for(i = 0; i < aLength; i++) aSeq[i] = (char*)theUnits[i].c_str();
151 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnits(aSeq);
155 std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowUnits()
157 std::vector<std::string> aVector;
160 Handle(TColStd_HSequenceOfExtendedString) aSeq;
161 aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowUnits();
162 aLength = aSeq->Length();
163 for(i = 1; i<= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
166 SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowUnits();
167 aLength = aSeq->length();
168 for(i = 0; i<aLength; i++) aVector.push_back((char*)aSeq[i].in());
173 int SALOMEDS_AttributeTableOfInteger::GetNbRows()
176 if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbRows();
177 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbRows();
181 int SALOMEDS_AttributeTableOfInteger::GetNbColumns()
184 if(_isLocal) aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbColumns();
185 else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbColumns();
190 void SALOMEDS_AttributeTableOfInteger::AddRow(const std::vector<int>& theData)
193 int aLength = theData.size(), i;
195 Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
196 aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
197 Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
198 for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
200 aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
203 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
207 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
208 aSeq->length(aLength);
209 for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
210 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddRow(aSeq);
214 void SALOMEDS_AttributeTableOfInteger::SetRow(int theRow, const std::vector<int>& theData)
217 int aLength = theData.size(), i;
219 Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
220 aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
221 Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
222 for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
224 aTable->SetRowData(theRow, aRow);
227 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
231 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
232 aSeq->length(aLength);
233 for(i = 0; i < aLength; i++) aSeq[i] = theData[i];
234 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theRow, aSeq);
238 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRow(int theRow)
240 std::vector<int> aVector;
243 Handle(TColStd_HSequenceOfInteger) aRow;
244 aRow = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowData(theRow);
245 aLength = aRow->Length();
246 for(i = 1; i<= aLength; i++) aVector.push_back(aRow->Value(i));
249 SALOMEDS::LongSeq_var aRow = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRow(theRow);
250 for(i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
256 void SALOMEDS_AttributeTableOfInteger::AddColumn(const std::vector<int>& theData)
259 int aLength = theData.size(), i;
261 Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
262 aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
263 Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
264 for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
266 aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
269 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
273 SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
274 aColumn->length(aLength);
275 for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
276 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->AddColumn(aColumn);
280 void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vector<int>& theData)
283 int aLength = theData.size(), i;
285 Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
286 aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
287 Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
288 for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
290 aTable->SetRowData(theColumn, aColumn);
293 throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
297 SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
298 aColumn->length(aLength);
299 for(i = 0; i < aLength; i++) aColumn[i] = theData[i];
300 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
304 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetColumn(int theColumn)
306 std::vector<int> aVector;
309 Handle(TColStd_HSequenceOfInteger) aColumn;
310 aColumn = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetColumnData(theColumn);
311 aLength = aColumn->Length();
312 for(i = 1; i<= aLength; i++) aVector.push_back(aColumn->Value(i));
315 SALOMEDS::LongSeq_var aColumn = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumn(theColumn);
316 for(i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
321 void SALOMEDS_AttributeTableOfInteger::PutValue(int theValue, int theRow, int theColumn)
326 Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->PutValue(theValue, theRow, theColumn);
329 throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
333 SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
337 bool SALOMEDS_AttributeTableOfInteger::HasValue(int theRow, int theColumn)
340 if(_isLocal) ret = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->HasValue(theRow, theColumn);
341 else ret = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->HasValue(theRow, theColumn);
345 int SALOMEDS_AttributeTableOfInteger::GetValue(int theRow, int theColumn)
350 aValue = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetValue(theRow, theColumn);
353 throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
357 aValue = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetValue(theRow, theColumn);
362 std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow)
364 std::vector<int> aVector;
367 Handle(TColStd_HSequenceOfInteger) aSet;
368 aSet = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetSetRowIndices(theRow);
369 aLength = aSet->Length();
370 for(i = 1; i<= aLength; i++) aVector.push_back(aSet->Value(i));
373 SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow);
374 for(i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
379 void SALOMEDS_AttributeTableOfInteger::SetNbColumns(int theNbColumns)
381 if(_isLocal) Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetNbColumns(theNbColumns);
382 else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns);