1 // SuperVisionTest TestFunctionsMemory : Check of memory leaks ...
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 : TestFunctionsMemory.cxx
25 // Author : Jean Rahuel
26 // Module : SuperVisionTest
32 #include <SALOMEconfig.h>
33 #include CORBA_CLIENT_HEADER(AddComponent)
34 #include CORBA_CLIENT_HEADER(SALOME_Component)
36 #include "utilities.h"
37 #include "SALOME_NamingService.hxx"
38 #include "SALOME_LifeCycleCORBA.hxx"
41 #include "DynInvoke.hxx"
45 int main(int argc, char **argv) {
46 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
47 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
48 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
49 SALOME_NamingService _NS(orb) ;
50 SALOME_LifeCycleCORBA _LCC(&_NS) ;
52 Engines::Component_var AddComponent = _LCC.FindOrLoad_Component( "FactoryServer" ,
54 SuperVisionTest::AddComponent_var AddInterface ;
55 AddInterface = SuperVisionTest::AddComponent::_narrow( AddComponent );
57 SuperVisionTest::Adder_var Adder1 ;
58 bool sts1 = AddInterface->AdditionObjRef1( Adder1 ) ;
61 ServicesAnyData * inParams = NULL ;
63 ServicesAnyData * outParams = new ServicesAnyData[noutParams] ;
65 outParams[ 0 ].Value <<= (CORBA::Any::from_boolean ) b ;
66 outParams[ 1 ].Value <<= CORBA::Object::_nil() ;
67 DynInvoke( AddInterface , "AdditionObjRef1" , inParams , ninParams ,
68 outParams , noutParams ) ;
69 outParams[ 0 ].Value >>= sts1 ;
70 CORBA::Object_ptr objptr ;
71 outParams[ 1 ].Value >>= objptr ;
72 SuperVisionTest::Adder_var DynAdder1 ;
73 DynAdder1 = SuperVisionTest::Adder::_narrow( objptr ) ;
75 SuperVisionTest::Adder_var Adder2 ;
77 AddInterface->AdditionObjRef2( sts2 , Adder2 ) ;
79 outParams[ 0 ].Value <<= (CORBA::Any::from_boolean ) b ;
80 outParams[ 1 ].Value <<= CORBA::Object::_nil() ;
81 DynInvoke( AddInterface , "AdditionObjRef2" , inParams , ninParams ,
82 outParams , noutParams ) ;
83 outParams[ 0 ].Value >>= sts2 ;
84 outParams[ 1 ].Value >>= objptr ;
85 SuperVisionTest::Adder_var DynAdder2 ;
86 DynAdder2 = SuperVisionTest::Adder::_narrow( objptr ) ;
91 for ( i = 0 ; i < 10000 ; i++ ) {
94 ServicesAnyData * inParams = new ServicesAnyData[ninParams] ;
96 ServicesAnyData * outParams = new ServicesAnyData[noutParams] ;
98 // Direct call to AdditionObjRef1
100 inParams[0].Name = string( "x1" ) ;
101 inParams[0].Value <<= d1 ;
103 inParams[1].Name = string( "y1" ) ;
104 inParams[1].Value <<= d2 ;
106 outParams[ 0 ].Name = string( "Func1" ) ;
107 outParams[ 0 ].Value <<= Func1 ;
109 outParams[ 1 ].Name = string( "z1" ) ;
110 outParams[ 1 ].Value <<= z1 ;
111 DynInvoke( Adder1 , "AddWithoutSleep" , inParams , ninParams ,
112 outParams , noutParams ) ;
113 outParams[ 0 ].Value >>= Func1 ;
114 outParams[ 1 ].Value >>= z1 ;
115 cout << i << ". TestFunctionsMemory " << " Func1 " << Func1 << " z1 " << z1 << endl ;
117 // Call to AdditionObjRef1 via dynamic invocation
119 outParams[ 0 ].Value <<= Func1 ;
121 outParams[ 1 ].Value <<= z1 ;
122 DynInvoke( DynAdder1 , "AddWithoutSleep" , inParams , ninParams ,
123 outParams , noutParams ) ;
124 outParams[ 0 ].Value >>= Func1 ;
125 outParams[ 1 ].Value >>= z1 ;
126 Func1 = DynAdder1->AddWithoutSleep( 1. , 2. , z1 ) ;
127 cout << i << ". TestFunctionsMemory DynInvoke " << " Func1 " << Func1 << " z1 " << z1
130 // Direct call to AdditionObjRef2
131 inParams[0].Name = string( "x2" ) ;
132 inParams[1].Name = string( "y2" ) ;
134 outParams[ 0 ].Name = string( "Func2" ) ;
135 outParams[ 0 ].Value <<= Func2 ;
137 outParams[ 1 ].Name = string( "z2" ) ;
138 outParams[ 1 ].Value <<= z2 ;
139 DynInvoke( Adder2 , "AddWithoutSleep" , inParams , ninParams ,
140 outParams , noutParams ) ;
141 outParams[ 0 ].Value >>= Func2 ;
142 outParams[ 1 ].Value >>= z2 ;
143 cout << i << ". TestFunctions " << " Func2 " << Func2 << " z2 " << z2 << endl ;
145 // Call to AdditionObjRef2 via dynamic invocation
146 outParams[ 0 ].Value <<= Func2 ;
147 outParams[ 1 ].Value <<= z2 ;
148 DynInvoke( DynAdder2 , "AddWithoutSleep" , inParams , ninParams ,
149 outParams , noutParams ) ;
150 outParams[ 0 ].Value >>= Func2 ;
151 outParams[ 1 ].Value >>= z2 ;
152 cout << i << ". TestFunctionsMemory DynInvoke " << " Func2 " << Func2 << " z2 " << z2
156 delete [] outParams ;
161 DynAdder1->destroy() ;
163 DynAdder2->destroy() ;