From 47e7f5e178afa3dd200bac0211dd157c71d4a5bf Mon Sep 17 00:00:00 2001 From: rahuel Date: Wed, 19 Oct 2005 09:44:54 +0000 Subject: [PATCH] Names sof implementation files --- .../SIGNALSComponent_CheckOfUndefined.cxx | 159 ++++++++++++++++++ .../SIGNALSComponent_Impl.cxx | 125 ++++++++++++++ .../SIGNALSComponent_Impl.hxx | 69 ++++++++ .../libSIGNALSComponent_Swig.i | 6 +- 4 files changed, 356 insertions(+), 3 deletions(-) create mode 100644 src/SIGNALSComponent/SIGNALSComponent_CheckOfUndefined.cxx create mode 100755 src/SIGNALSComponent/SIGNALSComponent_Impl.cxx create mode 100755 src/SIGNALSComponent/SIGNALSComponent_Impl.hxx diff --git a/src/SIGNALSComponent/SIGNALSComponent_CheckOfUndefined.cxx b/src/SIGNALSComponent/SIGNALSComponent_CheckOfUndefined.cxx new file mode 100644 index 0000000..02a8705 --- /dev/null +++ b/src/SIGNALSComponent/SIGNALSComponent_CheckOfUndefined.cxx @@ -0,0 +1,159 @@ +// SALOME Container : implementation of container and engine for Kernel +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOME_Container.cxx +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Module : SALOME +// $Header$ + +#include +#include +#include + +#ifndef WNT +#include +#else +#include +#endif +#include "SALOME_Container_i.hxx" +#include "utilities.h" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "SALOMETraceCollector.hxx" +#include "OpUtil.hxx" + +#ifdef CHECKTIME +#include +#endif + +#ifdef HAVE_MPI2 +#include +#endif + +#include "Container_init_python.hxx" + +using namespace std; + +extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB); + +int main(int argc, char* argv[]) +{ +#ifdef HAVE_MPI2 + MPI_Init(&argc,&argv); +#endif + + // Initialise the ORB. + //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb + //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ; + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()); + CORBA::ORB_var orb = init(0 , 0 ) ; + + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); + INFOS_COMPILATION; + BEGIN_OF(argv[0]); + + ASSERT(argc > 1); + SCRUTE(argv[1]); + bool isSupervContainer = false; + if (strcmp(argv[1],"SuperVisionContainer") == 0) isSupervContainer = true; + + if (!isSupervContainer) + { + int _argc = 1; + char* _argv[] = {""}; + KERNEL_PYTHON::init_python(argc,argv); + } + else + { + Py_Initialize() ; + PySys_SetArgv( argc , argv ) ; + } + + char *containerName = ""; + if(argc > 1) + { + containerName = argv[1] ; + } + + try + { + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + ASSERT(!CORBA::is_nil(obj)); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); + + PortableServer::POAManager_var pman = root_poa->the_POAManager(); + + // add new container to the kill list +#ifndef WNT + char aCommand[40]; + sprintf(aCommand, "addToKillList.py %d SALOME_Container", getpid()); + system(aCommand); +#endif + + Engines_Container_i * myContainer + = new Engines_Container_i(orb, root_poa, containerName , argc , argv ); + + pman->activate(); + +#ifdef CHECKTIME + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); +#endif + + HandleServerSideSignals(orb); + + } + catch(CORBA::SystemException&) + { + INFOS("Caught CORBA::SystemException."); + } + catch(PortableServer::POA::ServantAlreadyActive&) + { + INFOS("Caught CORBA::ServantAlreadyActiveException"); + } + catch(CORBA::Exception&) + { + INFOS("Caught CORBA::Exception."); + } + catch(std::exception& exc) + { + INFOS("Caught std::exception - "< +#include +#include +#include +#include + +//#include "utilities.h" +#include "SIGNALSComponent_Impl.hxx" + +SIGNALSComponent_Impl::SIGNALSComponent_Impl( CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) +{ + MESSAGE("SIGNALSComponent_Impl::SIGNALSComponent_Impl activate object instanceName(" + << instanceName << ") interfaceName(" << interfaceName << ")" ) + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + NULLPTR = NULL ; +} + +SIGNALSComponent_Impl::SIGNALSComponent_Impl() : + Engines_Component_i() +{ + NULLPTR = NULL ; +} + +SIGNALSComponent_Impl::~SIGNALSComponent_Impl() +{ +} + +long SIGNALSComponent_Impl::SIGSEGVfunc() { + beginService( " SIGNALSComponent_Impl::SIGSEGVfunc" ); + cout << pthread_self() << "SIGNALSComponent_Impl::SIGSEGVfunc" << endl ; + int S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + while ( S ) { + S = sleep( S ) ; + } + long nullptr = *NULLPTR ; + endService( " SIGNALSComponent_Impl::SIGSEGVfunc" ); + return nullptr ; +} + +long SIGNALSComponent_Impl::SIGFPEfunc( long a , long b ) { + beginService( " SIGNALSComponent_Impl::SIGFPEfunc" ); + cout << pthread_self() << "SIGNALSComponent_Impl::SIGFPEfunc" << endl ; + int S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + while ( S ) { + S = sleep( S ) ; + } + long c = a/b ; + endService( " SIGNALSComponent_Impl::SIGFPEfunc" ); + return c ; +} + +void SIGNALSComponent_Impl::MethodToKill() { + beginService( " SIGNALSComponent_Impl::MethodToKill" ); + while ( 1 ) { + sleep(1) ; + } + endService( " SIGNALSComponent_Impl::MethodToKill" ); + return ; +} + +void * RunMethodToKill( void * ptr ) { + SIGNALSComponent_Impl * mySIGNALSComponent ; + mySIGNALSComponent = ( SIGNALSComponent_Impl * ) ptr ; + mySIGNALSComponent->MethodToKill() ; + return ptr ; +} + +void SIGNALSComponent_Impl::WaitKill() { + pthread_t T; + pthread_create( &T , NULL , RunMethodToKill , this ) ; + pthread_join( T , NULL ) ; +} + +extern "C" +{ + PortableServer::ObjectId * SIGNALSComponentEngine_factory + (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + MESSAGE("SIGNALSComponentEngine_factory SIGNALSComponent_Impl(" + << instanceName << "," << interfaceName << ")"); + SIGNALSComponent_Impl * mySIGNALSComponent + = new SIGNALSComponent_Impl(orb, poa, contId, instanceName, interfaceName); + return mySIGNALSComponent->getId() ; + } +} + + diff --git a/src/SIGNALSComponent/SIGNALSComponent_Impl.hxx b/src/SIGNALSComponent/SIGNALSComponent_Impl.hxx new file mode 100755 index 0000000..7b2a2c5 --- /dev/null +++ b/src/SIGNALSComponent/SIGNALSComponent_Impl.hxx @@ -0,0 +1,69 @@ +// SuperVisionTest SIGNALSComponent : example of component that devides two numbers +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SIGNALSComponent.hxx +// Author : MARC TAJCHMAN, CEA +// Module : SuperVisionTest +// $Header$ + +#ifndef _SIGNALSCOMPONENT_IMPL_HXX_ +#define _SIGNALSCOMPONENT_IMPL_HXX_ + +//#include +#include +#include CORBA_SERVER_HEADER(SIGNALSComponent) +#include CORBA_SERVER_HEADER(SALOME_Component) +#include "SALOME_Component_i.hxx" + +class SIGNALSComponent_Impl : public POA_SuperVisionTest::SIGNALSComponent , + public Engines_Component_i { +public: + SIGNALSComponent_Impl() ; + SIGNALSComponent_Impl( CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + + virtual ~SIGNALSComponent_Impl(); + + long SIGSEGVfunc() ; + long SIGFPEfunc( long a , long b ) ; + void MethodToKill() ; + void WaitKill() ; + +private: + + long * NULLPTR ; + +}; + +extern "C" + PortableServer::ObjectId * SIGNALSComponentEngine_factory + ( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName ) ; + +#endif diff --git a/src/SIGNALSComponent_Swig/libSIGNALSComponent_Swig.i b/src/SIGNALSComponent_Swig/libSIGNALSComponent_Swig.i index 2406947..e46ec57 100644 --- a/src/SIGNALSComponent_Swig/libSIGNALSComponent_Swig.i +++ b/src/SIGNALSComponent_Swig/libSIGNALSComponent_Swig.i @@ -26,12 +26,12 @@ %module libSIGNALSComponent_Swig %{ -#include "SIGNALSComponent.hxx" +#include "SIGNALSComponent_Impl.hxx" %} -class SIGNALSComponentEngine { +class SIGNALSComponent_Impl { public: - SIGNALSComponentEngine(){}; + SIGNALSComponent_Impl(){}; long SIGSEGVfunc() ; long SIGFPEfunc( long a , long b ) ; }; -- 2.39.2