Salome HOME
updating the main trunk with the CEA debug devellopment from the branch
[modules/med.git] / src / MEDMEM_I / MEDMEM_Family_i.cxx
1 //=============================================================================
2 // File      :  MEDMEM_Family_i.cxx
3 // Project   :  SALOME
4 // Copyright :  EDF 2002
5 // Author    :  EDF
6 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Family_i.cxx
7 //=============================================================================
8
9 #include "utilities.h"
10 #include "Utils_CorbaException.hxx"
11 #include "MEDMEM_Family_i.hxx"
12 #include "MEDMEM_Family.hxx"
13 using namespace MEDMEM;
14
15 //=============================================================================
16 /*!
17  * Default constructor
18  */
19 //=============================================================================
20 FAMILY_i::FAMILY_i(): _family((::FAMILY*)NULL),
21                                 SUPPORT_i()
22 {
23         BEGIN_OF("Default Constructor FAMILY_i");
24         END_OF("Default Constructor FAMILY_i");
25 }
26 //=============================================================================
27 /*!
28  * Copy Constructor 
29  */
30 //=============================================================================
31 FAMILY_i::FAMILY_i(const FAMILY_i & f): _family(f._family),
32                                         SUPPORT_i(f._family)
33 {
34         BEGIN_OF("Default Constructor FAMILY_i");
35         END_OF("Default Constructor FAMILY_i");
36 }
37 //=============================================================================
38 /*!
39  * Destructor
40  */
41 //=============================================================================
42 FAMILY_i::~FAMILY_i()
43 {
44 }
45 //=============================================================================
46 /*!
47  * Constructor
48  */
49 //=============================================================================
50 FAMILY_i::FAMILY_i(const ::FAMILY * const f): _family(f),
51                                               SUPPORT_i(f)
52 {
53         BEGIN_OF("Constructor FAMILY_i");
54         END_OF("Constructor FAMILY_i");
55 }
56 //=============================================================================
57 /*!
58  * CORBA: Accessor for Family's Identifier
59  */
60 //=============================================================================
61
62 CORBA::Long FAMILY_i::getIdentifier()      
63 throw (SALOME::SALOME_Exception)
64 {
65         if (_family==NULL)
66                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
67                                              SALOME::INTERNAL_ERROR); 
68         try
69         {
70                 return _family->getIdentifier();
71         }
72         catch(MEDEXCEPTION &ex)
73         {
74                 MESSAGE("Unable to acces Family Identifier");
75                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
76         }
77
78 }
79 //=============================================================================
80 /*!
81  * CORBA: Accessor for number of attributes
82  */
83 //=============================================================================
84 CORBA::Long FAMILY_i::getNumberOfAttributes() 
85 throw (SALOME::SALOME_Exception)
86 {
87         if (_family==NULL)
88                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
89                                              SALOME::INTERNAL_ERROR);
90         try
91         {
92                 return _family->getNumberOfAttributes();
93         }
94         catch(MEDEXCEPTION &ex)
95         {
96                 MESSAGE("Unable to get number of attributes");
97                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
98         }
99 }
100 //=============================================================================
101 /*!
102  * CORBA: Accessor for attributes identifiers
103  */
104 //=============================================================================
105 SALOME_MED::long_array*  FAMILY_i::getAttributesIdentifiers() 
106 throw (SALOME::SALOME_Exception)
107 {
108         if (_family==NULL)
109                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
110                                              SALOME::INTERNAL_ERROR);
111         SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
112         try
113         {
114                 int nbAttribute=_family->getNumberOfAttributes();
115                 myseq->length(nbAttribute);
116                 int * identifiers=_family->getAttributesIdentifiers();
117                 for (int i=0;i<nbAttribute;i++)
118                 {
119                         myseq[i]=identifiers[i];
120                 }
121         }
122         catch(MEDEXCEPTION &ex)
123         {
124                 MESSAGE("Unable to acces Family Identifiers");
125                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
126         }
127         return myseq._retn();
128 }
129 //=============================================================================
130 /*!
131  * CORBA: Accessor for attribute identifier I
132  */
133 //=============================================================================
134 CORBA::Long FAMILY_i::getAttributeIdentifier(CORBA::Long i) 
135 throw (SALOME::SALOME_Exception)
136 {    
137         if (_family==NULL)
138                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
139                                              SALOME::INTERNAL_ERROR);
140         try
141         {
142                 return _family->getAttributeIdentifier(i);
143         }
144         catch(MEDEXCEPTION &ex)
145         {
146                 MESSAGE("Unable to acces Family Identifier");
147                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
148         }
149  
150 }
151 //=============================================================================
152 /*!
153  * CORBA: Accessor for attributes values
154  */
155 //=============================================================================
156 SALOME_MED::long_array*  FAMILY_i::getAttributesValues() 
157 throw (SALOME::SALOME_Exception)
158 {
159         if (_family==NULL)
160                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
161                                              SALOME::INTERNAL_ERROR);
162         SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
163         try
164         {
165                 int nbAttribute=_family->getNumberOfAttributes();
166                 myseq->length(nbAttribute);
167                 int * values=_family->getAttributesValues();
168                 for (int i=0;i<nbAttribute;i++)
169                 {
170                         myseq[i]=values[i];
171                 }
172         }
173         catch(MEDEXCEPTION &ex)
174         {
175                 MESSAGE("Unable to acces attributs values");
176                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
177         }
178         return myseq._retn();
179 }
180 //=============================================================================
181 /*!
182  * CORBA: Accessor for attribute value I
183  */
184 //=============================================================================
185 CORBA::Long  FAMILY_i::getAttributeValue(CORBA::Long i) 
186 throw (SALOME::SALOME_Exception)
187 {   
188         if (_family==NULL)
189                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
190                                              SALOME::INTERNAL_ERROR);
191         try
192         {
193                 return _family->getAttributeValue(i);
194         }
195         catch(MEDEXCEPTION &ex)
196         {
197                 MESSAGE("Unable to acces specified attribut value");
198                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
199         }
200 }
201 //=============================================================================
202 /*!
203  * CORBA: Accessor for attributes desriptions
204  */
205 //=============================================================================
206 SALOME_MED::string_array * FAMILY_i::getAttributesDescriptions() 
207 throw (SALOME::SALOME_Exception)
208 {
209         if (_family==NULL)
210                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
211                                              SALOME::INTERNAL_ERROR);
212         
213         SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
214         try
215         {
216                 int nbAttribute=_family->getNumberOfAttributes();
217                 myseq->length(nbAttribute);
218                 string * descattribute=_family->getAttributesDescriptions();
219                 for (int i=0;i<nbAttribute;i++)
220                 {
221                         myseq[i]=CORBA::string_dup(descattribute[i].c_str());
222                 }
223         }
224         catch(MEDEXCEPTION &ex)
225         {
226                 MESSAGE("Unable to acces attributs descriptions");
227                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
228         }
229         return myseq._retn();
230
231 }
232 //=============================================================================
233 /*!
234  * CORBA: Accessor for attribute description i
235  */
236 //=============================================================================
237 char *  FAMILY_i::getAttributeDescription( CORBA::Long i) 
238 throw (SALOME::SALOME_Exception)
239 {   
240         if (_family==NULL)
241                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
242                                              SALOME::INTERNAL_ERROR);
243         try
244         {
245                 return CORBA::string_dup(_family->getAttributeDescription(i).c_str());
246         }
247         catch(MEDEXCEPTION &ex)
248         {
249                 MESSAGE("Unable to acces specified attribut description");
250                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
251         }
252 }
253
254 //=============================================================================
255 /*!
256  * CORBA: Accessor for number of groups the family belongs to
257  */
258 //=============================================================================
259 CORBA::Long  FAMILY_i::getNumberOfGroups()
260 throw (SALOME::SALOME_Exception)
261 {
262         if (_family==NULL)
263                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
264                                              SALOME::INTERNAL_ERROR);
265         try
266         {
267                 return _family->getNumberOfGroups();
268         }
269         catch (MEDEXCEPTION &ex)
270         {
271                 MESSAGE("Unable to acces specified attribut value");
272                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
273         }
274 }
275 //=============================================================================
276 /*!
277  * CORBA: Accessor for groups names
278  */
279 //=============================================================================
280 SALOME_MED::string_array * FAMILY_i::getGroupsNames()
281 throw (SALOME::SALOME_Exception)
282 {
283         if (_family==NULL)
284                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
285                                              SALOME::INTERNAL_ERROR);
286
287         SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
288         try
289         {
290                 int nbGroups=_family->getNumberOfGroups();
291                 myseq->length(nbGroups);
292                 string * descGroups=_family->getGroupsNames();
293                 for (int i=0;i<nbGroups;i++)
294                 {
295                         myseq[i]=CORBA::string_dup(descGroups[i].c_str());
296                 }
297         }
298         catch (MEDEXCEPTION &ex)
299         {
300                 MESSAGE("Unable to acces attributs descriptions");
301                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
302         }
303         return myseq._retn();
304
305 }
306 //=============================================================================
307 /*!
308  * CORBA: Accessor for attribute description i
309  */
310 //=============================================================================
311 char *  FAMILY_i::getGroupName( CORBA::Long i)
312 throw (SALOME::SALOME_Exception)
313 {
314         if (_family==NULL)
315                 THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
316                                              SALOME::INTERNAL_ERROR);
317         try
318         {
319                 return CORBA::string_dup(_family->getGroupName(i).c_str());
320         }
321         catch (MEDEXCEPTION &ex)
322         {
323                 MESSAGE("Unable to acces specified attribut description");
324                 THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
325         }
326 }
327