Salome HOME
A patch from Paul RASCLE for: kernel documentation with doxygen, modification on...
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTableOfReal.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDS_AttributeTableOfReal.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24 #include "SALOMEDS_AttributeTableOfReal.hxx"
25 #include "SALOMEDS.hxx"
26
27 using namespace std;
28
29 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal
30                   (SALOMEDSImpl_AttributeTableOfReal* theAttr)
31 :SALOMEDS_GenericAttribute(theAttr)
32 {}
33
34 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal(SALOMEDS::AttributeTableOfReal_ptr theAttr)
35 :SALOMEDS_GenericAttribute(theAttr)
36 {}
37
38 SALOMEDS_AttributeTableOfReal::~SALOMEDS_AttributeTableOfReal()
39 {}
40
41
42 void SALOMEDS_AttributeTableOfReal::SetTitle(const std::string& theTitle)
43 {
44   if (_isLocal) {
45     CheckLocked();
46     SALOMEDS::Locker lock;     
47     dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetTitle(theTitle);
48   }
49   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
50 }
51
52 std::string SALOMEDS_AttributeTableOfReal::GetTitle()
53 {
54   std::string aStr;
55   if (_isLocal) {
56     SALOMEDS::Locker lock; 
57     aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetTitle();
58   }
59   else aStr = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetTitle();
60   return aStr;
61 }
62
63 void SALOMEDS_AttributeTableOfReal::SetRowTitle(int theIndex, const std::string& theTitle)
64 {
65   if (_isLocal) {
66     CheckLocked();
67     SALOMEDS::Locker lock;     
68     dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitle(theIndex, theTitle);
69   }
70   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
71 }
72
73 void SALOMEDS_AttributeTableOfReal::SetRowTitles(const std::vector<std::string>& theTitles)
74 {
75   CheckLocked();
76   int aLength = theTitles.size(), i;
77   if (_isLocal) {
78     CheckLocked();
79     SALOMEDS::Locker lock;     
80     dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitles(theTitles);
81   }
82   else {
83     SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
84     aSeq->length(aLength);
85     for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
86     SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitles(aSeq);
87   }
88 }
89
90 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowTitles()
91 {
92   std::vector<std::string> aVector;
93   int aLength, i;
94   if (_isLocal) {
95     SALOMEDS::Locker lock; 
96     aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowTitles();
97   }
98   else {
99     SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitles();
100     aLength = aSeq->length();
101     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
102   }
103   return aVector;
104 }
105
106 void SALOMEDS_AttributeTableOfReal::SetColumnTitle(int theIndex, const std::string& theTitle)
107 {
108   if (_isLocal) {
109     CheckLocked();
110     SALOMEDS::Locker lock; 
111     dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
112   }
113   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
114 }
115
116 void SALOMEDS_AttributeTableOfReal::SetColumnTitles(const std::vector<std::string>& theTitles)
117 {
118   int aLength = theTitles.size(), i;
119   if (_isLocal) {
120     CheckLocked();
121     SALOMEDS::Locker lock; 
122     dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitles(theTitles);
123   }
124   else {
125     SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
126     aSeq->length(aLength);
127     for (i = 0; i < aLength; i++) aSeq[i] = (char*)theTitles[i].c_str();
128     SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitles(aSeq);
129   }
130 }
131
132 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetColumnTitles()
133 {
134   std::vector<std::string> aVector;
135   int aLength, i;
136   if (_isLocal) {
137     SALOMEDS::Locker lock; 
138     aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnTitles();
139   }
140   else {
141     SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitles();
142     aLength = aSeq->length();
143     for (i = 0; i < aLength; i++) aVector.push_back((char*)aSeq[i].in());
144   }
145   return aVector;
146 }
147
148 void SALOMEDS_AttributeTableOfReal::SetRowUnit(int theIndex, const std::string& theUnit)
149 {
150   if (_isLocal) {
151     CheckLocked();
152     SALOMEDS::Locker lock; 
153     dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnit(theIndex, theUnit);
154   }
155   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
156 }
157
158 void SALOMEDS_AttributeTableOfReal::SetRowUnits(const std::vector<std::string>& theUnits)
159 {
160   int aLength = theUnits.size(), i;
161   if (_isLocal) {
162     CheckLocked();
163     SALOMEDS::Locker lock; 
164     dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnits(theUnits);
165   }
166   else {
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::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnits(aSeq);
171   }
172 }
173
174 std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowUnits()
175 {
176   std::vector<std::string> aVector;
177   int aLength, i;
178   if (_isLocal) {
179     SALOMEDS::Locker lock; 
180     aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowUnits();
181   }
182   else {
183     SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnits();
184     aLength = aSeq->length();
185     for (i = 0; i < aLength; i++) aVector.push_back(string(aSeq[i].in()));
186   }
187   return aVector;
188 }
189
190 int SALOMEDS_AttributeTableOfReal::GetNbRows()
191 {
192   int aNb;
193   if (_isLocal) {
194     SALOMEDS::Locker lock; 
195     aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbRows();
196   }
197   else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbRows();
198   return aNb;
199 }
200
201 int SALOMEDS_AttributeTableOfReal::GetNbColumns()
202 {  
203   int aNb;
204   if (_isLocal) {
205     SALOMEDS::Locker lock; 
206     aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbColumns();
207   }
208   else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbColumns();
209   return aNb;
210 }
211
212 void SALOMEDS_AttributeTableOfReal::AddRow(const std::vector<double>& theData)
213 {
214   int aLength = theData.size(), i;
215   if (_isLocal) {
216     CheckLocked();
217     SALOMEDS::Locker lock; 
218     SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
219     try {
220       aTable->SetRowData(aTable->GetNbRows() + 1, theData);
221     }   
222     catch(...) {
223       throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
224     }
225   }
226   else {
227     SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
228     aSeq->length(aLength);
229     for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
230     SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddRow(aSeq);
231   }
232 }
233
234 void SALOMEDS_AttributeTableOfReal::SetRow(int theRow, const std::vector<double>& theData)
235 {
236   int aLength = theData.size(), i;
237   if (_isLocal) {
238     CheckLocked();
239     SALOMEDS::Locker lock; 
240     SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
241     try {
242       aTable->SetRowData(theRow, theData);
243     }   
244     catch(...) {
245       throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
246     }
247   }
248   else {
249     SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq();
250     aSeq->length(aLength);
251     for (i = 0; i < aLength; i++) aSeq[i] = theData[i];
252     SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theRow, aSeq);
253   }
254 }
255
256 std::vector<double> SALOMEDS_AttributeTableOfReal::GetRow(int theRow)
257 {
258   std::vector<double> aVector;
259   int aLength, i;
260   if (_isLocal) {
261     SALOMEDS::Locker lock; 
262     aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowData(theRow);
263   }
264   else {
265     SALOMEDS::DoubleSeq_var aRow = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRow(theRow);
266     aLength = aRow->length();
267     for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
268   }
269
270   return aVector;
271 }
272
273 void SALOMEDS_AttributeTableOfReal::AddColumn(const std::vector<double>& theData)
274 {
275   int aLength = theData.size(), i;
276   if (_isLocal) {
277     CheckLocked();
278     SALOMEDS::Locker lock; 
279     SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
280     try {
281       aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
282     }   
283     catch(...) {
284       throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
285     }
286   }
287   else {
288     SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
289     aColumn->length(aLength);
290     for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
291     SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->AddColumn(aColumn);
292   }
293 }
294
295 void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vector<double>& theData)
296 {
297   int aLength = theData.size(), i;
298   if (_isLocal) {
299     CheckLocked();
300     SALOMEDS::Locker lock; 
301     SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
302     try {
303       aTable->SetColumnData(theColumn, theData);
304     }   
305     catch(...) {
306       throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
307     }
308   }
309   else {
310     SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
311     aColumn->length(aLength);
312     for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
313     SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
314   }
315 }
316
317 std::vector<double> SALOMEDS_AttributeTableOfReal::GetColumn(int theColumn)
318 {
319   std::vector<double> aVector;
320   int aLength, i;
321   if (_isLocal) {
322     SALOMEDS::Locker lock; 
323     aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnData(theColumn);
324   }
325   else {
326     SALOMEDS::DoubleSeq_var aColumn = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumn(theColumn);
327     aLength = aColumn->length();
328     for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
329   }
330   return aVector;
331 }
332
333 void SALOMEDS_AttributeTableOfReal::PutValue(double theValue, int theRow, int theColumn)
334 {
335   if (_isLocal) {
336     CheckLocked();
337     SALOMEDS::Locker lock; 
338     try {
339       dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->PutValue(theValue, theRow, theColumn);
340     }   
341     catch(...) {
342       throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
343     }
344   }
345   else {
346     SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->PutValue(theValue, theRow, theColumn);
347   }
348 }
349
350 bool SALOMEDS_AttributeTableOfReal::HasValue(int theRow, int theColumn)
351 {
352   bool ret;
353   if (_isLocal) {
354     SALOMEDS::Locker lock; 
355     ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->HasValue(theRow, theColumn);
356   }
357   else ret = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->HasValue(theRow, theColumn);
358   return ret;
359 }
360
361 double SALOMEDS_AttributeTableOfReal::GetValue(int theRow, int theColumn)
362 {
363   double aValue;
364   if (_isLocal) {
365     SALOMEDS::Locker lock; 
366     try {
367       aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetValue(theRow, theColumn);
368     }   
369     catch(...) {
370       throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
371     }
372   }
373   else {
374     aValue = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetValue(theRow, theColumn);
375   }
376   return aValue;
377 }
378
379 std::vector<int> SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow)
380 {
381   std::vector<int> aVector;
382   int aLength, i;
383   if (_isLocal) {
384     SALOMEDS::Locker lock; 
385     aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetSetRowIndices(theRow);
386   }
387   else {
388     SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowSetIndices(theRow);
389     aLength = aSet->length();
390     for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
391   }
392   return aVector;
393 }
394
395 void SALOMEDS_AttributeTableOfReal::SetNbColumns(int theNbColumns)
396 {
397   if (_isLocal) {
398     SALOMEDS::Locker lock; 
399     dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetNbColumns(theNbColumns);
400   }
401   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
402 }