Salome HOME
Used for test of omniORB4 : problem with object references
authorrahuel <rahuel@opencascade.com>
Tue, 30 Aug 2005 06:50:16 +0000 (06:50 +0000)
committerrahuel <rahuel@opencascade.com>
Tue, 30 Aug 2005 06:50:16 +0000 (06:50 +0000)
src/GraphBase/SuperVisionBase_CheckOfUndefined.cxx

index e41144bf8ea4a66125c49e86d19c887a2fa9539e..4e24a56d98f1cd4675647cf26d18215c96b32bcf 100644 (file)
@@ -35,14 +35,14 @@ using namespace std;
 #include "SALOME_NamingService.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
 
+#include "DataFlowBase_Base.hxx"
+
 int _ArgC ;
 char ** _ArgV ;
 
 int main(int argc, char **argv) {
 
-  Engines::Component_var objComponent ;
-  CORBA::Any * anAny = new CORBA::Any() ;
-  CORBA::Object_ptr obj ;
+  Engines::Component_ptr objComponent ;
   char * IOR ;
 
   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
@@ -54,19 +54,87 @@ int main(int argc, char **argv) {
   SALOME_LifeCycleCORBA LCC( NamingService ) ;
   objComponent = LCC.FindOrLoad_Component( "FactoryServer" , "AddComponent" );
   if ( CORBA::is_nil( objComponent ) ) {
-    //cout << " LCC.FindOrLoad_Component( FactoryServer , AddComponent )" << endl;
+    cout << "ERROR LCC.FindOrLoad_Component( FactoryServer , AddComponent )" << endl;
     return 0 ;
   }
+  objComponent->ping() ;
 
-  *anAny <<= objComponent ;
   IOR = orb->object_to_string( objComponent );
-  //cout << "objComponent " << objComponent << " IOR " << IOR << " nil " << CORBA::is_nil( objComponent )
-  //       << endl ;
+  cout << "objComponent " << objComponent << " IOR " << IOR << " nil "
+       << CORBA::is_nil( objComponent ) << endl ;
+
+  Engines::Component_ptr mySuperVision ;
+  mySuperVision = LCC.FindOrLoad_Component( "SuperVisionContainer","SUPERV" ) ;
+  SUPERV::SuperG_ptr mySuperVisionComponent ;
+  mySuperVisionComponent =  SUPERV::SuperG::_narrow( mySuperVision ) ;
+
+  CORBA::Any anAny ;
+//  anAny <<= CORBA::Object::_nil() ;
+  anAny <<= objComponent ;
+//  CORBA::Any anAny = CORBA::Any( CORBA::_tc_Object, objComponent ) ;
+//  anAny.replace( CORBA::_tc_Object, objComponent );
+
+  CORBA::Object * obj ;
+  anAny >>= obj ;
+
+  IOR = orb->object_to_string( objComponent );
+  cout << "objComponent " << objComponent << " IOR " << IOR << " nil "
+       << CORBA::is_nil( objComponent ) << endl ;
+
+// Crash
+//  IOR = orb->object_to_string( obj );
+//  cout << "obj " << obj << " IOR " << IOR << " nil " << CORBA::is_nil( obj )
+//       << endl ;
+
+  Engines::Component_ptr objComponentfromAny ;
+  objComponentfromAny = Engines::Component::_narrow( obj ) ;
+  IOR = orb->object_to_string( objComponentfromAny );
+  cout << "obComponentfromAny " << objComponentfromAny << " IOR " << IOR << " nil "
+       << CORBA::is_nil( objComponentfromAny ) << endl ;
+
+
+
+//  CORBA::Object_var myObj = NamingService->ResolveComponent("xmen","FactoryServer" ,
+//                                                            "AddComponent" );
+//  SuperVisionTest::AddComponent_ptr myObjComponent ;
+//  myObjComponent = SuperVisionTest::AddComponent::_narrow( myObj ) ;
+//  IOR = orb->object_to_string( myObjComponent );
+//  cout << "myObjComponent " << myObjComponent << " IOR " << IOR << " nil "
+//       << CORBA::is_nil( myObjComponent ) << endl ;
+//  anAny <<= myObjComponent ;
+//  anAny >>= obj ;
+//  objComponentfromAny = Engines::Component::_narrow( obj ) ;
+//  IOR = orb->object_to_string( objComponentfromAny );
+//  cout << "objComponentfromAny " << objComponentfromAny << " IOR " << IOR << " nil "
+//       << CORBA::is_nil( objComponentfromAny ) << endl ;
+
+//  SuperVisionTest::Adder_ptr myAdder = myObjComponent->Addition() ;
+//  myAdder->ping() ;
+//  IOR = orb->object_to_string( myAdder );
+//  cout << "myAdder " << myAdder << " IOR " << IOR << " nil "
+//       << CORBA::is_nil( myAdder ) << endl ;
+//  anAny <<=  myAdder ;
+//  anAny <<=  orb->string_to_object( IOR ) ;
+//  anAny >>= obj ;
+//  SuperVisionTest::Adder_ptr objAdderfromAny ;
+//  objAdderfromAny = SuperVisionTest::Adder::_narrow( obj ) ;
+//  IOR = orb->object_to_string( objAdderfromAny );
+//  cout << "objAdderfromAny " << objAdderfromAny << " IOR " << IOR << " nil "
+//       << CORBA::is_nil( objAdderfromAny ) << endl ;
+  
+
+//  Engines::Container_ptr myContainer = myObjComponent-> GetContainerRef() ;
+//  IOR = orb->object_to_string( myContainer );
+//  cout << "myContainer " << myContainer << " IOR " << IOR << " nil "
+//       << CORBA::is_nil( myContainer ) << endl ;
+//  anAny <<= myContainer ;
+//  anAny >>= obj ;
+//  Engines::Container_ptr objContainerfromAny ;
+//  objContainerfromAny = Engines::Container::_narrow( obj ) ;
+//  IOR = orb->object_to_string( objContainerfromAny );
+//  cout << "objContainerfromAny " << objContainerfromAny << " IOR " << IOR << " nil "
+//       << CORBA::is_nil( objContainerfromAny ) << endl ;
 
-  *anAny >>= obj ;
-  IOR = orb->object_to_string( obj );
-  //cout << "obj " << obj << " IOR " << IOR << " nil " << CORBA::is_nil( obj )
-  //       << endl ;
 
   return 0;
 }