]> SALOME platform Git repositories - modules/paravis.git/blob - src/ENGINE/PARAVIS_Engine_i.cc
Salome HOME
ee16c936ee80c96e1aae7534b2b96c1318fbe17c
[modules/paravis.git] / src / ENGINE / PARAVIS_Engine_i.cc
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 #include "PARAVIS_Engine_i.hh"
23 #include "utilities.h"
24
25 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
26
27 #include "SALOME_NamingService.hxx"
28 #include "Utils_ExceptHandlers.hxx"
29
30 using namespace std;
31
32 #ifdef _DEBUG_
33 static int MYDEBUG = 1;
34 #else
35 static int MYDEBUG = 0;
36 #endif
37
38 #ifdef WNT
39 #if defined PARAVIS_ENGINE_EXPORTS || defined PARAVISEngine_EXPORTS
40 #define PARAVIS_ENGINE_EXPORT __declspec(dllexport)
41 #else
42 #define PARAVIS_ENGINE_EXPORT __declspec(dllimport)
43 #endif
44 #else
45 #define PARAVIS_ENGINE_EXPORT
46 #endif
47
48 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
49
50 extern "C" {
51 PARAVIS_ENGINE_EXPORT PortableServer::ObjectId* PARAVISEngine_factory(CORBA::ORB_ptr orb, 
52                                                                       PortableServer::POA_ptr poa, 
53                                                                       PortableServer::ObjectId * contId,
54                                                                       const char *instanceName, 
55                                                                       const char *interfaceName) 
56 {
57   MESSAGE("PARAVISEngine_factory : "<<interfaceName);
58   SALOME_NamingService aNamingService(orb);
59   CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session");
60   SALOME::Session_var aSession = SALOME::Session::_narrow(anObject);
61   if (CORBA::is_nil(aSession))
62     return NULL;
63   
64   PARAVIS::PARAVIS_Gen_i* pPARAVIS_Gen = new PARAVIS::PARAVIS_Gen_i(aSession, 
65                                                                     orb, 
66                                                                     poa, 
67                                                                     contId, 
68                                                                     instanceName, 
69                                                                     interfaceName);
70   return pPARAVIS_Gen->getId() ;
71 }
72 }
73
74 namespace PARAVIS {
75   //===========================================================================
76   PARAVIS_Gen_i::PARAVIS_Gen_i(SALOME::Session_ptr session,
77                                CORBA::ORB_ptr orb,
78                                PortableServer::POA_ptr poa,
79                                PortableServer::ObjectId * contId, 
80                                const char *instanceName, 
81                                const char *interfaceName) :
82     Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
83   {
84     _thisObj = this ;
85     _id = _poa->activate_object(_thisObj);
86 #ifndef WIN32
87     Engines::Component_var aComponent = session->GetComponent("libPARAVIS.so");
88 #else
89     Engines::Component_var aComponent = session->GetComponent("PARAVIS.dll");
90 #endif
91     if (CORBA::is_nil(aComponent)) {
92       MESSAGE("Component PARAVIS is null");
93       return;
94     }
95     myParaVisGen = PARAVIS::PARAVIS_Gen::_narrow(aComponent);
96   } 
97   
98   //===========================================================================
99   PARAVIS_Gen_i::~PARAVIS_Gen_i()
100   {
101     if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::~PARAVIS_Gen_i");
102   }
103
104
105   //===========================================================================
106   char* PARAVIS_Gen_i::GetIOR(){
107     return myParaVisGen->GetIOR();
108   }
109
110   //===========================================================================
111   bool PARAVIS_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
112                         const SALOMEDS::TMPFile & theStream,
113                         const char* theURL,
114                         bool isMultiFile)
115   {
116     return myParaVisGen->Load(theComponent,theStream,theURL,isMultiFile);
117   }
118
119   //===========================================================================
120   bool PARAVIS_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
121                              const SALOMEDS::TMPFile & theStream,
122                              const char* theURL,
123                              bool isMultiFile) 
124   {
125     return Load(theComponent, theStream, theURL, isMultiFile);
126   }
127
128
129   //===========================================================================
130   char* PARAVIS_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
131                                            const char* aLocalPersistentID,
132                                            CORBA::Boolean isMultiFile,
133                                            CORBA::Boolean isASCII) 
134   {
135     return myParaVisGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
136   }
137
138   //===========================================================================
139   SALOMEDS::TMPFile* PARAVIS_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
140                                       const char* theURL,
141                                       bool isMultiFile)
142   {
143     return myParaVisGen->Save(theComponent,theURL,isMultiFile);
144   }
145
146   //===========================================================================
147   SALOMEDS::TMPFile* PARAVIS_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
148                                            const char* theURL,
149                                            bool isMultiFile) 
150   {
151     return myParaVisGen->Save(theComponent,theURL,isMultiFile);
152   }
153
154
155   //===========================================================================
156   char* PARAVIS_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
157                                            const char* IORString,
158                                            CORBA::Boolean isMultiFile,
159                                            CORBA::Boolean isASCII) 
160   {
161     return myParaVisGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
162   }
163
164   //===========================================================================
165   void PARAVIS_Gen_i::ImportFile(const char* theFileName)
166   {
167     if (CORBA::is_nil(myParaVisGen)) {
168       MESSAGE("PARAVIS_Gen_i is null");
169       return;
170     }
171     myParaVisGen->ImportFile(theFileName);
172   }
173
174   //===========================================================================
175   char* PARAVIS_Gen_i::GetTrace()
176   {
177     if (CORBA::is_nil(myParaVisGen)) {
178       MESSAGE("PARAVIS_Gen_i is null");
179       return CORBA::string_dup("");
180     }
181     return CORBA::string_dup(myParaVisGen->GetTrace());
182   }
183
184   //===========================================================================
185   void PARAVIS_Gen_i::SaveTrace(const char* theFileName)
186   {
187     if (CORBA::is_nil(myParaVisGen)) {
188       MESSAGE("PARAVIS_Gen_i is null");
189       return ;
190     }
191     myParaVisGen->SaveTrace(theFileName);
192   }
193
194   //===========================================================================
195   void PARAVIS_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
196   {
197     myParaVisGen->Close(theComponent);
198   }
199
200
201   //===========================================================================
202   char* PARAVIS_Gen_i::ComponentDataType()
203   {
204     return CORBA::string_dup("PARAVIS");
205   }
206
207   //===========================================================================
208   CORBA::Boolean PARAVIS_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) 
209   {
210     return myParaVisGen->CanPublishInStudy(theIOR);
211   }
212
213
214   //===========================================================================
215   SALOMEDS::SObject_ptr PARAVIS_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
216                                                    SALOMEDS::SObject_ptr theSObject,
217                                                    CORBA::Object_ptr theObject,
218                                                    const char* theName) 
219     throw (SALOME::SALOME_Exception) 
220   {
221     return myParaVisGen->PublishInStudy(theStudy, theSObject, theObject, theName);
222   }
223
224   //===========================================================================
225   CORBA::Boolean PARAVIS_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) 
226   {
227     return myParaVisGen->CanCopy(theObject);
228   }
229   
230
231   //===========================================================================
232   SALOMEDS::TMPFile* PARAVIS_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) 
233   {
234     return myParaVisGen->CopyFrom(theObject, theObjectID);
235   }
236   
237
238   //===========================================================================
239   CORBA::Boolean PARAVIS_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) 
240   {
241     return myParaVisGen->CanPaste(theComponentName, theObjectID);
242   }
243
244   //===========================================================================
245   SALOMEDS::SObject_ptr PARAVIS_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
246                                               CORBA::Long theObjectID,
247                                               SALOMEDS::SObject_ptr theObject) 
248   {
249     return myParaVisGen->PasteInto(theStream,theObjectID,theObject);
250   }
251
252   //===========================================================================
253   PARAVIS::string_array* PARAVIS_Gen_i::GetClassesList()
254   {
255     return myParaVisGen->GetClassesList();
256   }
257
258   //===========================================================================
259   PARAVIS_Base_ptr PARAVIS_Gen_i::CreateClass(const char* theClassName)
260   {
261     return myParaVisGen->CreateClass(theClassName);
262   }
263
264   //===========================================================================
265   void PARAVIS_Gen_i::GetConnectionParameters(CORBA::Long& theId, 
266                                               CORBA::String_out theDHost, CORBA::Long& theDPort,
267                                               CORBA::String_out theRHost, CORBA::Long& theRPort,
268                                               CORBA::Long& theReversed)
269   {
270     myParaVisGen->GetConnectionParameters(theId, theDHost, theDPort, theRHost, theRPort, theReversed);
271   }
272     
273   //===========================================================================
274   void PARAVIS_Gen_i::ActivateModule()
275   {
276     myParaVisGen->ActivateModule();
277   }
278 }