1 // SuperVisionTest TestFunctions : example of component that adds two numbers
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : TestFunctions.cxx
25 // Module : SuperVisionTest
31 #include <SALOMEconfig.h>
32 #include CORBA_CLIENT_HEADER(AddComponent)
33 #include CORBA_CLIENT_HEADER(SALOME_Component)
35 #include "utilities.h"
36 #include "SALOME_NamingService.hxx"
37 #include "SALOME_LifeCycleCORBA.hxx"
40 #include "DynInvoke.hxx"
44 int main(int argc, char **argv) {
45 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
46 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
47 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
48 SALOME_NamingService _NS(orb) ;
49 SALOME_LifeCycleCORBA _LCC(&_NS) ;
51 Engines::Component_var AddComponent = _LCC.FindOrLoad_Component( "FactoryServer" ,
53 SuperVisionTest::AddComponent_var AddInterface ;
54 AddInterface = SuperVisionTest::AddComponent::_narrow( AddComponent );
56 // Direct call to AdditionObjRef1
57 SuperVisionTest::Adder_var Adder1 ;
58 bool sts1 = AddInterface->AdditionObjRef1( Adder1 ) ;
60 Func1 = Adder1->Add( 1. , 2. , z1 ) ;
61 cout << "TestFunctions sts1 " << sts1 << " Func1 " << Func1 << " z1 " << z1 << endl ;
63 // Call to AdditionObjRef1 via dynamic invocation
65 ServicesAnyData * inParams = NULL ;
67 ServicesAnyData * outParams = new ServicesAnyData[noutParams] ;
69 outParams[ 0 ].Value <<= (CORBA::Any::from_boolean ) b ;
70 outParams[ 1 ].Value <<= CORBA::Object::_nil() ;
71 DynInvoke( AddInterface , "AdditionObjRef1" , inParams , ninParams ,
72 outParams , noutParams ) ;
73 outParams[ 0 ].Value >>= sts1 ;
74 CORBA::Object_ptr objptr ;
75 outParams[ 1 ].Value >>= objptr ;
76 Adder1 = SuperVisionTest::Adder::_narrow( objptr ) ;
77 Func1 = Adder1->Add( 1. , 2. , z1 ) ;
78 cout << "TestFunctions DynInvoke sts1 " << sts1 << " Func1 " << Func1 << " z1 " << z1
81 // Direct call to AdditionObjRef2
82 SuperVisionTest::Adder_var Adder2 ;
84 AddInterface->AdditionObjRef2( sts2 , Adder2 ) ;
86 Func2 = Adder2->Add( 1. , 2. , z2 ) ;
87 cout << "TestFunctions sts2 " << sts2 << " Func2 " << Func2 << " z2 " << z2 << endl ;
89 // Call to AdditionObjRef2 via dynamic invocation
90 outParams[ 0 ].Value <<= (CORBA::Any::from_boolean ) b ;
91 outParams[ 1 ].Value <<= CORBA::Object::_nil() ;
92 DynInvoke( AddInterface , "AdditionObjRef2" , inParams , ninParams ,
93 outParams , noutParams ) ;
94 outParams[ 0 ].Value >>= sts2 ;
95 outParams[ 1 ].Value >>= objptr ;
96 Adder2 = SuperVisionTest::Adder::_narrow( objptr ) ;
97 Func2 = Adder2->Add( 1. , 2. , z2 ) ;
98 cout << "TestFunctions DynInvoke sts2 " << sts2 << " Func2 " << Func2 << " z2 " << z2