]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM_I/MEDMEM_Group_i.cxx
Salome HOME
updating the main trunk with the CEA debug devellopment from the branch
[modules/med.git] / src / MEDMEM_I / MEDMEM_Group_i.cxx
1 //=============================================================================
2 // File      : MEDMEM_Group_i.cxx
3 // Project   : SALOME
4 // Author    : EDF 
5 // Copyright : EDF 2002
6 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Group_i.cxx
7 //=============================================================================
8
9 #include <vector>
10
11 #include "utilities.h"
12 #include "Utils_CorbaException.hxx"
13
14 #include "MEDMEM_Group_i.hxx"
15 #include "MEDMEM_Family_i.hxx"
16
17 #include "MEDMEM_Group.hxx"
18 #include "MEDMEM_Family.hxx"
19 using namespace MEDMEM;
20
21 //=============================================================================
22 /*!
23  * Default constructor
24  */
25 //=============================================================================
26 GROUP_i::GROUP_i():_group((::GROUP*)NULL),
27                    SUPPORT_i()
28 {
29         BEGIN_OF("Default Constructor GROUP_i");
30         END_OF("Default Constructor GROUP_i");
31 };
32 //=============================================================================
33 /*!
34  * Destructor
35  */
36 //=============================================================================
37 GROUP_i::~GROUP_i()
38 {
39 };
40 //=============================================================================
41 /*!
42  * Constructor
43  */
44 //=============================================================================
45 GROUP_i::GROUP_i(const ::GROUP * const g):_group(g),
46                    SUPPORT_i(g)
47 {
48         BEGIN_OF("Constructor GROUP_i");
49         END_OF("Constructor GROUP_i");
50 };
51 //=============================================================================
52 /*!
53  * Constructor par recopie
54  */
55 //=============================================================================
56 GROUP_i::GROUP_i(const GROUP_i & g):_group(g._group),
57                    SUPPORT_i(g._group)
58 {
59         BEGIN_OF("Constructor GROUP_i");
60         END_OF("Constructor GROUP_i");
61 };
62 //=============================================================================
63 /*!
64  * CORBA: Number of Families existing in the group
65  */
66 //=============================================================================
67
68 CORBA::Long  GROUP_i::getNumberOfFamilies() 
69 throw (SALOME::SALOME_Exception)
70 {
71         if (_group==NULL)
72                 THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
73                                              SALOME::INTERNAL_ERROR);
74         try
75         {
76                 return _group->getNumberOfFamilies();
77         }
78         catch (MEDEXCEPTION &ex)
79         {
80                 MESSAGE("Unable to get number of families of the group");
81                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
82         }
83 };
84 //=============================================================================
85 /*!
86  * CORBA: Returns references for families within the group
87  */
88 //=============================================================================
89
90 SALOME_MED::Family_array* GROUP_i::getFamilies()         
91 throw (SALOME::SALOME_Exception)
92 {
93         if (_group==NULL)
94                 THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
95                                              SALOME::INTERNAL_ERROR);
96         SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
97         try
98         {
99                 int nbfam= _group->getNumberOfFamilies();
100                 myseq->length(nbfam);
101                 vector<FAMILY*> fam(nbfam);
102                 fam = _group->getFamilies();
103                 for (int i=0;i<nbfam;i++)
104                 {
105                         FAMILY_i * f1=new FAMILY_i(fam[i]);
106                         myseq[i] = f1->POA_SALOME_MED::FAMILY::_this();
107                 }
108         }
109         catch (MEDEXCEPTION &ex)
110         {
111                 MESSAGE("Unable to access families");
112                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
113         }
114         return myseq._retn();
115 };
116 //=============================================================================
117 /*!
118  * CORBA: Returns reference for family I within the group
119  */
120 //=============================================================================
121
122 SALOME_MED::FAMILY_ptr GROUP_i::getFamily(CORBA::Long i) 
123 throw (SALOME::SALOME_Exception)
124 {
125         if (_group==NULL)
126                 THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
127                                              SALOME::INTERNAL_ERROR);
128         try
129         {
130                 FAMILY * fam=_group->getFamily(i);
131                 FAMILY_i * f1=new FAMILY_i(fam);
132                 return f1->POA_SALOME_MED::FAMILY::_this();
133         }
134         catch (MEDEXCEPTION &ex)
135         {
136                 MESSAGE("Unable to acces to the specified family");
137                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
138         }
139 };