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"
26 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
28 #include "SALOME_NamingService.hxx"
29 #include "Utils_ExceptHandlers.hxx"
34 static int MYDEBUG = 1;
36 static int MYDEBUG = 0;
40 #if defined PARAVIS_ENGINE_EXPORTS || defined PARAVISEngine_EXPORTS
41 #define PARAVIS_ENGINE_EXPORT __declspec(dllexport)
43 #define PARAVIS_ENGINE_EXPORT __declspec(dllimport)
46 #define PARAVIS_ENGINE_EXPORT
49 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
52 PARAVIS_ENGINE_EXPORT PortableServer::ObjectId* PARAVISEngine_factory(CORBA::ORB_ptr orb,
53 PortableServer::POA_ptr poa,
54 PortableServer::ObjectId * contId,
55 const char *instanceName,
56 const char *interfaceName)
58 MESSAGE("PARAVISEngine_factory : "<<interfaceName);
59 SALOME_NamingService aNamingService(orb);
60 CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session");
61 SALOME::Session_var aSession = SALOME::Session::_narrow(anObject);
62 if (CORBA::is_nil(aSession))
65 PARAVIS::PARAVIS_Gen_i* pPARAVIS_Gen = new PARAVIS::PARAVIS_Gen_i(aSession,
71 return pPARAVIS_Gen->getId() ;
76 //===========================================================================
77 PARAVIS_Gen_i::PARAVIS_Gen_i(SALOME::Session_ptr session,
79 PortableServer::POA_ptr poa,
80 PortableServer::ObjectId * contId,
81 const char *instanceName,
82 const char *interfaceName) :
83 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
86 _id = _poa->activate_object(_thisObj);
88 Engines::Component_var aComponent = session->GetComponent("libPARAVIS.so");
90 Engines::Component_var aComponent = session->GetComponent("PARAVIS.dll");
92 if (CORBA::is_nil(aComponent)) {
93 MESSAGE("Component PARAVIS is null");
96 myParaVisGen = PARAVIS::PARAVIS_Gen::_narrow(aComponent);
99 //===========================================================================
100 PARAVIS_Gen_i::~PARAVIS_Gen_i()
102 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::~PARAVIS_Gen_i");
106 //===========================================================================
107 char* PARAVIS_Gen_i::GetIOR(){
108 return myParaVisGen->GetIOR();
111 //===========================================================================
112 bool PARAVIS_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
113 const SALOMEDS::TMPFile & theStream,
117 return myParaVisGen->Load(theComponent,theStream,theURL,isMultiFile);
120 //===========================================================================
121 bool PARAVIS_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
122 const SALOMEDS::TMPFile & theStream,
126 return Load(theComponent, theStream, theURL, isMultiFile);
130 //===========================================================================
131 char* PARAVIS_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
132 const char* aLocalPersistentID,
133 CORBA::Boolean isMultiFile,
134 CORBA::Boolean isASCII)
136 return myParaVisGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
139 //===========================================================================
140 SALOMEDS::TMPFile* PARAVIS_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
144 return myParaVisGen->Save(theComponent,theURL,isMultiFile);
147 //===========================================================================
148 SALOMEDS::TMPFile* PARAVIS_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
152 return myParaVisGen->Save(theComponent,theURL,isMultiFile);
156 //===========================================================================
157 char* PARAVIS_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
158 const char* IORString,
159 CORBA::Boolean isMultiFile,
160 CORBA::Boolean isASCII)
162 return myParaVisGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
165 //===========================================================================
166 void PARAVIS_Gen_i::ImportFile(const char* theFileName)
168 if (CORBA::is_nil(myParaVisGen)) {
169 MESSAGE("PARAVIS_Gen_i is null");
172 myParaVisGen->ImportFile(theFileName);
175 //===========================================================================
176 char* PARAVIS_Gen_i::GetTrace()
178 if (CORBA::is_nil(myParaVisGen)) {
179 MESSAGE("PARAVIS_Gen_i is null");
180 return CORBA::string_dup("");
182 return CORBA::string_dup(myParaVisGen->GetTrace());
185 //===========================================================================
186 void PARAVIS_Gen_i::SaveTrace(const char* theFileName)
188 if (CORBA::is_nil(myParaVisGen)) {
189 MESSAGE("PARAVIS_Gen_i is null");
192 myParaVisGen->SaveTrace(theFileName);
195 //===========================================================================
196 void PARAVIS_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
198 myParaVisGen->Close(theComponent);
202 //===========================================================================
203 char* PARAVIS_Gen_i::ComponentDataType()
205 return CORBA::string_dup("PARAVIS");
208 //===========================================================================
209 CORBA::Boolean PARAVIS_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
211 return myParaVisGen->CanPublishInStudy(theIOR);
215 //===========================================================================
216 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
217 SALOMEDS::SObject_ptr theSObject,
218 CORBA::Object_ptr theObject,
220 throw (SALOME::SALOME_Exception)
222 return myParaVisGen->PublishInStudy(theStudy, theSObject, theObject, theName);
225 //===========================================================================
226 CORBA::Boolean PARAVIS_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
228 return myParaVisGen->CanCopy(theObject);
232 //===========================================================================
233 SALOMEDS::TMPFile* PARAVIS_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID)
235 return myParaVisGen->CopyFrom(theObject, theObjectID);
239 //===========================================================================
240 CORBA::Boolean PARAVIS_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID)
242 return myParaVisGen->CanPaste(theComponentName, theObjectID);
245 //===========================================================================
246 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
247 CORBA::Long theObjectID,
248 SALOMEDS::SObject_ptr theObject)
250 return myParaVisGen->PasteInto(theStream,theObjectID,theObject);
253 //===========================================================================
254 PARAVIS::string_array* PARAVIS_Gen_i::GetClassesList()
256 return myParaVisGen->GetClassesList();
259 //===========================================================================
260 PARAVIS_Base_ptr PARAVIS_Gen_i::CreateClass(const char* theClassName)
262 return myParaVisGen->CreateClass(theClassName);
265 //===========================================================================
266 void PARAVIS_Gen_i::GetConnectionParameters(CORBA::Long& theId,
267 CORBA::String_out theDHost, CORBA::Long& theDPort,
268 CORBA::String_out theRHost, CORBA::Long& theRPort,
269 CORBA::Long& theReversed)
271 myParaVisGen->GetConnectionParameters(theId, theDHost, theDPort, theRHost, theRPort, theReversed);
274 //===========================================================================
275 void PARAVIS_Gen_i::ActivateModule()
277 myParaVisGen->ActivateModule();