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_AttributeParameter_i.cxx
21 // Author : Sergey RUIN
25 #include "SALOMEDS_AttributeParameter_i.hxx"
26 #include "SALOMEDS.hxx"
32 //=======================================================================
35 * Purpose : Associates a integer value with the ID
37 //=======================================================================
38 void SALOMEDS_AttributeParameter_i::SetInt(const char* theID, CORBA::Long theValue)
40 SALOMEDS::Locker lock;
42 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetInt(theID, theValue);
45 //=======================================================================
48 * Purpose : Returns a int value associated with the given ID
50 //=======================================================================
51 CORBA::Long SALOMEDS_AttributeParameter_i::GetInt(const char* theID)
53 SALOMEDS::Locker lock;
54 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetInt(theID);
57 //=======================================================================
60 * Purpose : Associates a double value with the ID
62 //=======================================================================
63 void SALOMEDS_AttributeParameter_i::SetReal(const char* theID, CORBA::Double theValue)
65 SALOMEDS::Locker lock;
67 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetReal(theID, theValue);
70 //=======================================================================
73 * Purpose : Returns a double value associated with the given ID
75 //=======================================================================
76 CORBA::Double SALOMEDS_AttributeParameter_i::GetReal(const char* theID)
78 SALOMEDS::Locker lock;
79 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetReal(theID);
82 //=======================================================================
84 * Function : SetString
85 * Purpose : Associates a string with the ID
87 //=======================================================================
88 void SALOMEDS_AttributeParameter_i::SetString(const char* theID, const char* theValue)
90 SALOMEDS::Locker lock;
92 SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
93 impl->SetString(theID, theValue);
96 //=======================================================================
98 * Function : GetString
99 * Purpose : Returns a string associated with the given ID
101 //=======================================================================
102 char* SALOMEDS_AttributeParameter_i::GetString(const char* theID)
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());
110 //=======================================================================
113 * Purpose : Associates a bool value with the ID
115 //=======================================================================
116 void SALOMEDS_AttributeParameter_i::SetBool(const char* theID, CORBA::Boolean theValue)
118 SALOMEDS::Locker lock;
120 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetBool(theID, theValue);
123 //=======================================================================
126 * Purpose : Returns a bool value associated with the ID
128 //=======================================================================
129 CORBA::Boolean SALOMEDS_AttributeParameter_i::GetBool(const char* theID)
131 SALOMEDS::Locker lock;
132 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetBool(theID);
135 //=======================================================================
137 * Function : SetRealArray
138 * Purpose : Associates an array of double values with the given ID
140 //=======================================================================
141 void SALOMEDS_AttributeParameter_i::SetRealArray(const char* theID, const SALOMEDS::DoubleSeq& theArray)
143 SALOMEDS::Locker lock;
146 int length = theArray.length();
149 for(int i = 0; i<length; i++) v[i] = theArray[i];
151 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetRealArray(theID, v);
154 //=======================================================================
156 * Function : GetRealArray
157 * Purpose : Returns an array of double values associated with the ID
159 //=======================================================================
160 SALOMEDS::DoubleSeq* SALOMEDS_AttributeParameter_i::GetRealArray(const char* theID)
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();
167 aSeq->length(length);
168 for(int i = 0; i<length; i++) aSeq[i] = v[i];
173 //=======================================================================
175 * Function : SetIntArray
176 * Purpose : Associates an array of int values with the given ID
178 //=======================================================================
179 void SALOMEDS_AttributeParameter_i::SetIntArray(const char* theID, const SALOMEDS::LongSeq& theArray)
181 SALOMEDS::Locker lock;
184 int length = theArray.length();
187 for(int i = 0; i<length; i++) v[i] = theArray[i];
189 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetIntArray(theID, v);
192 //=======================================================================
194 * Function : GetIntArray
195 * Purpose : Returns an array of int values associated with the ID
197 //=======================================================================
198 SALOMEDS::LongSeq* SALOMEDS_AttributeParameter_i::GetIntArray(const char* theID)
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();
205 aSeq->length(length);
206 for(int i = 0; i<length; i++) aSeq[i] = v[i];
211 //=======================================================================
213 * Function : SetStrArray
214 * Purpose : Associates an array of string values with the given ID
216 //=======================================================================
217 void SALOMEDS_AttributeParameter_i::SetStrArray(const char* theID, const SALOMEDS::StringSeq& theArray)
219 SALOMEDS::Locker lock;
222 int length = theArray.length();
225 for(int i = 0; i<length; i++) v[i] = string(theArray[i].in());
227 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetStrArray(theID, v);
230 //=======================================================================
232 * Function : GetStrArray
233 * Purpose : Returns an array of string values associated with the ID
235 //=======================================================================
236 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetStrArray(const char* theID)
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();
243 aSeq->length(length);
244 for(int i = 0; i<length; i++) aSeq[i] = CORBA::string_dup(v[i].c_str());
250 //=======================================================================
253 * Purpose : Returns true if for the ID of given type was assigned \n
254 * a value in the attribute
256 //=======================================================================
257 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsSet(const char* theID, CORBA::Long theType)
259 SALOMEDS::Locker lock;
260 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsSet(theID, (Parameter_Types)theType);
263 //=======================================================================
265 * Function : RemoveID
266 * Purpose : Removes a parameter with given ID
268 //=======================================================================
269 CORBA::Boolean SALOMEDS_AttributeParameter_i::RemoveID(const char* theID, CORBA::Long theType)
271 SALOMEDS::Locker lock;
273 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->RemoveID(theID, (Parameter_Types)theType);
276 //=======================================================================
278 * Function : GetFather
279 * Purpose : Returns a father attribute for this attribute
281 //=======================================================================
282 SALOMEDS::AttributeParameter_ptr SALOMEDS_AttributeParameter_i::GetFather()
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();
290 //=======================================================================
292 * Function : HasFather
293 * Purpose : Returns True if the attribute has a father attribute
295 //=======================================================================
296 CORBA::Boolean SALOMEDS_AttributeParameter_i::HasFather()
298 SALOMEDS::Locker lock;
299 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->HasFather();
302 //=======================================================================
305 * Purpose : Returns True is the attribute is highest in an hierachy
307 //=======================================================================
308 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsRoot()
310 SALOMEDS::Locker lock;
311 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsRoot();
314 //=======================================================================
317 * Purpose : Clears the content of the attribute
319 //=======================================================================
320 void SALOMEDS_AttributeParameter_i::Clear()
322 SALOMEDS::Locker lock;
323 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->Clear();
327 //=======================================================================
330 * Purpose : Returns an array of all ID's of the given type
332 //=======================================================================
333 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetIDs(CORBA::Long theType)
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);
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());;
345 return CorbaSeq._retn();