]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD_I/HOMARD_Gen_i.hxx
Salome HOME
5d9033f47a2cdbc6167a6f561a9d8a6f719f9b88
[modules/homard.git] / src / HOMARD_I / HOMARD_Gen_i.hxx
1 // Copyright (C) 2011-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _HOMARD_GEN_I_HXX_
21 #define _HOMARD_GEN_I_HXX_
22
23 #include <SALOMEconfig.h>
24 #include CORBA_SERVER_HEADER(HOMARD_Gen)
25 #include CORBA_SERVER_HEADER(HOMARD_Cas)
26 #include CORBA_SERVER_HEADER(HOMARD_Hypothesis)
27 #include CORBA_SERVER_HEADER(HOMARD_Iteration)
28 #include CORBA_SERVER_HEADER(HOMARD_Zone)
29 #include CORBA_SERVER_HEADER(HOMARD_Boundary)
30 #include CORBA_CLIENT_HEADER(SALOMEDS)
31 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
32
33 #include "HOMARD_Gen.hxx"
34 #include "SALOME_Component_i.hxx"
35 #include "SALOME_NamingService.hxx"
36 #include "Utils_CorbaException.hxx"
37
38
39 #include <string>
40 #include <map>
41
42 class HOMARD_Gen_i:
43   public virtual Engines_Component_i,
44   public virtual POA_HOMARD::HOMARD_Gen
45 {
46 public:
47   HOMARD_Gen_i( CORBA::ORB_ptr orb,
48                 PortableServer::POA_ptr poa,
49                 PortableServer::ObjectId* contId,
50                 const char* instanceName,
51                 const char* interfaceName );
52   virtual ~HOMARD_Gen_i();
53
54
55 // Generalites
56
57 // Les creations
58   HOMARD::HOMARD_Boundary_ptr     CreateBoundary (const char* nomBoundary, CORBA::Long typeBoundary);
59   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryDi (const char* nomBoundary,
60                                                     const char* MeshName, const char* FileName);
61   HOMARD::HOMARD_Boundary_ptr     CreateBoundaryCylinder (const char* nomBoundary,
62                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
63                                       CORBA::Double Xaxis, CORBA::Double Yaxis, CORBA::Double Zaxis,
64                                       CORBA::Double Rayon);
65   HOMARD::HOMARD_Boundary_ptr     CreateBoundarySphere (const char* nomBoundary,
66                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
67                                       CORBA::Double Rayon);
68
69   HOMARD::HOMARD_Cas_ptr          CreateCase      (const char* nomCas,
70                                                    const char* MeshName, const char* FileName);
71
72   HOMARD::HOMARD_Hypothesis_ptr   CreateHypothesis(const char* nomHypothesis);
73
74   HOMARD::HOMARD_Iteration_ptr    CreateIteration (const char* nomIter, const char* nomIterParent);
75
76   HOMARD::HOMARD_Zone_ptr         CreateZone (const char* nomZone, CORBA::Long typeZone);
77   HOMARD::HOMARD_Zone_ptr         CreateZoneBox (const char* nomZone,
78                                       CORBA::Double Xmini, CORBA::Double Xmaxi,
79                                       CORBA::Double Ymini, CORBA::Double Ymaxi,
80                                       CORBA::Double Zmini, CORBA::Double Zmaxi);
81   HOMARD::HOMARD_Zone_ptr         CreateZoneBox2D (const char* nomZone,
82                                       CORBA::Double Umini, CORBA::Double Umaxi,
83                                       CORBA::Double Vmini, CORBA::Double Vmaxi,
84                                       CORBA::Long Orient);
85   HOMARD::HOMARD_Zone_ptr         CreateZoneCylinder (const char* nomZone,
86                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
87                                       CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
88                                       CORBA::Double Rayon, CORBA::Double Haut);
89   HOMARD::HOMARD_Zone_ptr         CreateZoneDisk (const char* nomZone,
90                                       CORBA::Double Ucentre, CORBA::Double Vcentre,
91                                       CORBA::Double Rayon,
92                                       CORBA::Long Orient);
93   HOMARD::HOMARD_Zone_ptr         CreateZoneDiskWithHole (const char* nomZone,
94                                       CORBA::Double Ucentre, CORBA::Double Vcentre,
95                                       CORBA::Double Rayon, CORBA::Double Rayonint,
96                                       CORBA::Long Orient);
97   HOMARD::HOMARD_Zone_ptr         CreateZonePipe (const char* nomZone,
98                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
99                                       CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
100                                       CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint);
101   HOMARD::HOMARD_Zone_ptr         CreateZoneSphere (const char* nomZone,
102                                       CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon);
103
104 // Les informations
105   HOMARD::HOMARD_Boundary_ptr     GetBoundary   (const char* nomBoundary);
106   HOMARD::HOMARD_Cas_ptr          GetCase       (const char* nomCas);
107   HOMARD::HOMARD_Hypothesis_ptr   GetHypothesis (const char* nomHypothesis);
108   HOMARD::HOMARD_Iteration_ptr    GetIteration  (const char* nomIteration);
109   HOMARD::HOMARD_Zone_ptr         GetZone       (const char* nomZone);
110
111   HOMARD::listeBoundarys*         GetAllBoundarysName();
112   HOMARD::listeCases*             GetAllCasesName();
113   HOMARD::listeHypotheses*        GetAllHypothesesName();
114   HOMARD::listeIterations*        GetAllIterationsName();
115   HOMARD::listeZones*             GetAllZonesName();
116
117   HOMARD::HOMARD_Iteration_ptr    LastIteration  (const char* nomCas);
118
119 // L'etude
120   SALOMEDS::Study_ptr             GetCurrentStudy();
121   void                            SetCurrentStudy(SALOMEDS::Study_ptr theStudy);
122   CORBA::Long                     GetCurrentStudyID();
123
124 // Liens entre structures
125   void                            InvalideBoundary(const char* nomBoundary);
126   void                            InvalideHypo(const char* nomHypo);
127   void                            InvalideIter(const char* nomIter);
128   void                            InvalideZone(const char* nomZone);
129
130   CORBA::Long                     DeleteBoundary(const char* nomBoundary);
131   CORBA::Long                     DeleteCase(const char* nomCas);
132   CORBA::Long                     DeleteHypo(const char* nomHypothesis);
133   CORBA::Long                     DeleteIteration(const char* nomIter);
134   CORBA::Long                     DeleteIterationOption(const char* nomIter, CORBA::Long Option);
135   CORBA::Long                     DeleteZone(const char* nomZone);
136
137   void                            AssociateIterHypo(const char* nomIter, const char* nomHypothesis);
138
139   void                            AssociateHypoZone(const char* nomHypothesis, const char* nomZone, CORBA::Long TypeUse);
140   void                            DissociateHypoZone(const char* nomHypothesis, const char* nomZone);
141
142   void                            AssociateCaseIter(const char* nomCas, const char* nomIter,
143                                                     const char* labelIter);
144
145   void                            SetEtatIter(const char* nomIter,const CORBA::Boolean EtatCalcul);
146
147   CORBA::Long                     Compute(const char* nomIteration, CORBA::Long etatMenage);
148   CORBA::Boolean                  VerifieDir(const char* nomDir);
149
150   void                            PublishResultInSmesh(const char* NomFich, CORBA::Long IconeType);
151   void                            DeleteResultInSmesh(const char* NomFich, const char* MeshName);
152   void                            PublishFileUnderIteration(const char* NomIter, const char* NomFich,
153                                                             const char* Commentaire);
154   void                            PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName);
155
156   void                            IsValidStudy();
157
158   // ---------------------------------------------------------------
159   // next functions are inherited from SALOMEDS::Driver interface
160   // ---------------------------------------------------------------
161
162   // --> Persistence
163   virtual SALOMEDS::TMPFile*      Save(SALOMEDS::SComponent_ptr theComponent,
164                                         const char* theURL,
165                                         CORBA::Boolean isMultiFile);
166
167   virtual SALOMEDS::TMPFile*      SaveASCII(SALOMEDS::SComponent_ptr theComponent,
168                                              const char* theURL,
169                                              CORBA::Boolean isMultiFile);
170
171   virtual CORBA::Boolean          Load(SALOMEDS::SComponent_ptr theComponent,
172                                         const SALOMEDS::TMPFile& theStream,
173                                         const char* theURL,
174                                         CORBA::Boolean isMultiFile);
175
176   virtual CORBA::Boolean          LoadASCII(SALOMEDS::SComponent_ptr theComponent,
177                                              const SALOMEDS::TMPFile& theStream,
178                                              const char* theURL,
179                                              CORBA::Boolean isMultiFile);
180
181   virtual void                    Close(SALOMEDS::SComponent_ptr IORSComponent);
182
183   virtual char*                   ComponentDataType();
184
185   virtual char*                   IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
186                                                           const char* IORString,
187                                                           CORBA::Boolean isMultiFile,
188                                                           CORBA::Boolean isASCII);
189
190   virtual char*                   LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
191                                                           const char* aLocalPersistentID,
192                                                           CORBA::Boolean isMultiFile,
193                                                           CORBA::Boolean isASCII);
194
195   // --> Data publishing
196   virtual CORBA::Boolean          CanPublishInStudy(CORBA::Object_ptr theIOR);
197
198   virtual SALOMEDS::SObject_ptr   PublishInStudy(SALOMEDS::Study_ptr theStudy,
199                                                  SALOMEDS::SObject_ptr theSObject,
200                                                  CORBA::Object_ptr theObject,
201                                                  const char* theName);
202
203   // --> Copy/Paste
204   virtual CORBA::Boolean          CanCopy(SALOMEDS::SObject_ptr theObject);
205
206   virtual SALOMEDS::TMPFile*      CopyFrom(SALOMEDS::SObject_ptr theObject,
207                                             CORBA::Long& theObjectID);
208
209   virtual CORBA::Boolean          CanPaste(const char* theComponentName, CORBA::Long theObjectID);
210
211   virtual SALOMEDS::SObject_ptr   PasteInto(const SALOMEDS::TMPFile& theStream,
212                                              CORBA::Long theObjectID,
213                                              SALOMEDS::SObject_ptr theObject);
214
215 //   virtual void SALOMEException( std::string message );
216
217 private:
218   void                            addInStudy(SALOMEDS::Study_ptr theStudy);
219   SALOMEDS::SObject_ptr           PublishCaseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
220                                                      HOMARD::HOMARD_Cas_ptr theObject, const char* theName);
221
222   SALOMEDS::SObject_ptr           PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
223                                                      HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName);
224
225   SALOMEDS::SObject_ptr           PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
226                                                      HOMARD::HOMARD_Zone_ptr theObject, const char* theName);
227   SALOMEDS::SObject_ptr           PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
228                                                      HOMARD::HOMARD_Boundary_ptr theObject, const char* theName);
229   virtual void                    PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
230                                                      SALOMEDS::SObject_var aResultSO,
231                                                      const char* theName, const char* value, const char* icone, const char* ior);
232
233 PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
234
235   HOMARD::HOMARD_Cas_ptr          newCase();
236   HOMARD::HOMARD_Hypothesis_ptr   newHypothesis();
237   HOMARD::HOMARD_Iteration_ptr    newIteration();
238   HOMARD::HOMARD_Zone_ptr         newZone();
239   HOMARD::HOMARD_Boundary_ptr     newBoundary();
240
241
242   virtual Engines::TMPFile*       DumpPython(CORBA::Object_ptr theStudy,
243                                              CORBA::Boolean isPublished,
244                                              CORBA::Boolean isMultiFile,
245                                              CORBA::Boolean& isValidScript);
246
247   virtual char*                   getVersion();
248
249 private:
250   struct StudyContext
251   {
252     std::map<std::string, HOMARD::HOMARD_Cas_var>        _mesCas;
253     std::map<std::string, HOMARD::HOMARD_Hypothesis_var> _mesHypotheses;
254     std::map<std::string, HOMARD::HOMARD_Iteration_var>  _mesIterations;
255     std::map<std::string, HOMARD::HOMARD_Zone_var>       _mesZones;
256     std::map<std::string, HOMARD::HOMARD_Boundary_var>   _mesBoundarys;
257     std::map<int, PortableServer::ServantBase*>          _idmap;
258   };
259   typedef std::map<int, StudyContext> ContextMap;
260
261   ::HOMARD_Gen*                 myHomard;
262   SALOMEDS::Study_var           myCurrentStudy;
263   ContextMap                    myContextMap;
264   SALOME_NamingService*         _NS;
265
266 };
267
268 #endif