Salome HOME
Used for test of omniORB4 : problem with object references
[modules/superv.git] / src / GraphBase / SuperVisionBase_CheckOfUndefined.cxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SuperVisionBase_CheckOfUndefined.cxx
25 //  Module : SUPERV
26
27 using namespace std;
28 #include <iostream>
29 #include <fstream>
30 #include <unistd.h>
31
32 #include "Utils_ORB_INIT.hxx"
33 #include "Utils_SINGLETON.hxx"
34
35 #include "SALOME_NamingService.hxx"
36 #include "SALOME_LifeCycleCORBA.hxx"
37
38 #include "DataFlowBase_Base.hxx"
39
40 int _ArgC ;
41 char ** _ArgV ;
42
43 int main(int argc, char **argv) {
44
45   Engines::Component_ptr objComponent ;
46   char * IOR ;
47
48   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
49   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
50   CORBA::ORB_var &orb = init( argc , argv ) ;
51
52   SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
53
54   SALOME_LifeCycleCORBA LCC( NamingService ) ;
55   objComponent = LCC.FindOrLoad_Component( "FactoryServer" , "AddComponent" );
56   if ( CORBA::is_nil( objComponent ) ) {
57     cout << "ERROR LCC.FindOrLoad_Component( FactoryServer , AddComponent )" << endl;
58     return 0 ;
59   }
60   objComponent->ping() ;
61
62   IOR = orb->object_to_string( objComponent );
63   cout << "objComponent " << objComponent << " IOR " << IOR << " nil "
64        << CORBA::is_nil( objComponent ) << endl ;
65
66   Engines::Component_ptr mySuperVision ;
67   mySuperVision = LCC.FindOrLoad_Component( "SuperVisionContainer","SUPERV" ) ;
68   SUPERV::SuperG_ptr mySuperVisionComponent ;
69   mySuperVisionComponent =  SUPERV::SuperG::_narrow( mySuperVision ) ;
70
71   CORBA::Any anAny ;
72 //  anAny <<= CORBA::Object::_nil() ;
73   anAny <<= objComponent ;
74 //  CORBA::Any anAny = CORBA::Any( CORBA::_tc_Object, objComponent ) ;
75 //  anAny.replace( CORBA::_tc_Object, objComponent );
76
77   CORBA::Object * obj ;
78   anAny >>= obj ;
79
80   IOR = orb->object_to_string( objComponent );
81   cout << "objComponent " << objComponent << " IOR " << IOR << " nil "
82        << CORBA::is_nil( objComponent ) << endl ;
83
84 // Crash
85 //  IOR = orb->object_to_string( obj );
86 //  cout << "obj " << obj << " IOR " << IOR << " nil " << CORBA::is_nil( obj )
87 //       << endl ;
88
89   Engines::Component_ptr objComponentfromAny ;
90   objComponentfromAny = Engines::Component::_narrow( obj ) ;
91   IOR = orb->object_to_string( objComponentfromAny );
92   cout << "obComponentfromAny " << objComponentfromAny << " IOR " << IOR << " nil "
93        << CORBA::is_nil( objComponentfromAny ) << endl ;
94
95
96
97 //  CORBA::Object_var myObj = NamingService->ResolveComponent("xmen","FactoryServer" ,
98 //                                                            "AddComponent" );
99 //  SuperVisionTest::AddComponent_ptr myObjComponent ;
100 //  myObjComponent = SuperVisionTest::AddComponent::_narrow( myObj ) ;
101 //  IOR = orb->object_to_string( myObjComponent );
102 //  cout << "myObjComponent " << myObjComponent << " IOR " << IOR << " nil "
103 //       << CORBA::is_nil( myObjComponent ) << endl ;
104 //  anAny <<= myObjComponent ;
105 //  anAny >>= obj ;
106 //  objComponentfromAny = Engines::Component::_narrow( obj ) ;
107 //  IOR = orb->object_to_string( objComponentfromAny );
108 //  cout << "objComponentfromAny " << objComponentfromAny << " IOR " << IOR << " nil "
109 //       << CORBA::is_nil( objComponentfromAny ) << endl ;
110
111 //  SuperVisionTest::Adder_ptr myAdder = myObjComponent->Addition() ;
112 //  myAdder->ping() ;
113 //  IOR = orb->object_to_string( myAdder );
114 //  cout << "myAdder " << myAdder << " IOR " << IOR << " nil "
115 //       << CORBA::is_nil( myAdder ) << endl ;
116 //  anAny <<=  myAdder ;
117 //  anAny <<=  orb->string_to_object( IOR ) ;
118 //  anAny >>= obj ;
119 //  SuperVisionTest::Adder_ptr objAdderfromAny ;
120 //  objAdderfromAny = SuperVisionTest::Adder::_narrow( obj ) ;
121 //  IOR = orb->object_to_string( objAdderfromAny );
122 //  cout << "objAdderfromAny " << objAdderfromAny << " IOR " << IOR << " nil "
123 //       << CORBA::is_nil( objAdderfromAny ) << endl ;
124   
125
126 //  Engines::Container_ptr myContainer = myObjComponent-> GetContainerRef() ;
127 //  IOR = orb->object_to_string( myContainer );
128 //  cout << "myContainer " << myContainer << " IOR " << IOR << " nil "
129 //       << CORBA::is_nil( myContainer ) << endl ;
130 //  anAny <<= myContainer ;
131 //  anAny >>= obj ;
132 //  Engines::Container_ptr objContainerfromAny ;
133 //  objContainerfromAny = Engines::Container::_narrow( obj ) ;
134 //  IOR = orb->object_to_string( objContainerfromAny );
135 //  cout << "objContainerfromAny " << objContainerfromAny << " IOR " << IOR << " nil "
136 //       << CORBA::is_nil( objContainerfromAny ) << endl ;
137
138
139   return 0;
140 }
141