1 // Copyright (C) 2010-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "PARAVIS_Engine_i.hh"
21 #include "utilities.h"
24 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
26 #include "SALOME_NamingService.hxx"
27 #include "Utils_ExceptHandlers.hxx"
32 static int MYDEBUG = 1;
34 static int MYDEBUG = 0;
38 #if defined PARAVIS_ENGINE_EXPORTS || defined PARAVISEngine_EXPORTS
39 #define PARAVIS_ENGINE_EXPORT __declspec(dllexport)
41 #define PARAVIS_ENGINE_EXPORT __declspec(dllimport)
44 #define PARAVIS_ENGINE_EXPORT
47 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
50 PARAVIS_ENGINE_EXPORT PortableServer::ObjectId* PARAVISEngine_factory(CORBA::ORB_ptr orb,
51 PortableServer::POA_ptr poa,
52 PortableServer::ObjectId * contId,
53 const char *instanceName,
54 const char *interfaceName)
56 MESSAGE("PARAVISEngine_factory : "<<interfaceName);
57 SALOME_NamingService aNamingService(orb);
58 CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session");
59 SALOME::Session_var aSession = SALOME::Session::_narrow(anObject);
60 if (CORBA::is_nil(aSession))
63 PARAVIS::PARAVIS_Gen_i* pPARAVIS_Gen = new PARAVIS::PARAVIS_Gen_i(aSession,
69 return pPARAVIS_Gen->getId() ;
74 //===========================================================================
75 PARAVIS_Gen_i::PARAVIS_Gen_i(SALOME::Session_ptr session,
77 PortableServer::POA_ptr poa,
78 PortableServer::ObjectId * contId,
79 const char *instanceName,
80 const char *interfaceName) :
81 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
84 _id = _poa->activate_object(_thisObj);
86 Engines::EngineComponent_var aComponent = session->GetComponent("libPARAVIS.so");
88 Engines::EngineComponent_var aComponent = session->GetComponent("PARAVIS.dll");
90 if (CORBA::is_nil(aComponent)) {
91 MESSAGE("Component PARAVIS is null");
94 myParaVisGen = PARAVIS::PARAVIS_Gen::_narrow(aComponent);
97 //===========================================================================
98 PARAVIS_Gen_i::~PARAVIS_Gen_i()
100 if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::~PARAVIS_Gen_i");
104 //===========================================================================
105 char* PARAVIS_Gen_i::GetIOR(){
106 return myParaVisGen->GetIOR();
109 //===========================================================================
110 bool PARAVIS_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
111 const SALOMEDS::TMPFile & theStream,
115 return myParaVisGen->Load(theComponent,theStream,theURL,isMultiFile);
118 //===========================================================================
119 bool PARAVIS_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
120 const SALOMEDS::TMPFile & theStream,
124 return Load(theComponent, theStream, theURL, isMultiFile);
128 //===========================================================================
129 char* PARAVIS_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
130 const char* aLocalPersistentID,
131 CORBA::Boolean isMultiFile,
132 CORBA::Boolean isASCII)
134 return myParaVisGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
137 //===========================================================================
138 SALOMEDS::TMPFile* PARAVIS_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
142 return myParaVisGen->Save(theComponent,theURL,isMultiFile);
145 //===========================================================================
146 SALOMEDS::TMPFile* PARAVIS_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
150 return myParaVisGen->Save(theComponent,theURL,isMultiFile);
154 //===========================================================================
155 char* PARAVIS_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
156 const char* IORString,
157 CORBA::Boolean isMultiFile,
158 CORBA::Boolean isASCII)
160 return myParaVisGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
163 //===========================================================================
164 void PARAVIS_Gen_i::ImportFile(const char* theFileName)
166 if (CORBA::is_nil(myParaVisGen)) {
167 MESSAGE("PARAVIS_Gen_i is null");
170 myParaVisGen->ImportFile(theFileName);
173 void PARAVIS_Gen_i::ExecuteScript(const char* script)
175 if (CORBA::is_nil(myParaVisGen)) {
176 MESSAGE("PARAVIS_Gen_i is null");
179 myParaVisGen->ExecuteScript(script);
182 //===========================================================================
183 char* PARAVIS_Gen_i::GetTrace()
185 if (CORBA::is_nil(myParaVisGen)) {
186 MESSAGE("PARAVIS_Gen_i is null");
187 return CORBA::string_dup("");
189 return CORBA::string_dup(myParaVisGen->GetTrace());
192 //===========================================================================
193 void PARAVIS_Gen_i::SaveTrace(const char* theFileName)
195 if (CORBA::is_nil(myParaVisGen)) {
196 MESSAGE("PARAVIS_Gen_i is null");
199 myParaVisGen->SaveTrace(theFileName);
202 //===========================================================================
203 void PARAVIS_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
205 myParaVisGen->Close(theComponent);
209 //===========================================================================
210 char* PARAVIS_Gen_i::ComponentDataType()
212 return CORBA::string_dup("PARAVIS");
215 //===========================================================================
216 CORBA::Boolean PARAVIS_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
218 return myParaVisGen->CanPublishInStudy(theIOR);
222 //===========================================================================
223 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
224 SALOMEDS::SObject_ptr theSObject,
225 CORBA::Object_ptr theObject,
227 throw (SALOME::SALOME_Exception)
229 return myParaVisGen->PublishInStudy(theStudy, theSObject, theObject, theName);
232 //===========================================================================
233 CORBA::Boolean PARAVIS_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
235 return myParaVisGen->CanCopy(theObject);
239 //===========================================================================
240 SALOMEDS::TMPFile* PARAVIS_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID)
242 return myParaVisGen->CopyFrom(theObject, theObjectID);
246 //===========================================================================
247 CORBA::Boolean PARAVIS_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID)
249 return myParaVisGen->CanPaste(theComponentName, theObjectID);
252 //===========================================================================
253 SALOMEDS::SObject_ptr PARAVIS_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
254 CORBA::Long theObjectID,
255 SALOMEDS::SObject_ptr theObject)
257 return myParaVisGen->PasteInto(theStream,theObjectID,theObject);
260 //===========================================================================
261 PARAVIS::string_array* PARAVIS_Gen_i::GetClassesList()
263 return myParaVisGen->GetClassesList();
266 //===========================================================================
267 PARAVIS_Base_ptr PARAVIS_Gen_i::CreateClass(const char* theClassName)
269 return myParaVisGen->CreateClass(theClassName);
272 //===========================================================================
273 void PARAVIS_Gen_i::GetConnectionParameters(CORBA::Long& theId,
274 CORBA::String_out theDHost, CORBA::Long& theDPort,
275 CORBA::String_out theRHost, CORBA::Long& theRPort,
276 CORBA::Long& theReversed)
278 myParaVisGen->GetConnectionParameters(theId, theDHost, theDPort, theRHost, theRPort, theReversed);
281 //===========================================================================
282 void PARAVIS_Gen_i::ActivateModule()
284 myParaVisGen->ActivateModule();
287 //===========================================================================
288 void PARAVIS_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
289 myParaVisGen->SetCurrentStudy(theStudy);
293 //===========================================================================
294 SALOMEDS::Study_ptr PARAVIS_Gen_i::GetCurrentStudy(){
295 return myParaVisGen->GetCurrentStudy();