Salome HOME
version 5_1_4 HOMARD_SRC
[modules/homard.git] / src / HOMARD_I / HOMARD_Gen_i.hxx
1 #ifndef _HOMARD_GEN_I_HXX_
2 #define _HOMARD_GEN_I_HXX_
3
4 #include <SALOMEconfig.h>
5 #include CORBA_SERVER_HEADER(HOMARD_Gen)
6 #include CORBA_SERVER_HEADER(HOMARD_Cas)
7 #include CORBA_SERVER_HEADER(HOMARD_Hypothesis)
8 #include CORBA_SERVER_HEADER(HOMARD_Iteration)
9 #include CORBA_SERVER_HEADER(HOMARD_Zone)
10 #include CORBA_SERVER_HEADER(HOMARD_Boundary)
11 #include CORBA_CLIENT_HEADER(SALOMEDS)
12 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
13
14 #include "HOMARD_Gen.hxx"
15 #include "SALOME_Component_i.hxx"
16 #include "SALOME_NamingService.hxx"
17 #include "Utils_CorbaException.hxx"
18
19
20 #include <string>
21 #include <map>
22
23 class HOMARD_Gen_i:
24   public virtual Engines_Component_i,
25   public virtual POA_HOMARD::HOMARD_Gen
26
27 public:
28   HOMARD_Gen_i(CORBA::ORB_ptr orb,
29                 PortableServer::POA_ptr poa,
30                 PortableServer::ObjectId* contId, 
31                 const char* instanceName, 
32                 const char* interfaceName);
33   virtual ~HOMARD_Gen_i();
34   
35
36   SALOMEDS::Study_ptr             GetCurrentStudy();
37   void                            SetCurrentStudy(SALOMEDS::Study_ptr theStudy);
38   int                             GetCurrentStudyID();
39
40   HOMARD::HOMARD_Cas_ptr          CreateCase      (const char* nomCas,
41                                                    const char* MeshName, const char* FileName);
42   HOMARD::HOMARD_Hypothesis_ptr   CreateHypothesis(const char* nomHypothesis);
43   HOMARD::HOMARD_Iteration_ptr    CreateIteration (const char* nomIter, const char* nomIterParent);
44   HOMARD::HOMARD_Zone_ptr         CreateZone      (const char* nomZone, CORBA::Long typeZone);
45   HOMARD::HOMARD_Boundary_ptr     CreateBoundary  (const char* nomBoundary, CORBA::Long typeBoundary);
46
47   HOMARD::HOMARD_Cas_ptr          GetCas        (const char* nomCas);
48   HOMARD::HOMARD_Zone_ptr         GetZone       (const char* nomZone);
49   HOMARD::HOMARD_Hypothesis_ptr   GetHypothesis (const char* nomHypothesis);
50   HOMARD::HOMARD_Iteration_ptr    GetIteration  (const char* nomIteration);
51   HOMARD::HOMARD_Boundary_ptr     GetBoundary   (const char* nomBoundary);
52
53   void                            AssociateCaseIter(const char* nomCas, const char* nomIter,
54                                                     const char* labelIter);
55   void                            AssociateIterIter(const char* nomIterParent, const char* nomIter);
56   void                            AssociateIterHypo(const char* nomIter, const char* nomHypothesis);
57   void                            AssociateHypoZone(const char* nomZone, const char* nomHypothesis);
58   void                            DissociateHypoZone(const char* nomZone, const char* nomHypothesis);
59
60   void                            InvalideZone(const char* nomZone);
61   void                            InvalideHypo(const char* nomHypo);
62   void                            InvalideIter(const char* nomIter);
63
64   void                            SetEtatIter(const char* nomIter,const bool EtatCalcul);
65
66   HOMARD::listeCases*             GetAllCases();
67   HOMARD::listeHypotheses*        GetAllHypotheses();
68   HOMARD::listeZones*             GetAllZones();
69   HOMARD::listeIterations*        GetAllIterations();
70   HOMARD::listeBoundarys*         GetAllBoundarys();
71
72   char*                           GetCaseName(const char* nomIteration);
73   
74   CORBA::Boolean                  Compute(const char* nomIteration, CORBA::Long etatMenage);
75   CORBA::Boolean                  VerifieDir(const char* nomDir);
76   
77   void                            PublishResultInSmesh(const char* NomFich, CORBA::Long IconeType);
78   void                            DeleteResultInSmesh(const char* NomFich, const char* MeshName);
79   void                            PublishFileUnderIteration(const char* NomIter, const char* NomFich,
80                                                             const char* Commentaire);
81
82   // ---------------------------------------------------------------
83   // next functions are inherited from SALOMEDS::Driver interface
84   // ---------------------------------------------------------------
85
86   // --> Persistence
87   virtual SALOMEDS::TMPFile*      Save(SALOMEDS::SComponent_ptr theComponent,
88                                         const char* theURL,
89                                         bool isMultiFile);
90   
91   virtual SALOMEDS::TMPFile*      SaveASCII(SALOMEDS::SComponent_ptr theComponent,
92                                              const char* theURL,
93                                              bool isMultiFile);
94   
95   virtual bool                    Load(SALOMEDS::SComponent_ptr theComponent,
96                                         const SALOMEDS::TMPFile& theStream,
97                                         const char* theURL,
98                                         bool isMultiFile);
99
100   virtual bool                    LoadASCII(SALOMEDS::SComponent_ptr theComponent,
101                                              const SALOMEDS::TMPFile& theStream,
102                                              const char* theURL,
103                                              bool isMultiFile);
104
105   virtual void                    Close(SALOMEDS::SComponent_ptr IORSComponent);
106   
107   virtual char*                   ComponentDataType();
108   
109   virtual char*                   IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
110                                                           const char* IORString,
111                                                           CORBA::Boolean isMultiFile,
112                                                           CORBA::Boolean isASCII);
113
114   virtual char*                   LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
115                                                           const char* aLocalPersistentID,
116                                                           CORBA::Boolean isMultiFile,
117                                                           CORBA::Boolean isASCII);
118   
119   // --> Data publishing
120   virtual bool                    CanPublishInStudy(CORBA::Object_ptr theIOR);
121
122   virtual SALOMEDS::SObject_ptr   PublishInStudy(SALOMEDS::Study_ptr theStudy,
123                                                  SALOMEDS::SObject_ptr theSObject,
124                                                  CORBA::Object_ptr theObject,
125                                                  const char* theName);
126
127   // --> Copy/Paste
128   virtual CORBA::Boolean          CanCopy(SALOMEDS::SObject_ptr theObject);
129   
130   virtual SALOMEDS::TMPFile*      CopyFrom(SALOMEDS::SObject_ptr theObject,
131                                             CORBA::Long& theObjectID);
132
133   virtual CORBA::Boolean          CanPaste(const char* theComponentName, CORBA::Long theObjectID);
134
135   virtual SALOMEDS::SObject_ptr   PasteInto(const SALOMEDS::TMPFile& theStream,
136                                              CORBA::Long theObjectID,
137                                              SALOMEDS::SObject_ptr theObject);
138
139
140 private:
141   void                            addInStudy(SALOMEDS::Study_ptr theStudy);
142   SALOMEDS::SObject_ptr           PublishCaseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
143                                                      HOMARD::HOMARD_Cas_ptr theObject, const char* theName);
144   
145   SALOMEDS::SObject_ptr           PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
146                                                      HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName);
147
148   SALOMEDS::SObject_ptr           PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
149                                                      HOMARD::HOMARD_Zone_ptr theObject, const char* theName);
150   SALOMEDS::SObject_ptr           PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder,
151                                                      HOMARD::HOMARD_Boundary_ptr theObject, const char* theName);
152   virtual void                    PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
153                                                      SALOMEDS::SObject_var aResultSO,
154                                                      const char* theName, const char* value, const char* icone, const char* ior);
155   PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
156
157   HOMARD::HOMARD_Cas_ptr          newCase();
158   HOMARD::HOMARD_Hypothesis_ptr   newHypothesis();
159   HOMARD::HOMARD_Iteration_ptr    newIteration();
160   HOMARD::HOMARD_Zone_ptr         newZone();
161   HOMARD::HOMARD_Boundary_ptr     newBoundary();
162
163
164   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
165                                        CORBA::Boolean isPublished,
166                                        CORBA::Boolean& isValidScript);
167
168
169 private:
170   struct StudyContext
171   {
172     std::map<std::string, HOMARD::HOMARD_Cas_var>        _mesCas;
173     std::map<std::string, HOMARD::HOMARD_Hypothesis_var> _mesHypotheses;
174     std::map<std::string, HOMARD::HOMARD_Iteration_var>  _mesIterations;
175     std::map<std::string, HOMARD::HOMARD_Zone_var>       _mesZones;
176     std::map<std::string, HOMARD::HOMARD_Boundary_var>   _mesBoundarys;
177     std::map<int, PortableServer::ServantBase*>          _idmap;
178   };
179   typedef std::map<int, StudyContext> ContextMap;
180   
181   ::HOMARD_Gen*                 myHomard;
182   SALOMEDS::Study_var           myCurrentStudy;
183   ContextMap                    myContextMap;
184   SALOME_NamingService*         _NS;
185
186 };
187
188 #endif