Back to index

salome-smesh  6.5.0
SPADDERPluginTester_i.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2011-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 // Authors : Guillaume Boulant (EDF) - 01/03/2011
00020 
00021 #include "SPADDERPluginTester_i.hxx"
00022 
00023 #include <SALOME_NamingService.hxx>
00024 #include <Utils_SALOME_Exception.hxx>
00025 
00026 // For standard logging
00027 #include "Basics_Utils.hxx"
00028 
00029 //
00030 // ==========================================================================
00031 // Implementation of the SPADDER component interface
00032 // ==========================================================================
00033 //
00034 using namespace std;
00035 
00039 SPADDERPluginTester_i::SPADDERPluginTester_i(CORBA::ORB_ptr orb,
00040                                              PortableServer::POA_ptr poa,
00041                                              PortableServer::ObjectId * contId,
00042                                              const char *instanceName,
00043                                              const char *interfaceName)
00044   : Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
00045 {
00046   LOG("Activating SPADDERPluginTester_i::SPADDERPluginTester object");
00047   _thisObj = this ;
00048   _id = _poa->activate_object(_thisObj);
00049 }
00050 
00052 SPADDERPluginTester_i::~SPADDERPluginTester_i()
00053 {
00054   std::cerr << "SPADDERPluginTester destruction" << std::endl;
00055 }
00056 
00060 void SPADDERPluginTester_i::demo(CORBA::Double a,CORBA::Double b,CORBA::Double& c)
00061 {
00062   beginService("SPADDERPluginTester_i::demo");
00063   try {
00064     //BODY
00065     
00066     std::cerr << "a: " << a << std::endl;
00067     std::cerr << "b: " << b << std::endl;
00068     c=a+b;
00069     std::cerr << "c: " << c << std::endl;
00070     
00071   }
00072   catch ( const SALOME_Exception & ex) {
00073     SALOME::ExceptionStruct es;
00074     es.text=CORBA::string_dup(ex.what());
00075     es.type=SALOME::INTERNAL_ERROR;
00076     throw SALOME::SALOME_Exception(es);
00077   }
00078   catch ( const SALOME::SALOME_Exception & ex) {
00079     throw;
00080   }
00081   catch (...) {
00082     std::cerr << "unknown exception" << std::endl;
00083     SALOME::ExceptionStruct es;
00084     es.text=CORBA::string_dup(" unknown exception");
00085     es.type=SALOME::INTERNAL_ERROR;
00086     throw SALOME::SALOME_Exception(es);
00087   }
00088   endService("SPADDERPluginTester_i::demo");
00089 }
00090 
00091 #ifdef LOG
00092 #undef LOG
00093 #endif
00094 
00095 #include <SALOME_KernelServices.hxx>
00096 #include "SALOME_Launcher.hxx"
00097 bool SPADDERPluginTester_i::testkernel()
00098 {
00099   beginService("SPADDERPluginTester_i::testplugin");
00100 
00101   Engines::SalomeLauncher_ptr salomeLauncher = KERNEL::getSalomeLauncher();
00102 
00103   endService("SPADDERPluginTester_i::testplugin");
00104   return true;
00105 }
00106 
00107 
00108 #include <SMESH_Gen_i.hxx>
00109 #include <SMESH_Gen.hxx>
00110 #include <SALOMEconfig.h>
00111 #include CORBA_CLIENT_HEADER(SALOMEDS)
00112 
00113 #include <utilities.h>
00114 
00119 bool SPADDERPluginTester_i::testsmesh(CORBA::Long studyId)
00120 {
00121   beginService("SPADDERPluginTester_i::testsmesh");
00122 
00123   // Resolve the SMESH engine and the SALOME study
00124   // _WARN_ The SMESH engine should have been loaded first
00125   SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
00126   CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
00127   SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
00128   SALOMEDS::Study_var myStudy = aStudyMgr->GetStudyByID(studyId);
00129 
00130   //
00131   // _MEM_ CAUTION: SMESH_Gen define a data structure for local usage
00132   // while SMESH_Gen_i is the implementation of the SMESH_Gen IDL
00133   // interface.
00134   //
00135 
00136   endService("SPADDERPluginTester_i::testsmesh");
00137   return true;
00138 }
00139 
00140 //
00141 // ==========================================================================
00142 // Factory services
00143 // ==========================================================================
00144 //
00145 extern "C"
00146 {
00147   PortableServer::ObjectId * SPADDERPluginTesterEngine_factory( CORBA::ORB_ptr orb,
00148                                                                 PortableServer::POA_ptr poa,
00149                                                                 PortableServer::ObjectId * contId,
00150                                                                 const char *instanceName,
00151                                                                 const char *interfaceName)
00152   {
00153     MESSAGE("PortableServer::ObjectId * SPADDERPluginTesterEngine_factory()");
00154     SPADDERPluginTester_i * myEngine = new SPADDERPluginTester_i(orb, poa, contId, instanceName, interfaceName);
00155     return myEngine->getId() ;
00156   }
00157 }