Back to index

salome-paravis  6.5.0
PARAVIS_Engine_i.cc
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "PARAVIS_Engine_i.hh"
00021 #include "utilities.h"
00022 
00023 
00024 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
00025 
00026 #include "SALOME_NamingService.hxx"
00027 #include "Utils_ExceptHandlers.hxx"
00028 
00029 using namespace std;
00030 
00031 #ifdef _DEBUG_
00032 static int MYDEBUG = 1;
00033 #else
00034 static int MYDEBUG = 0;
00035 #endif
00036 
00037 #ifdef WNT
00038 #if defined PARAVIS_ENGINE_EXPORTS || defined PARAVISEngine_EXPORTS
00039 #define PARAVIS_ENGINE_EXPORT __declspec(dllexport)
00040 #else
00041 #define PARAVIS_ENGINE_EXPORT __declspec(dllimport)
00042 #endif
00043 #else
00044 #define PARAVIS_ENGINE_EXPORT
00045 #endif
00046 
00047 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
00048 
00049 extern "C" {
00050 PARAVIS_ENGINE_EXPORT PortableServer::ObjectId* PARAVISEngine_factory(CORBA::ORB_ptr orb, 
00051                                                                       PortableServer::POA_ptr poa, 
00052                                                                       PortableServer::ObjectId * contId,
00053                                                                       const char *instanceName, 
00054                                                                       const char *interfaceName) 
00055 {
00056   MESSAGE("PARAVISEngine_factory : "<<interfaceName);
00057   SALOME_NamingService aNamingService(orb);
00058   CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session");
00059   SALOME::Session_var aSession = SALOME::Session::_narrow(anObject);
00060   if (CORBA::is_nil(aSession))
00061     return NULL;
00062   
00063   PARAVIS::PARAVIS_Gen_i* pPARAVIS_Gen = new PARAVIS::PARAVIS_Gen_i(aSession, 
00064                                                                     orb, 
00065                                                                     poa, 
00066                                                                     contId, 
00067                                                                     instanceName, 
00068                                                                     interfaceName);
00069   return pPARAVIS_Gen->getId() ;
00070 }
00071 }
00072 
00073 namespace PARAVIS {
00074   //===========================================================================
00075   PARAVIS_Gen_i::PARAVIS_Gen_i(SALOME::Session_ptr session,
00076                                CORBA::ORB_ptr orb,
00077                                PortableServer::POA_ptr poa,
00078                                PortableServer::ObjectId * contId, 
00079                                const char *instanceName, 
00080                                const char *interfaceName) :
00081     Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
00082   {
00083     _thisObj = this ;
00084     _id = _poa->activate_object(_thisObj);
00085 #ifndef WIN32
00086     Engines::EngineComponent_var aComponent = session->GetComponent("libPARAVIS.so");
00087 #else
00088     Engines::EngineComponent_var aComponent = session->GetComponent("PARAVIS.dll");
00089 #endif
00090     if (CORBA::is_nil(aComponent)) {
00091       MESSAGE("Component PARAVIS is null");
00092       return;
00093     }
00094     myParaVisGen = PARAVIS::PARAVIS_Gen::_narrow(aComponent);
00095   } 
00096   
00097   //===========================================================================
00098   PARAVIS_Gen_i::~PARAVIS_Gen_i()
00099   {
00100     if(MYDEBUG) MESSAGE("PARAVIS_Gen_i::~PARAVIS_Gen_i");
00101   }
00102 
00103 
00104   //===========================================================================
00105   char* PARAVIS_Gen_i::GetIOR(){
00106     return myParaVisGen->GetIOR();
00107   }
00108 
00109   //===========================================================================
00110   bool PARAVIS_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
00111                         const SALOMEDS::TMPFile & theStream,
00112                         const char* theURL,
00113                         bool isMultiFile)
00114   {
00115     return myParaVisGen->Load(theComponent,theStream,theURL,isMultiFile);
00116   }
00117 
00118   //===========================================================================
00119   bool PARAVIS_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
00120                              const SALOMEDS::TMPFile & theStream,
00121                              const char* theURL,
00122                              bool isMultiFile) 
00123   {
00124     return Load(theComponent, theStream, theURL, isMultiFile);
00125   }
00126 
00127 
00128   //===========================================================================
00129   char* PARAVIS_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
00130                                            const char* aLocalPersistentID,
00131                                            CORBA::Boolean isMultiFile,
00132                                            CORBA::Boolean isASCII) 
00133   {
00134     return myParaVisGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
00135   }
00136 
00137   //===========================================================================
00138   SALOMEDS::TMPFile* PARAVIS_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
00139                                   const char* theURL,
00140                                   bool isMultiFile)
00141   {
00142     return myParaVisGen->Save(theComponent,theURL,isMultiFile);
00143   }
00144 
00145   //===========================================================================
00146   SALOMEDS::TMPFile* PARAVIS_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
00147                                       const char* theURL,
00148                                       bool isMultiFile) 
00149   {
00150     return myParaVisGen->Save(theComponent,theURL,isMultiFile);
00151   }
00152 
00153 
00154   //===========================================================================
00155   char* PARAVIS_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
00156                                       const char* IORString,
00157                                       CORBA::Boolean isMultiFile,
00158                                       CORBA::Boolean isASCII) 
00159   {
00160     return myParaVisGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
00161   }
00162 
00163   //===========================================================================
00164   void PARAVIS_Gen_i::ImportFile(const char* theFileName)
00165   {
00166     if (CORBA::is_nil(myParaVisGen)) {
00167       MESSAGE("PARAVIS_Gen_i is null");
00168       return;
00169     }
00170     myParaVisGen->ImportFile(theFileName);
00171   }
00172 
00173   void PARAVIS_Gen_i::ExecuteScript(const char* script)
00174   {
00175     if (CORBA::is_nil(myParaVisGen)) {
00176       MESSAGE("PARAVIS_Gen_i is null");
00177       return;
00178     }
00179     myParaVisGen->ExecuteScript(script);
00180   }
00181 
00182   //===========================================================================
00183   char* PARAVIS_Gen_i::GetTrace()
00184   {
00185     if (CORBA::is_nil(myParaVisGen)) {
00186       MESSAGE("PARAVIS_Gen_i is null");
00187       return CORBA::string_dup("");
00188     }
00189     return CORBA::string_dup(myParaVisGen->GetTrace());
00190   }
00191 
00192   //===========================================================================
00193   void PARAVIS_Gen_i::SaveTrace(const char* theFileName)
00194   {
00195     if (CORBA::is_nil(myParaVisGen)) {
00196       MESSAGE("PARAVIS_Gen_i is null");
00197       return ;
00198     }
00199     myParaVisGen->SaveTrace(theFileName);
00200   }
00201 
00202   //===========================================================================
00203   void PARAVIS_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
00204   {
00205     myParaVisGen->Close(theComponent);
00206   }
00207 
00208 
00209   //===========================================================================
00210   char* PARAVIS_Gen_i::ComponentDataType()
00211   {
00212     return CORBA::string_dup("PARAVIS");
00213   }
00214 
00215   //===========================================================================
00216   CORBA::Boolean PARAVIS_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) 
00217   {
00218     return myParaVisGen->CanPublishInStudy(theIOR);
00219   }
00220 
00221 
00222   //===========================================================================
00223   SALOMEDS::SObject_ptr PARAVIS_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
00224                                              SALOMEDS::SObject_ptr theSObject,
00225                                              CORBA::Object_ptr theObject,
00226                                              const char* theName) 
00227     throw (SALOME::SALOME_Exception) 
00228   {
00229     return myParaVisGen->PublishInStudy(theStudy, theSObject, theObject, theName);
00230   }
00231 
00232   //===========================================================================
00233   CORBA::Boolean PARAVIS_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) 
00234   {
00235     return myParaVisGen->CanCopy(theObject);
00236   }
00237   
00238 
00239   //===========================================================================
00240   SALOMEDS::TMPFile* PARAVIS_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) 
00241   {
00242     return myParaVisGen->CopyFrom(theObject, theObjectID);
00243   }
00244   
00245 
00246   //===========================================================================
00247   CORBA::Boolean PARAVIS_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) 
00248   {
00249     return myParaVisGen->CanPaste(theComponentName, theObjectID);
00250   }
00251 
00252   //===========================================================================
00253   SALOMEDS::SObject_ptr PARAVIS_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
00254                                          CORBA::Long theObjectID,
00255                                          SALOMEDS::SObject_ptr theObject) 
00256   {
00257     return myParaVisGen->PasteInto(theStream,theObjectID,theObject);
00258   }
00259 
00260   //===========================================================================
00261   PARAVIS::string_array* PARAVIS_Gen_i::GetClassesList()
00262   {
00263     return myParaVisGen->GetClassesList();
00264   }
00265 
00266   //===========================================================================
00267   PARAVIS_Base_ptr PARAVIS_Gen_i::CreateClass(const char* theClassName)
00268   {
00269     return myParaVisGen->CreateClass(theClassName);
00270   }
00271 
00272   //===========================================================================
00273   void PARAVIS_Gen_i::GetConnectionParameters(CORBA::Long& theId, 
00274                                               CORBA::String_out theDHost, CORBA::Long& theDPort,
00275                                               CORBA::String_out theRHost, CORBA::Long& theRPort,
00276                                               CORBA::Long& theReversed)
00277   {
00278     myParaVisGen->GetConnectionParameters(theId, theDHost, theDPort, theRHost, theRPort, theReversed);
00279   }
00280     
00281   //===========================================================================
00282   void PARAVIS_Gen_i::ActivateModule()
00283   {
00284     myParaVisGen->ActivateModule();
00285   }
00286 
00287   //===========================================================================
00288   void PARAVIS_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
00289     myParaVisGen->SetCurrentStudy(theStudy);
00290   }
00291 
00292 
00293   //===========================================================================
00294   SALOMEDS::Study_ptr PARAVIS_Gen_i::GetCurrentStudy(){
00295     return myParaVisGen->GetCurrentStudy();
00296   }
00297 }