1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_AttributeParameter_i.cxx
24 // Author : Sergey RUIN
27 #include "SALOMEDS_AttributeParameter_i.hxx"
28 #include "SALOMEDS.hxx"
32 #include "Utils_ExceptHandlers.hxx"
33 UNEXPECT_CATCH(AP_InvalidIdentifier, SALOMEDS::AttributeParameter::InvalidIdentifier)
35 //=======================================================================
38 * Purpose : Associates a integer value with the ID
40 //=======================================================================
41 void SALOMEDS_AttributeParameter_i::SetInt(const char* theID, CORBA::Long theValue)
43 SALOMEDS::Locker lock;
45 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetInt(theID, theValue);
48 //=======================================================================
51 * Purpose : Returns a int value associated with the given ID
53 //=======================================================================
54 CORBA::Long SALOMEDS_AttributeParameter_i::GetInt(const char* theID)
56 SALOMEDS::Locker lock;
57 Unexpect aCatch (AP_InvalidIdentifier);
58 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetInt(theID);
61 //=======================================================================
64 * Purpose : Associates a double value with the ID
66 //=======================================================================
67 void SALOMEDS_AttributeParameter_i::SetReal(const char* theID, CORBA::Double theValue)
69 SALOMEDS::Locker lock;
71 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetReal(theID, theValue);
74 //=======================================================================
77 * Purpose : Returns a double value associated with the given ID
79 //=======================================================================
80 CORBA::Double SALOMEDS_AttributeParameter_i::GetReal(const char* theID)
82 SALOMEDS::Locker lock;
83 Unexpect aCatch (AP_InvalidIdentifier);
84 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetReal(theID);
87 //=======================================================================
89 * Function : SetString
90 * Purpose : Associates a string with the ID
92 //=======================================================================
93 void SALOMEDS_AttributeParameter_i::SetString(const char* theID, const char* theValue)
95 SALOMEDS::Locker lock;
97 SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
98 impl->SetString(theID, theValue);
101 //=======================================================================
103 * Function : GetString
104 * Purpose : Returns a string associated with the given ID
106 //=======================================================================
107 char* SALOMEDS_AttributeParameter_i::GetString(const char* theID)
109 SALOMEDS::Locker lock;
110 Unexpect aCatch (AP_InvalidIdentifier);
111 SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
112 CORBA::String_var c_s = CORBA::string_dup(impl->GetString(theID).c_str());
116 //=======================================================================
119 * Purpose : Associates a bool value with the ID
121 //=======================================================================
122 void SALOMEDS_AttributeParameter_i::SetBool(const char* theID, CORBA::Boolean theValue)
124 SALOMEDS::Locker lock;
126 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetBool(theID, theValue);
129 //=======================================================================
132 * Purpose : Returns a bool value associated with the ID
134 //=======================================================================
135 CORBA::Boolean SALOMEDS_AttributeParameter_i::GetBool(const char* theID)
137 SALOMEDS::Locker lock;
138 Unexpect aCatch (AP_InvalidIdentifier);
139 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetBool(theID);
142 //=======================================================================
144 * Function : SetRealArray
145 * Purpose : Associates an array of double values with the given ID
147 //=======================================================================
148 void SALOMEDS_AttributeParameter_i::SetRealArray(const char* theID, const SALOMEDS::DoubleSeq& theArray)
150 SALOMEDS::Locker lock;
152 std::vector<double> v;
153 int length = theArray.length();
156 for(int i = 0; i<length; i++) v[i] = theArray[i];
158 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetRealArray(theID, v);
161 //=======================================================================
163 * Function : GetRealArray
164 * Purpose : Returns an array of double values associated with the ID
166 //=======================================================================
167 SALOMEDS::DoubleSeq* SALOMEDS_AttributeParameter_i::GetRealArray(const char* theID)
169 SALOMEDS::Locker lock;
170 Unexpect aCatch (AP_InvalidIdentifier);
171 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq;
172 std::vector<double> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetRealArray(theID);
173 int length = (int)v.size(); //!< TODO: conversion from size_t to int
175 aSeq->length(length);
176 for(int i = 0; i<length; i++) aSeq[i] = v[i];
181 //=======================================================================
183 * Function : SetIntArray
184 * Purpose : Associates an array of int values with the given ID
186 //=======================================================================
187 void SALOMEDS_AttributeParameter_i::SetIntArray(const char* theID, const SALOMEDS::LongSeq& theArray)
189 SALOMEDS::Locker lock;
192 int length = theArray.length();
195 for(int i = 0; i<length; i++) v[i] = theArray[i];
197 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetIntArray(theID, v);
200 //=======================================================================
202 * Function : GetIntArray
203 * Purpose : Returns an array of int values associated with the ID
205 //=======================================================================
206 SALOMEDS::LongSeq* SALOMEDS_AttributeParameter_i::GetIntArray(const char* theID)
208 SALOMEDS::Locker lock;
209 Unexpect aCatch (AP_InvalidIdentifier);
210 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq;
211 std::vector<int> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetIntArray(theID);
212 int length = (int)v.size(); //!< TODO: conversion from size_t to int
214 aSeq->length(length);
215 for(int i = 0; i<length; i++) aSeq[i] = v[i];
220 //=======================================================================
222 * Function : SetStrArray
223 * Purpose : Associates an array of string values with the given ID
225 //=======================================================================
226 void SALOMEDS_AttributeParameter_i::SetStrArray(const char* theID, const SALOMEDS::StringSeq& theArray)
228 SALOMEDS::Locker lock;
230 std::vector<std::string> v;
231 int length = theArray.length();
234 for(int i = 0; i<length; i++) v[i] = std::string(theArray[i].in());
236 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetStrArray(theID, v);
239 //=======================================================================
241 * Function : GetStrArray
242 * Purpose : Returns an array of string values associated with the ID
244 //=======================================================================
245 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetStrArray(const char* theID)
247 SALOMEDS::Locker lock;
248 Unexpect aCatch (AP_InvalidIdentifier);
249 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq;
250 std::vector<std::string> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetStrArray(theID);
251 int length = (int)v.size(); //!< TODO: conversion from size_t to int
253 aSeq->length(length);
254 for(int i = 0; i<length; i++) aSeq[i] = CORBA::string_dup(v[i].c_str());
260 //=======================================================================
263 * Purpose : Returns true if for the ID of given type was assigned \n
264 * a value in the attribute
266 //=======================================================================
267 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsSet(const char* theID, CORBA::Long theType)
269 SALOMEDS::Locker lock;
270 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsSet(theID, (Parameter_Types)theType);
273 //=======================================================================
275 * Function : RemoveID
276 * Purpose : Removes a parameter with given ID
278 //=======================================================================
279 CORBA::Boolean SALOMEDS_AttributeParameter_i::RemoveID(const char* theID, CORBA::Long theType)
281 SALOMEDS::Locker lock;
283 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->RemoveID(theID, (Parameter_Types)theType);
286 //=======================================================================
288 * Function : GetFather
289 * Purpose : Returns a father attribute for this attribute
291 //=======================================================================
292 SALOMEDS::AttributeParameter_ptr SALOMEDS_AttributeParameter_i::GetFather()
294 SALOMEDS::Locker lock;
295 SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
296 SALOMEDS_AttributeParameter_i* attr = new SALOMEDS_AttributeParameter_i(impl, _orb);
297 return attr->AttributeParameter::_this();
300 //=======================================================================
302 * Function : HasFather
303 * Purpose : Returns True if the attribute has a father attribute
305 //=======================================================================
306 CORBA::Boolean SALOMEDS_AttributeParameter_i::HasFather()
308 SALOMEDS::Locker lock;
309 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->HasFather();
312 //=======================================================================
315 * Purpose : Returns True is the attribute is highest in an hierarchy
317 //=======================================================================
318 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsRoot()
320 SALOMEDS::Locker lock;
321 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsRoot();
324 //=======================================================================
327 * Purpose : Clears the content of the attribute
329 //=======================================================================
330 void SALOMEDS_AttributeParameter_i::Clear()
332 SALOMEDS::Locker lock;
333 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->Clear();
337 //=======================================================================
340 * Purpose : Returns an array of all ID's of the given type
342 //=======================================================================
343 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetIDs(CORBA::Long theType)
345 SALOMEDS::Locker lock;
346 SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
347 std::vector<std::string> A = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetIDs((Parameter_Types)theType);
350 int length = (int)A.size(); //!< TODO: conversion from size_t to int
351 CorbaSeq->length(length);
352 for (int i = 0; i < length; i++) CorbaSeq[i] = CORBA::string_dup(A[i].c_str());;
355 return CorbaSeq._retn();