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