1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, 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)
55 throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
57 SALOMEDS::Locker lock;
58 Unexpect aCatch (AP_InvalidIdentifier);
59 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetInt(theID);
62 //=======================================================================
65 * Purpose : Associates a double value with the ID
67 //=======================================================================
68 void SALOMEDS_AttributeParameter_i::SetReal(const char* theID, CORBA::Double theValue)
70 SALOMEDS::Locker lock;
72 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetReal(theID, theValue);
75 //=======================================================================
78 * Purpose : Returns a double value associated with the given ID
80 //=======================================================================
81 CORBA::Double SALOMEDS_AttributeParameter_i::GetReal(const char* theID)
82 throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
84 SALOMEDS::Locker lock;
85 Unexpect aCatch (AP_InvalidIdentifier);
86 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetReal(theID);
89 //=======================================================================
91 * Function : SetString
92 * Purpose : Associates a string with the ID
94 //=======================================================================
95 void SALOMEDS_AttributeParameter_i::SetString(const char* theID, const char* theValue)
97 SALOMEDS::Locker lock;
99 SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
100 impl->SetString(theID, theValue);
103 //=======================================================================
105 * Function : GetString
106 * Purpose : Returns a string associated with the given ID
108 //=======================================================================
109 char* SALOMEDS_AttributeParameter_i::GetString(const char* theID)
110 throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
112 SALOMEDS::Locker lock;
113 Unexpect aCatch (AP_InvalidIdentifier);
114 SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
115 CORBA::String_var c_s = CORBA::string_dup(impl->GetString(theID).c_str());
119 //=======================================================================
122 * Purpose : Associates a bool value with the ID
124 //=======================================================================
125 void SALOMEDS_AttributeParameter_i::SetBool(const char* theID, CORBA::Boolean theValue)
127 SALOMEDS::Locker lock;
129 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetBool(theID, theValue);
132 //=======================================================================
135 * Purpose : Returns a bool value associated with the ID
137 //=======================================================================
138 CORBA::Boolean SALOMEDS_AttributeParameter_i::GetBool(const char* theID)
139 throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
141 SALOMEDS::Locker lock;
142 Unexpect aCatch (AP_InvalidIdentifier);
143 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetBool(theID);
146 //=======================================================================
148 * Function : SetRealArray
149 * Purpose : Associates an array of double values with the given ID
151 //=======================================================================
152 void SALOMEDS_AttributeParameter_i::SetRealArray(const char* theID, const SALOMEDS::DoubleSeq& theArray)
154 SALOMEDS::Locker lock;
156 std::vector<double> v;
157 int length = theArray.length();
160 for(int i = 0; i<length; i++) v[i] = theArray[i];
162 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetRealArray(theID, v);
165 //=======================================================================
167 * Function : GetRealArray
168 * Purpose : Returns an array of double values associated with the ID
170 //=======================================================================
171 SALOMEDS::DoubleSeq* SALOMEDS_AttributeParameter_i::GetRealArray(const char* theID)
172 throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
174 SALOMEDS::Locker lock;
175 Unexpect aCatch (AP_InvalidIdentifier);
176 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq;
177 std::vector<double> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetRealArray(theID);
178 int length = v.size();
180 aSeq->length(length);
181 for(int i = 0; i<length; i++) aSeq[i] = v[i];
186 //=======================================================================
188 * Function : SetIntArray
189 * Purpose : Associates an array of int values with the given ID
191 //=======================================================================
192 void SALOMEDS_AttributeParameter_i::SetIntArray(const char* theID, const SALOMEDS::LongSeq& theArray)
194 SALOMEDS::Locker lock;
197 int length = theArray.length();
200 for(int i = 0; i<length; i++) v[i] = theArray[i];
202 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetIntArray(theID, v);
205 //=======================================================================
207 * Function : GetIntArray
208 * Purpose : Returns an array of int values associated with the ID
210 //=======================================================================
211 SALOMEDS::LongSeq* SALOMEDS_AttributeParameter_i::GetIntArray(const char* theID)
212 throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
214 SALOMEDS::Locker lock;
215 Unexpect aCatch (AP_InvalidIdentifier);
216 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq;
217 std::vector<int> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetIntArray(theID);
218 int length = v.size();
220 aSeq->length(length);
221 for(int i = 0; i<length; i++) aSeq[i] = v[i];
226 //=======================================================================
228 * Function : SetStrArray
229 * Purpose : Associates an array of string values with the given ID
231 //=======================================================================
232 void SALOMEDS_AttributeParameter_i::SetStrArray(const char* theID, const SALOMEDS::StringSeq& theArray)
234 SALOMEDS::Locker lock;
236 std::vector<std::string> v;
237 int length = theArray.length();
240 for(int i = 0; i<length; i++) v[i] = std::string(theArray[i].in());
242 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetStrArray(theID, v);
245 //=======================================================================
247 * Function : GetStrArray
248 * Purpose : Returns an array of string values associated with the ID
250 //=======================================================================
251 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetStrArray(const char* theID)
252 throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
254 SALOMEDS::Locker lock;
255 Unexpect aCatch (AP_InvalidIdentifier);
256 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq;
257 std::vector<std::string> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetStrArray(theID);
258 int length = v.size();
260 aSeq->length(length);
261 for(int i = 0; i<length; i++) aSeq[i] = CORBA::string_dup(v[i].c_str());
267 //=======================================================================
270 * Purpose : Returns true if for the ID of given type was assigned \n
271 * a value in the attribute
273 //=======================================================================
274 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsSet(const char* theID, CORBA::Long theType)
276 SALOMEDS::Locker lock;
277 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsSet(theID, (Parameter_Types)theType);
280 //=======================================================================
282 * Function : RemoveID
283 * Purpose : Removes a parameter with given ID
285 //=======================================================================
286 CORBA::Boolean SALOMEDS_AttributeParameter_i::RemoveID(const char* theID, CORBA::Long theType)
288 SALOMEDS::Locker lock;
290 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->RemoveID(theID, (Parameter_Types)theType);
293 //=======================================================================
295 * Function : GetFather
296 * Purpose : Returns a father attribute for this attribute
298 //=======================================================================
299 SALOMEDS::AttributeParameter_ptr SALOMEDS_AttributeParameter_i::GetFather()
301 SALOMEDS::Locker lock;
302 SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
303 SALOMEDS_AttributeParameter_i* attr = new SALOMEDS_AttributeParameter_i(impl, _orb);
304 return attr->AttributeParameter::_this();
307 //=======================================================================
309 * Function : HasFather
310 * Purpose : Returns True if the attribute has a father attribute
312 //=======================================================================
313 CORBA::Boolean SALOMEDS_AttributeParameter_i::HasFather()
315 SALOMEDS::Locker lock;
316 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->HasFather();
319 //=======================================================================
322 * Purpose : Returns True is the attribute is highest in an hierarchy
324 //=======================================================================
325 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsRoot()
327 SALOMEDS::Locker lock;
328 return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsRoot();
331 //=======================================================================
334 * Purpose : Clears the content of the attribute
336 //=======================================================================
337 void SALOMEDS_AttributeParameter_i::Clear()
339 SALOMEDS::Locker lock;
340 dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->Clear();
344 //=======================================================================
347 * Purpose : Returns an array of all ID's of the given type
349 //=======================================================================
350 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetIDs(CORBA::Long theType)
352 SALOMEDS::Locker lock;
353 SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
354 std::vector<std::string> A = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetIDs((Parameter_Types)theType);
357 int length = A.size();
358 CorbaSeq->length(length);
359 for (int i = 0; i < length; i++) CorbaSeq[i] = CORBA::string_dup(A[i].c_str());;
362 return CorbaSeq._retn();