Salome HOME
Update copyright information
[modules/superv.git] / src / GraphBase / SuperVisionBase_CheckOfUndefined.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
23 //  File   : SuperVisionBase_CheckOfUndefined.cxx
24 //  Module : SUPERV
25 //
26 using namespace std;
27 #include <iostream>
28 #include <fstream>
29 #include <unistd.h>
30
31 #include "Utils_ORB_INIT.hxx"
32 #include "Utils_SINGLETON.hxx"
33
34 #include "SALOME_NamingService.hxx"
35 #include "SALOME_LifeCycleCORBA.hxx"
36
37 #include "DataFlowBase_Base.hxx"
38
39 #include CORBA_CLIENT_HEADER(SALOME_Component)
40
41
42
43 int _ArgC ;
44 char ** _ArgV ;
45
46 int main(int argc, char **argv) {
47
48   Engines::Component_ptr objComponent ;
49   char * IOR ;
50
51   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
52   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
53   CORBA::ORB_var &orb = init( argc , argv ) ;
54
55   SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
56
57   SALOME_LifeCycleCORBA LCC( NamingService ) ;
58   objComponent = LCC.FindOrLoad_Component( "FactoryServer" , "AddComponent" );
59   if ( CORBA::is_nil( objComponent ) ) {
60     cout << "ERROR LCC.FindOrLoad_Component( FactoryServer , AddComponent )" << endl;
61     return 0 ;
62   }
63   objComponent->ping() ;
64
65   IOR = orb->object_to_string( objComponent );
66   cout << "objComponent " << objComponent << " IOR " << IOR << " nil "
67        << CORBA::is_nil( objComponent ) << endl ;
68
69   Engines::Component_ptr mySuperVision ;
70   mySuperVision = LCC.FindOrLoad_Component( "SuperVisionContainer","SUPERV" ) ;
71   SUPERV::SuperG_ptr mySuperVisionComponent ;
72   mySuperVisionComponent =  SUPERV::SuperG::_narrow( mySuperVision ) ;
73
74   CORBA::Any anAny ;
75 //  anAny <<= CORBA::Object::_nil() ;
76   anAny <<= objComponent ;
77 //  CORBA::Any anAny = CORBA::Any( CORBA::_tc_Object, objComponent ) ;
78 //  anAny.replace( CORBA::_tc_Object, objComponent );
79
80   CORBA::Object * obj ;
81   anAny >>= obj ;
82
83   IOR = orb->object_to_string( objComponent );
84   cout << "objComponent " << objComponent << " IOR " << IOR << " nil "
85        << CORBA::is_nil( objComponent ) << endl ;
86
87 // Crash
88 //  IOR = orb->object_to_string( obj );
89 //  cout << "obj " << obj << " IOR " << IOR << " nil " << CORBA::is_nil( obj )
90 //       << endl ;
91
92   Engines::Component_ptr objComponentfromAny ;
93   objComponentfromAny = Engines::Component::_narrow( obj ) ;
94   IOR = orb->object_to_string( objComponentfromAny );
95   cout << "obComponentfromAny " << objComponentfromAny << " IOR " << IOR << " nil "
96        << CORBA::is_nil( objComponentfromAny ) << endl ;
97
98
99
100 //  CORBA::Object_var myObj = NamingService->ResolveComponent("xmen","FactoryServer" ,
101 //                                                            "AddComponent" );
102 //  SuperVisionTest::AddComponent_ptr myObjComponent ;
103 //  myObjComponent = SuperVisionTest::AddComponent::_narrow( myObj ) ;
104 //  IOR = orb->object_to_string( myObjComponent );
105 //  cout << "myObjComponent " << myObjComponent << " IOR " << IOR << " nil "
106 //       << CORBA::is_nil( myObjComponent ) << endl ;
107 //  anAny <<= myObjComponent ;
108 //  anAny >>= obj ;
109 //  objComponentfromAny = Engines::Component::_narrow( obj ) ;
110 //  IOR = orb->object_to_string( objComponentfromAny );
111 //  cout << "objComponentfromAny " << objComponentfromAny << " IOR " << IOR << " nil "
112 //       << CORBA::is_nil( objComponentfromAny ) << endl ;
113
114 //  SuperVisionTest::Adder_ptr myAdder = myObjComponent->Addition() ;
115 //  myAdder->ping() ;
116 //  IOR = orb->object_to_string( myAdder );
117 //  cout << "myAdder " << myAdder << " IOR " << IOR << " nil "
118 //       << CORBA::is_nil( myAdder ) << endl ;
119 //  anAny <<=  myAdder ;
120 //  anAny <<=  orb->string_to_object( IOR ) ;
121 //  anAny >>= obj ;
122 //  SuperVisionTest::Adder_ptr objAdderfromAny ;
123 //  objAdderfromAny = SuperVisionTest::Adder::_narrow( obj ) ;
124 //  IOR = orb->object_to_string( objAdderfromAny );
125 //  cout << "objAdderfromAny " << objAdderfromAny << " IOR " << IOR << " nil "
126 //       << CORBA::is_nil( objAdderfromAny ) << endl ;
127   
128
129 //  Engines::Container_ptr myContainer = myObjComponent-> GetContainerRef() ;
130 //  IOR = orb->object_to_string( myContainer );
131 //  cout << "myContainer " << myContainer << " IOR " << IOR << " nil "
132 //       << CORBA::is_nil( myContainer ) << endl ;
133 //  anAny <<= myContainer ;
134 //  anAny >>= obj ;
135 //  Engines::Container_ptr objContainerfromAny ;
136 //  objContainerfromAny = Engines::Container::_narrow( obj ) ;
137 //  IOR = orb->object_to_string( objContainerfromAny );
138 //  cout << "objContainerfromAny " << objContainerfromAny << " IOR " << IOR << " nil "
139 //       << CORBA::is_nil( objContainerfromAny ) << endl ;
140
141
142   return 0;
143 }
144