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/
20 // File : SALOMEDS_AttributeParameter_i.cxx
21 // Author : Sergey RUIN
25 #include "SALOMEDS_AttributeParameter_i.hxx"
26 #include "SALOMEDS.hxx"
27 #include <TCollection_AsciiString.hxx>
33 //=======================================================================
36 * Purpose : Associates a integer value with the ID
38 //=======================================================================
39 void SALOMEDS_AttributeParameter_i::SetInt(const char* theID, CORBA::Long theValue)
41 SALOMEDS::Locker lock;
43 Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetInt(theID, theValue);
46 //=======================================================================
49 * Purpose : Returns a int value associated with the given ID
51 //=======================================================================
52 CORBA::Long SALOMEDS_AttributeParameter_i::GetInt(const char* theID)
54 SALOMEDS::Locker lock;
55 return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetInt(theID);
58 //=======================================================================
61 * Purpose : Associates a double value with the ID
63 //=======================================================================
64 void SALOMEDS_AttributeParameter_i::SetReal(const char* theID, const CORBA::Double theValue)
66 SALOMEDS::Locker lock;
68 Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetReal(theID, theValue);
71 //=======================================================================
74 * Purpose : Returns a double value associated with the given ID
76 //=======================================================================
77 CORBA::Double SALOMEDS_AttributeParameter_i::GetReal(const char* theID)
79 SALOMEDS::Locker lock;
80 return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetReal(theID);
83 //=======================================================================
85 * Function : SetString
86 * Purpose : Associates a string with the ID
88 //=======================================================================
89 void SALOMEDS_AttributeParameter_i::SetString(const char* theID, const char* theValue)
91 SALOMEDS::Locker lock;
93 Handle(SALOMEDSImpl_AttributeParameter) impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl);
94 impl->SetString(theID, theValue);
97 //=======================================================================
99 * Function : GetString
100 * Purpose : Returns a string associated with the given ID
102 //=======================================================================
103 char* SALOMEDS_AttributeParameter_i::GetString(const char* theID)
105 SALOMEDS::Locker lock;
106 Handle(SALOMEDSImpl_AttributeParameter) impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl);
107 CORBA::String_var c_s = CORBA::string_dup(impl->GetString(theID).c_str());
111 //=======================================================================
114 * Purpose : Associates a bool value with the ID
116 //=======================================================================
117 void SALOMEDS_AttributeParameter_i::SetBool(const char* theID, CORBA::Boolean theValue)
119 SALOMEDS::Locker lock;
121 Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetBool(theID, theValue);
124 //=======================================================================
127 * Purpose : Returns a bool value associated with the ID
129 //=======================================================================
130 CORBA::Boolean SALOMEDS_AttributeParameter_i::GetBool(const char* theID)
132 SALOMEDS::Locker lock;
133 return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetBool(theID);
136 //=======================================================================
138 * Function : SetRealArray
139 * Purpose : Associates an array of double values with the given ID
141 //=======================================================================
142 void SALOMEDS_AttributeParameter_i::SetRealArray(const char* theID, const SALOMEDS::DoubleSeq& theArray)
144 SALOMEDS::Locker lock;
147 int length = theArray.length();
150 for(int i = 0; i<length; i++) v[i] = theArray[i];
152 Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetRealArray(theID, v);
155 //=======================================================================
157 * Function : GetRealArray
158 * Purpose : Returns an array of double values associated with the ID
160 //=======================================================================
161 SALOMEDS::DoubleSeq* SALOMEDS_AttributeParameter_i::GetRealArray(const char* theID)
163 SALOMEDS::Locker lock;
164 SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq;
165 vector<double> v = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetRealArray(theID);
166 int length = v.size();
168 aSeq->length(length);
169 for(int i = 0; i<length; i++) aSeq[i] = v[i];
174 //=======================================================================
176 * Function : SetIntArray
177 * Purpose : Associates an array of int values with the given ID
179 //=======================================================================
180 void SALOMEDS_AttributeParameter_i::SetIntArray(const char* theID, const SALOMEDS::LongSeq& theArray)
182 SALOMEDS::Locker lock;
185 int length = theArray.length();
188 for(int i = 0; i<length; i++) v[i] = theArray[i];
190 Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetIntArray(theID, v);
193 //=======================================================================
195 * Function : GetIntArray
196 * Purpose : Returns an array of int values associated with the ID
198 //=======================================================================
199 SALOMEDS::LongSeq* SALOMEDS_AttributeParameter_i::GetIntArray(const char* theID)
201 SALOMEDS::Locker lock;
202 SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq;
203 vector<int> v = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetIntArray(theID);
204 int length = v.size();
206 aSeq->length(length);
207 for(int i = 0; i<length; i++) aSeq[i] = v[i];
212 //=======================================================================
214 * Function : SetStrArray
215 * Purpose : Associates an array of string values with the given ID
217 //=======================================================================
218 void SALOMEDS_AttributeParameter_i::SetStrArray(const char* theID, const SALOMEDS::StringSeq& theArray)
220 SALOMEDS::Locker lock;
223 int length = theArray.length();
226 for(int i = 0; i<length; i++) v[i] = string(theArray[i].in());
228 Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetStrArray(theID, v);
231 //=======================================================================
233 * Function : GetStrArray
234 * Purpose : Returns an array of string values associated with the ID
236 //=======================================================================
237 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetStrArray(const char* theID)
239 SALOMEDS::Locker lock;
240 SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq;
241 vector<string> v = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetStrArray(theID);
242 int length = v.size();
244 aSeq->length(length);
245 for(int i = 0; i<length; i++) aSeq[i] = CORBA::string_dup(v[i].c_str());
251 //=======================================================================
254 * Purpose : Returns true if for the ID of given type was assigned \n
255 * a value in the attribute
257 //=======================================================================
258 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsSet(const char* theID, CORBA::Long theType)
260 SALOMEDS::Locker lock;
261 return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->IsSet(theID, (Parameter_Types)theType);
264 //=======================================================================
266 * Function : RemoveID
267 * Purpose : Removes a parameter with given ID
269 //=======================================================================
270 CORBA::Boolean SALOMEDS_AttributeParameter_i::RemoveID(const char* theID, CORBA::Long theType)
272 SALOMEDS::Locker lock;
274 return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->RemoveID(theID, (Parameter_Types)theType);
277 //=======================================================================
279 * Function : GetFather
280 * Purpose : Returns a father attribute for this attribute
282 //=======================================================================
283 SALOMEDS::AttributeParameter_ptr SALOMEDS_AttributeParameter_i::GetFather()
285 SALOMEDS::Locker lock;
286 Handle(SALOMEDSImpl_AttributeParameter) impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl);
287 SALOMEDS_AttributeParameter_i* attr = new SALOMEDS_AttributeParameter_i(impl, _orb);
288 return attr->AttributeParameter::_this();
291 //=======================================================================
293 * Function : HasFather
294 * Purpose : Returns True if the attribute has a father attribute
296 //=======================================================================
297 CORBA::Boolean SALOMEDS_AttributeParameter_i::HasFather()
299 SALOMEDS::Locker lock;
300 return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->HasFather();
303 //=======================================================================
306 * Purpose : Returns True is the attribute is highest in an hierachy
308 //=======================================================================
309 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsRoot()
311 SALOMEDS::Locker lock;
312 return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->IsRoot();
315 //=======================================================================
318 * Purpose : Clears the content of the attribute
320 //=======================================================================
321 void SALOMEDS_AttributeParameter_i::Clear()
323 SALOMEDS::Locker lock;
324 Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->Clear();
328 //=======================================================================
331 * Purpose : Returns an array of all ID's of the given type
333 //=======================================================================
334 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetIDs(CORBA::Long theType)
336 SALOMEDS::Locker lock;
337 SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
338 vector<string> A = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetIDs((Parameter_Types)theType);
341 int length = A.size();
342 CorbaSeq->length(length);
343 for (int i = 0; i < length; i++) CorbaSeq[i] = CORBA::string_dup(A[i].c_str());;
346 return CorbaSeq._retn();