1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "PARAVIS_Engine_i.hh"
23 #include "utilities.h"
25 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
27 #include "SALOME_NamingService.hxx"
28 #include "Utils_ExceptHandlers.hxx"
33 static int MYDEBUG = 1;
35 static int MYDEBUG = 0;
39 #if defined PARAVIS_ENGINE_EXPORTS || defined PARAVISEngine_EXPORTS
40 #define PARAVIS_ENGINE_EXPORT __declspec(dllexport)
42 #define PARAVIS_ENGINE_EXPORT __declspec(dllimport)
45 #define PARAVIS_ENGINE_EXPORT
48 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
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)
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))
64 PARAVIS::PARAVIS_Gen_i* pPARAVIS_Gen = new PARAVIS::PARAVIS_Gen_i(aSession,
70 return pPARAVIS_Gen->getId() ;
75 //===========================================================================
76 PARAVIS_Gen_i::PARAVIS_Gen_i(SALOME::Session_ptr session,
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)
85 _id = _poa->activate_object(_thisObj);
87 Engines::Component_var aComponent = session->GetComponent("libPARAVIS.so");
89 Engines::Component_var aComponent = session->GetComponent("PARAVIS.dll");
91 if (CORBA::is_nil(aComponent)) {
92 MESSAGE("Component PARAVIS is null");
95 myParaVisGen = PARAVIS::PARAVIS_Gen::_narrow(aComponent);
98 //===========================================================================
99 PARAVIS_Gen_i::~PARAVIS_Gen_i()
101 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::~PARAVIS_Gen_i");
105 //===========================================================================
106 char* PARAVIS_Gen_i::GetIOR(){
107 return myParaVisGen->GetIOR();
110 //===========================================================================
111 bool PARAVIS_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
112 const SALOMEDS::TMPFile & theStream,
116 return myParaVisGen->Load(theComponent,theStream,theURL,isMultiFile);
119 //===========================================================================
120 bool PARAVIS_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
121 const SALOMEDS::TMPFile & theStream,
125 return Load(theComponent, theStream, theURL, isMultiFile);
129 //===========================================================================
130 char* PARAVIS_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
131 const char* aLocalPersistentID,
132 CORBA::Boolean isMultiFile,
133 CORBA::Boolean isASCII)
135 return myParaVisGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
138 //===========================================================================
139 SALOMEDS::TMPFile* PARAVIS_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
143 return myParaVisGen->Save(theComponent,theURL,isMultiFile);
146 //===========================================================================
147 SALOMEDS::TMPFile* PARAVIS_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
151 return myParaVisGen->Save(theComponent,theURL,isMultiFile);
155 //===========================================================================
156 char* PARAVIS_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
157 const char* IORString,
158 CORBA::Boolean isMultiFile,
159 CORBA::Boolean isASCII)
161 return myParaVisGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
164 //===========================================================================
165 void PARAVIS_Gen_i::ImportFile(const char* theFileName)
167 if (CORBA::is_nil(myParaVisGen)) {
168 MESSAGE("PARAVIS_Gen_i is null");
171 myParaVisGen->ImportFile(theFileName);
174 //===========================================================================
175 char* PARAVIS_Gen_i::GetTrace()
177 if (CORBA::is_nil(myParaVisGen)) {
178 MESSAGE("PARAVIS_Gen_i is null");
179 return CORBA::string_dup("");
181 return CORBA::string_dup(myParaVisGen->GetTrace());
184 //===========================================================================
185 void PARAVIS_Gen_i::SaveTrace(const char* theFileName)
187 if (CORBA::is_nil(myParaVisGen)) {
188 MESSAGE("PARAVIS_Gen_i is null");
191 myParaVisGen->SaveTrace(theFileName);
194 //===========================================================================
195 void PARAVIS_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
197 myParaVisGen->Close(theComponent);
201 //===========================================================================
202 char* PARAVIS_Gen_i::ComponentDataType()
204 return CORBA::string_dup("PARAVIS");
207 //===========================================================================
208 CORBA::Boolean PARAVIS_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
210 return myParaVisGen->CanPublishInStudy(theIOR);
214 //===========================================================================
215 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
216 SALOMEDS::SObject_ptr theSObject,
217 CORBA::Object_ptr theObject,
219 throw (SALOME::SALOME_Exception)
221 return myParaVisGen->PublishInStudy(theStudy, theSObject, theObject, theName);
224 //===========================================================================
225 CORBA::Boolean PARAVIS_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
227 return myParaVisGen->CanCopy(theObject);
231 //===========================================================================
232 SALOMEDS::TMPFile* PARAVIS_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID)
234 return myParaVisGen->CopyFrom(theObject, theObjectID);
238 //===========================================================================
239 CORBA::Boolean PARAVIS_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID)
241 return myParaVisGen->CanPaste(theComponentName, theObjectID);
244 //===========================================================================
245 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
246 CORBA::Long theObjectID,
247 SALOMEDS::SObject_ptr theObject)
249 return myParaVisGen->PasteInto(theStream,theObjectID,theObject);
252 //===========================================================================
253 PARAVIS::string_array* PARAVIS_Gen_i::GetClassesList()
255 return myParaVisGen->GetClassesList();
258 //===========================================================================
259 PARAVIS_Base_ptr PARAVIS_Gen_i::CreateClass(const char* theClassName)
261 return myParaVisGen->CreateClass(theClassName);
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)
270 myParaVisGen->GetConnectionParameters(theId, theDHost, theDPort, theRHost, theRPort, theReversed);
273 //===========================================================================
274 void PARAVIS_Gen_i::ActivateModule()
276 myParaVisGen->ActivateModule();