Salome HOME
Fix pb. with loading of last module (in list).
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeParameter_i.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_AttributeParameter_i.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24
25 #include "SALOMEDS_AttributeParameter_i.hxx"
26 #include "SALOMEDS.hxx"
27
28 #include <vector>
29
30 using namespace std;
31
32 //=======================================================================
33 /*!
34  * Function : SetInt
35  * Purpose  : Associates a integer value with the ID
36  */
37 //=======================================================================
38 void SALOMEDS_AttributeParameter_i::SetInt(const char* theID, CORBA::Long theValue)
39 {
40   SALOMEDS::Locker lock; 
41   CheckLocked();
42   dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetInt(theID, theValue);
43 }
44
45 //=======================================================================
46 /*!
47  * Function : GetInt
48  * Purpose  : Returns a int value associated with the given ID
49  */
50 //=======================================================================
51 CORBA::Long SALOMEDS_AttributeParameter_i::GetInt(const char* theID)
52 {
53   SALOMEDS::Locker lock; 
54   return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetInt(theID);
55 }
56
57 //=======================================================================
58 /*!
59  * Function : SetReal
60  * Purpose  : Associates a double value with the ID
61  */
62 //=======================================================================
63 void SALOMEDS_AttributeParameter_i::SetReal(const char* theID, CORBA::Double theValue)
64 {
65   SALOMEDS::Locker lock; 
66   CheckLocked();
67   dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetReal(theID, theValue);
68 }
69
70 //=======================================================================
71 /*!
72  * Function : GetReal
73  * Purpose  : Returns a double value associated with the given ID
74  */
75 //=======================================================================
76 CORBA::Double SALOMEDS_AttributeParameter_i::GetReal(const char* theID)
77 {
78   SALOMEDS::Locker lock; 
79   return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetReal(theID);
80 }
81
82 //=======================================================================
83 /*!
84  * Function : SetString
85  * Purpose  : Associates a string with the ID
86  */
87 //=======================================================================
88 void SALOMEDS_AttributeParameter_i::SetString(const char* theID, const char* theValue)
89 {
90   SALOMEDS::Locker lock; 
91   CheckLocked();
92   SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
93   impl->SetString(theID, theValue);
94 }
95
96 //=======================================================================
97 /*!
98  * Function : GetString
99  * Purpose  : Returns a string associated with the given ID
100  */
101 //=======================================================================
102 char* SALOMEDS_AttributeParameter_i::GetString(const char* theID)
103 {
104   SALOMEDS::Locker lock; 
105   SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
106   CORBA::String_var c_s = CORBA::string_dup(impl->GetString(theID).c_str());
107   return c_s._retn();
108 }
109
110 //=======================================================================
111 /*!
112  * Function : SetBool
113  * Purpose  : Associates a bool value with the ID
114  */
115 //=======================================================================  
116 void SALOMEDS_AttributeParameter_i::SetBool(const char* theID, CORBA::Boolean theValue)
117 {
118   SALOMEDS::Locker lock; 
119   CheckLocked();
120   dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetBool(theID, theValue);
121 }
122
123 //=======================================================================
124 /*!
125  * Function : GetBool
126  * Purpose  : Returns a bool value associated with the ID
127  */
128 //=======================================================================
129 CORBA::Boolean SALOMEDS_AttributeParameter_i::GetBool(const char* theID)
130 {
131   SALOMEDS::Locker lock; 
132   return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetBool(theID);
133 }
134   
135 //=======================================================================
136 /*!
137  * Function : SetRealArray
138  * Purpose  : Associates an array of double values with the given ID
139  */
140 //=======================================================================
141 void SALOMEDS_AttributeParameter_i::SetRealArray(const char* theID, const SALOMEDS::DoubleSeq& theArray)
142 {
143   SALOMEDS::Locker lock; 
144   CheckLocked();
145   vector<double> v;
146   int length = theArray.length();
147   if(length) {
148     v.resize(length);
149     for(int i = 0; i<length; i++) v[i] = theArray[i];
150   }
151   dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetRealArray(theID, v);
152 }
153
154 //=======================================================================
155 /*!
156  * Function : GetRealArray
157  * Purpose  : Returns an array of double values associated with the ID
158  */
159 //=======================================================================
160 SALOMEDS::DoubleSeq* SALOMEDS_AttributeParameter_i::GetRealArray(const char* theID)
161 {
162   SALOMEDS::Locker lock; 
163   SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq;
164   vector<double> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetRealArray(theID);
165   int length = v.size();
166   if(length) {
167     aSeq->length(length);
168     for(int i = 0; i<length; i++) aSeq[i] = v[i];
169   }
170   return aSeq._retn();
171 }
172  
173 //=======================================================================
174 /*!
175  * Function : SetIntArray
176  * Purpose  : Associates an array of int values with the given ID
177  */
178 //=======================================================================
179 void SALOMEDS_AttributeParameter_i::SetIntArray(const char* theID, const SALOMEDS::LongSeq& theArray)
180 {
181   SALOMEDS::Locker lock; 
182   CheckLocked();
183   vector<int> v;
184   int length = theArray.length();
185   if(length) {
186     v.resize(length);
187     for(int i = 0; i<length; i++) v[i] = theArray[i];
188   }
189   dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetIntArray(theID, v);
190 }
191
192 //=======================================================================
193 /*!
194  * Function : GetIntArray
195  * Purpose  : Returns an array of int values associated with the ID
196  */
197 //=======================================================================
198 SALOMEDS::LongSeq* SALOMEDS_AttributeParameter_i::GetIntArray(const char* theID)
199 {
200   SALOMEDS::Locker lock; 
201   SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq;
202   vector<int> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetIntArray(theID);
203   int length = v.size();
204   if(length) {
205     aSeq->length(length);
206     for(int i = 0; i<length; i++) aSeq[i] = v[i];
207   }
208   return aSeq._retn();
209 }
210   
211 //=======================================================================
212 /*!
213  * Function : SetStrArray
214  * Purpose  : Associates an array of string values with the given ID
215  */
216 //=======================================================================
217 void SALOMEDS_AttributeParameter_i::SetStrArray(const char* theID, const SALOMEDS::StringSeq& theArray)
218 {
219   SALOMEDS::Locker lock; 
220   CheckLocked();
221   vector<string> v;
222   int length = theArray.length();
223   if(length) {
224     v.resize(length);
225     for(int i = 0; i<length; i++) v[i] = string(theArray[i].in());
226   }
227   dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetStrArray(theID, v);
228 }
229
230 //=======================================================================
231 /*!
232  * Function : GetStrArray
233  * Purpose  : Returns an array of string values associated with the ID
234  */
235 //=======================================================================
236 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetStrArray(const char* theID)
237 {
238   SALOMEDS::Locker lock; 
239   SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq;
240   vector<string> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetStrArray(theID);
241   int length = v.size();
242   if(length) {
243     aSeq->length(length);
244     for(int i = 0; i<length; i++) aSeq[i] = CORBA::string_dup(v[i].c_str());
245   }
246   return aSeq._retn();
247 }
248   
249  
250 //=======================================================================
251 /*!
252  * Function : IsSet
253  * Purpose  : Returns true if for the ID of given type was assigned \n
254  *            a value in the attribute
255  */
256 //=======================================================================
257 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsSet(const char* theID, CORBA::Long theType)
258 {
259   SALOMEDS::Locker lock; 
260   return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsSet(theID, (Parameter_Types)theType);
261 }
262
263 //=======================================================================
264 /*!
265  * Function : RemoveID
266  * Purpose  : Removes a parameter with given ID
267  */
268 //=======================================================================  
269 CORBA::Boolean SALOMEDS_AttributeParameter_i::RemoveID(const char* theID, CORBA::Long theType)
270 {
271   SALOMEDS::Locker lock; 
272   CheckLocked();
273   return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->RemoveID(theID, (Parameter_Types)theType);
274 }
275
276 //=======================================================================
277 /*!
278  * Function : GetFather
279  * Purpose  : Returns a father attribute for this attribute
280  */
281 //=======================================================================
282 SALOMEDS::AttributeParameter_ptr SALOMEDS_AttributeParameter_i::GetFather()
283 {
284   SALOMEDS::Locker lock; 
285   SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
286   SALOMEDS_AttributeParameter_i* attr = new SALOMEDS_AttributeParameter_i(impl, _orb);
287   return attr->AttributeParameter::_this();
288 }
289
290 //=======================================================================
291 /*!
292  * Function : HasFather
293  * Purpose  : Returns True if the attribute has a father attribute
294  */
295 //=======================================================================
296 CORBA::Boolean SALOMEDS_AttributeParameter_i::HasFather()
297 {
298   SALOMEDS::Locker lock; 
299   return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->HasFather();
300 }
301
302 //=======================================================================
303 /*!
304  * Function : IsRoot
305  * Purpose  : Returns True is the attribute is highest in an hierachy
306  */
307 //=======================================================================
308 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsRoot()
309 {
310   SALOMEDS::Locker lock; 
311   return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsRoot();
312 }
313
314 //=======================================================================
315 /*!
316  * Function : IsRoot
317  * Purpose  : Clears the content of the attribute
318  */
319 //=======================================================================
320 void SALOMEDS_AttributeParameter_i::Clear()
321 {
322   SALOMEDS::Locker lock; 
323   dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->Clear();
324 }
325
326
327 //=======================================================================
328 /*!
329  * Function : GetIDs
330  * Purpose  : Returns an array of all ID's of the given type
331  */
332 //=======================================================================
333 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetIDs(CORBA::Long theType)
334 {
335   SALOMEDS::Locker lock; 
336   SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
337   vector<string> A = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetIDs((Parameter_Types)theType);
338
339   if(A.size()) {
340     int length = A.size();
341     CorbaSeq->length(length);
342     for (int i = 0; i < length; i++) CorbaSeq[i] = CORBA::string_dup(A[i].c_str());;
343   }
344
345   return CorbaSeq._retn();
346 }