Salome HOME
3da252387b280832c234b9f0918763c4f0fcf0ae
[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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 #include CORBA_CLIENT_HEADER(SALOME_Component)
41
42
43
44 int _ArgC ;
45 char ** _ArgV ;
46
47 int main(int argc, char **argv) {
48
49   Engines::Component_ptr objComponent ;
50   char * IOR ;
51
52   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
53   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
54   CORBA::ORB_var &orb = init( argc , argv ) ;
55
56   SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
57
58   SALOME_LifeCycleCORBA LCC( NamingService ) ;
59   objComponent = LCC.FindOrLoad_Component( "FactoryServer" , "AddComponent" );
60   if ( CORBA::is_nil( objComponent ) ) {
61     cout << "ERROR LCC.FindOrLoad_Component( FactoryServer , AddComponent )" << endl;
62     return 0 ;
63   }
64   objComponent->ping() ;
65
66   IOR = orb->object_to_string( objComponent );
67   cout << "objComponent " << objComponent << " IOR " << IOR << " nil "
68        << CORBA::is_nil( objComponent ) << endl ;
69
70   Engines::Component_ptr mySuperVision ;
71   mySuperVision = LCC.FindOrLoad_Component( "SuperVisionContainer","SUPERV" ) ;
72   SUPERV::SuperG_ptr mySuperVisionComponent ;
73   mySuperVisionComponent =  SUPERV::SuperG::_narrow( mySuperVision ) ;
74
75   CORBA::Any anAny ;
76 //  anAny <<= CORBA::Object::_nil() ;
77   anAny <<= objComponent ;
78 //  CORBA::Any anAny = CORBA::Any( CORBA::_tc_Object, objComponent ) ;
79 //  anAny.replace( CORBA::_tc_Object, objComponent );
80
81   CORBA::Object * obj ;
82   anAny >>= obj ;
83
84   IOR = orb->object_to_string( objComponent );
85   cout << "objComponent " << objComponent << " IOR " << IOR << " nil "
86        << CORBA::is_nil( objComponent ) << endl ;
87
88 // Crash
89 //  IOR = orb->object_to_string( obj );
90 //  cout << "obj " << obj << " IOR " << IOR << " nil " << CORBA::is_nil( obj )
91 //       << endl ;
92
93   Engines::Component_ptr objComponentfromAny ;
94   objComponentfromAny = Engines::Component::_narrow( obj ) ;
95   IOR = orb->object_to_string( objComponentfromAny );
96   cout << "obComponentfromAny " << objComponentfromAny << " IOR " << IOR << " nil "
97        << CORBA::is_nil( objComponentfromAny ) << endl ;
98
99
100
101 //  CORBA::Object_var myObj = NamingService->ResolveComponent("xmen","FactoryServer" ,
102 //                                                            "AddComponent" );
103 //  SuperVisionTest::AddComponent_ptr myObjComponent ;
104 //  myObjComponent = SuperVisionTest::AddComponent::_narrow( myObj ) ;
105 //  IOR = orb->object_to_string( myObjComponent );
106 //  cout << "myObjComponent " << myObjComponent << " IOR " << IOR << " nil "
107 //       << CORBA::is_nil( myObjComponent ) << endl ;
108 //  anAny <<= myObjComponent ;
109 //  anAny >>= obj ;
110 //  objComponentfromAny = Engines::Component::_narrow( obj ) ;
111 //  IOR = orb->object_to_string( objComponentfromAny );
112 //  cout << "objComponentfromAny " << objComponentfromAny << " IOR " << IOR << " nil "
113 //       << CORBA::is_nil( objComponentfromAny ) << endl ;
114
115 //  SuperVisionTest::Adder_ptr myAdder = myObjComponent->Addition() ;
116 //  myAdder->ping() ;
117 //  IOR = orb->object_to_string( myAdder );
118 //  cout << "myAdder " << myAdder << " IOR " << IOR << " nil "
119 //       << CORBA::is_nil( myAdder ) << endl ;
120 //  anAny <<=  myAdder ;
121 //  anAny <<=  orb->string_to_object( IOR ) ;
122 //  anAny >>= obj ;
123 //  SuperVisionTest::Adder_ptr objAdderfromAny ;
124 //  objAdderfromAny = SuperVisionTest::Adder::_narrow( obj ) ;
125 //  IOR = orb->object_to_string( objAdderfromAny );
126 //  cout << "objAdderfromAny " << objAdderfromAny << " IOR " << IOR << " nil "
127 //       << CORBA::is_nil( objAdderfromAny ) << endl ;
128   
129
130 //  Engines::Container_ptr myContainer = myObjComponent-> GetContainerRef() ;
131 //  IOR = orb->object_to_string( myContainer );
132 //  cout << "myContainer " << myContainer << " IOR " << IOR << " nil "
133 //       << CORBA::is_nil( myContainer ) << endl ;
134 //  anAny <<= myContainer ;
135 //  anAny >>= obj ;
136 //  Engines::Container_ptr objContainerfromAny ;
137 //  objContainerfromAny = Engines::Container::_narrow( obj ) ;
138 //  IOR = orb->object_to_string( objContainerfromAny );
139 //  cout << "objContainerfromAny " << objContainerfromAny << " IOR " << IOR << " nil "
140 //       << CORBA::is_nil( objContainerfromAny ) << endl ;
141
142
143   return 0;
144 }
145