-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 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 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, or (at your option) any later version.
//
-// 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.
+// 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// SuperVisionTest AdditionComponent : example of component that adds two numbers
// File : AdditionComponent_Impl.cxx
// Author : Jean Rahuel, CEA
// Module : SuperVisionTest
//
#include <stdio.h>
+#ifndef WIN32
#include <unistd.h>
+#else
+#include <process.h>
+#endif
#include <fstream>
#include <sstream>
#include <string>
#include "utilities.h"
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
+#include "OpUtil.hxx"
#include "SALOME_NamingService.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
+#include "SALOME_Container_i.hxx"
#include "AdditionComponent_Impl.hxx"
-#include "Adder_Impl.hxx"
+#include "Addition_Adder_Impl.hxx"
+#include "COMPONENT_version.h"
using namespace std;
PortableServer::POA_ptr poa,
PortableServer::ObjectId * contId,
const char *instanceName,
- const char *interfaceName) :
- Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) {
+ const char *interfaceName, bool withRegistry) :
+ Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,withRegistry) {
MESSAGE("AdditionInterface_Impl::AdditionInterface_Impl this " << hex << this << dec
<< "activate object instanceName("
- << instanceName << ") interfaceName(" << interfaceName << ")" )
+ << instanceName << ") interfaceName(" << interfaceName << ")" );
_thisObj = this ;
_id = _poa->activate_object(_thisObj);
LastAddition = 0 ;
AdditionInterface_Impl::~AdditionInterface_Impl() {
}
+char* AdditionInterface_Impl::getVersion()
+{
+#if COMPONENT_DEVELOPMENT
+ return CORBA::string_dup(COMPONENT_VERSION_STR"dev");
+#else
+ return CORBA::string_dup(COMPONENT_VERSION_STR);
+#endif
+}
+
CORBA::Double AdditionInterface_Impl::Add( CORBA::Double x , CORBA::Double y , CORBA::Double & z ) {
beginService( " AdditionInterface_Impl::Add" );
z = x + y ;
sendMessage(NOTIF_STEP, "AdditionInterface_Impl::Add is Computing");
// S = 1+(int) (15.0*rand()/(RAND_MAX+1.0));
S = 5 ;
+#ifndef WIN32
while ( S ) {
- S = sleep(S);
+ S = sleep( S ) ;
}
- MESSAGE( "AdditionInterface_Impl::Add( " << x << " , " << y << " , " << z
- << " ) returns " << (x - y) << " after " << S << " seconds" )
+#else
+ Sleep(S*1000);
+#endif
+ MESSAGE( "AdditionInterface_Impl::Add( " << x << " , " << y << " , " << z << " ) returns " << (x - y) << " after " << S << " seconds" );
LastAddition = z ;
endService( " AdditionInterface_Impl::Add" );
return (x - y) ;
void AdditionInterface_Impl::Setx( CORBA::Double x ) {
int S = 1+(int) (15.0*rand()/(RAND_MAX+1.0));
+#ifndef WIN32
while ( S ) {
- S = sleep(S);
+ S = sleep( S ) ;
}
+#else
+ Sleep(S*1000);
+#endif
xx = x ;
}
void AdditionInterface_Impl::Sety( CORBA::Double y ) {
int S = 1+(int) (15.0*rand()/(RAND_MAX+1.0));
+#ifndef WIN32
while ( S ) {
- S = sleep(S);
+ S = sleep( S ) ;
}
+#else
+ Sleep(S*1000);
+#endif
yy = y ;
}
CORBA::Double AdditionInterface_Impl::Addxy() {
int S = 1+(int) (15.0*rand()/(RAND_MAX+1.0));
+#ifndef WIN32
while ( S ) {
- S = sleep(S);
+ S = sleep( S ) ;
}
+#else
+ Sleep(S*1000);
+#endif
double zz = xx + yy ;
LastAddition = zz ;
return zz;
CORBA::Double AdditionInterface_Impl::AddyTox( CORBA::Double y ) {
int S = 1+(int) (15.0*rand()/(RAND_MAX+1.0));
+#ifndef WIN32
while ( S ) {
- S = sleep(S);
+ S = sleep( S ) ;
}
+#else
+ Sleep(S*1000);
+#endif
double zz = xx + y ;
LastAddition = zz ;
return zz;
beginService( "AdditionInterface_Impl::Addition" );
sendMessage(NOTIF_STEP, "AdditionInterface_Impl creates Adder_Impl");
Adder_Impl * myAdder ;
- myAdder = new Adder_Impl( _orb , _poa, _contId,
- instanceName() , interfaceName() ,
- graphName() , nodeName() ) ;
+ myAdder = this->BuildNewAdderImplObj() ;
AdditionComponent::Adder_var iobject ;
PortableServer::ObjectId * id = myAdder->getId() ;
CORBA::Object_var obj = _poa->id_to_reference(*id);
// return AdditionComponent::Adder::_duplicate(iobject) ;
}
+Adder_Impl *AdditionInterface_Impl::BuildNewAdderImplObj()
+{
+ Engines::Container_var cont = this->GetContainerRef();
+ if( cont->is_SSL_mode() )
+ {
+ return new Adder_Impl_SSL( _orb , _poa, _contId, instanceName() , interfaceName() , graphName() , nodeName() ) ;
+ }
+ else
+ {
+ return new Adder_Impl_No_SSL( _orb , _poa, _contId, instanceName() , interfaceName() , graphName() , nodeName() ) ;
+ }
+}
+
bool AdditionInterface_Impl::AdditionObjRef1( AdditionComponent::Adder_out aAdder ) {
beginService( "AdditionInterface_Impl::Addition" );
sendMessage(NOTIF_STEP, "AdditionInterface_Impl creates Adder_Impl");
- Adder_Impl * myAdder ;
- myAdder = new Adder_Impl( _orb , _poa, _contId,
- instanceName() , interfaceName() ,
- graphName() , nodeName() ) ;
+ Adder_Impl * myAdder = nullptr;
+ myAdder = this->BuildNewAdderImplObj() ;
AdditionComponent::Adder_var iobject ;
PortableServer::ObjectId * id = myAdder->getId() ;
CORBA::Object_var obj = _poa->id_to_reference(*id);
beginService( "AdditionInterface_Impl::Addition" );
sendMessage(NOTIF_STEP, "AdditionInterface_Impl creates Adder_Impl");
Adder_Impl * myAdder ;
- myAdder = new Adder_Impl( _orb , _poa, _contId,
- instanceName() , interfaceName() ,
- graphName() , nodeName() ) ;
+ myAdder = this->BuildNewAdderImplObj() ;
AdditionComponent::Adder_var iobject ;
PortableServer::ObjectId * id = myAdder->getId() ;
CORBA::Object_var obj = _poa->id_to_reference(*id);
bool RetVal = true ;
beginService( "AdditionInterface_Impl::AdditionObjRefs" );
cout << "beginService AdditionInterface_Impl::AdditionObjRefs" << endl ;
- ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
- CORBA::ORB_var orb = init(0 , 0 ) ;
+ CORBA::ORB_var orb = KERNEL::GetRefToORB();
char * IOR = orb->object_to_string( AdditionInterface1 );
cout << "AdditionInterface_Impl::AdditionObjRefs AdditionInterface1 " << AdditionInterface1 << " IOR "
<< IOR << " nil " << CORBA::is_nil( AdditionInterface1 ) << endl ;
const char *instanceName,
const char *interfaceName)
{
+#ifndef WIN32
MESSAGE("AdditionComponentEngine_factory AdditionInterfaceEngine ("
<< instanceName << "," << interfaceName << "," << getpid() << ")");
- AdditionInterface_Impl * myAdditionInterface
- = new AdditionInterface_Impl(orb, poa, contId, instanceName, interfaceName);
+#else
+ MESSAGE("AdditionComponentEngine_factory AdditionInterfaceEngine ("
+ << instanceName << "," << interfaceName << "," << _getpid() << ")");
+#endif
+ AdditionInterface_Impl * myAdditionInterface = nullptr;
+ CORBA::Object_var o = poa->id_to_reference(*contId);
+ Engines::Container_var cont = Engines::Container::_narrow(o);
+ if(cont->is_SSL_mode())
+ {
+ myAdditionInterface = new AdditionInterface_Impl_SSL(orb, poa, contId, instanceName, interfaceName);
+ }
+ else
+ {
+ myAdditionInterface = new AdditionInterface_Impl_No_SSL(orb, poa, contId, instanceName, interfaceName);
+ }
return myAdditionInterface->getId() ;
}
}