1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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
23 // SuperVisionTest TestFunctionsMemory : Check of memory leaks ...
24 // File : TestFunctionsMemory.cxx
25 // Author : Jean Rahuel
26 // Module : SuperVisionTest
34 #include <SALOMEconfig.h>
35 #include CORBA_CLIENT_HEADER(AddComponent)
36 #include CORBA_CLIENT_HEADER(SALOME_Component)
38 #include "utilities.h"
39 #include "SALOME_NamingService.hxx"
40 #include "SALOME_LifeCycleCORBA.hxx"
43 #include "DynInvoke.hxx"
47 int main(int argc, char **argv) {
48 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
49 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
50 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
51 SALOME_NamingService _NS(orb) ;
52 SALOME_LifeCycleCORBA _LCC(&_NS) ;
54 Engines::EngineComponent_var AddComponent = _LCC.FindOrLoad_Component( "FactoryServer" ,
56 SuperVisionTest::AddComponent_var AddInterface ;
57 AddInterface = SuperVisionTest::AddComponent::_narrow( AddComponent );
59 SuperVisionTest::Adder_var Adder1 ;
60 bool sts1 = AddInterface->AdditionObjRef1( Adder1 ) ;
63 ServicesAnyData * inParams = NULL ;
65 ServicesAnyData * outParams = new ServicesAnyData[noutParams] ;
67 outParams[ 0 ].Value <<= (CORBA::Any::from_boolean ) b ;
68 outParams[ 1 ].Value <<= CORBA::Object::_nil() ;
69 DynInvoke( AddInterface , "AdditionObjRef1" , inParams , ninParams ,
70 outParams , noutParams ) ;
71 outParams[ 0 ].Value >>= sts1 ;
72 CORBA::Object_ptr objptr ;
73 outParams[ 1 ].Value >>= objptr ;
74 SuperVisionTest::Adder_var DynAdder1 ;
75 DynAdder1 = SuperVisionTest::Adder::_narrow( objptr ) ;
77 SuperVisionTest::Adder_var Adder2 ;
79 AddInterface->AdditionObjRef2( sts2 , Adder2 ) ;
81 outParams[ 0 ].Value <<= (CORBA::Any::from_boolean ) b ;
82 outParams[ 1 ].Value <<= CORBA::Object::_nil() ;
83 DynInvoke( AddInterface , "AdditionObjRef2" , inParams , ninParams ,
84 outParams , noutParams ) ;
85 outParams[ 0 ].Value >>= sts2 ;
86 outParams[ 1 ].Value >>= objptr ;
87 SuperVisionTest::Adder_var DynAdder2 ;
88 DynAdder2 = SuperVisionTest::Adder::_narrow( objptr ) ;
93 for ( i = 0 ; i < 10000 ; i++ ) {
96 ServicesAnyData * inParams = new ServicesAnyData[ninParams] ;
98 ServicesAnyData * outParams = new ServicesAnyData[noutParams] ;
100 // Direct call to AdditionObjRef1
102 inParams[0].Value <<= d1 ;
104 inParams[1].Value <<= d2 ;
106 outParams[ 0 ].Value <<= Func1 ;
108 outParams[ 1 ].Value <<= z1 ;
109 DynInvoke( Adder1 , "AddWithoutSleep" , inParams , ninParams ,
110 outParams , noutParams ) ;
111 outParams[ 0 ].Value >>= Func1 ;
112 outParams[ 1 ].Value >>= z1 ;
113 cout << i << ". TestFunctionsMemory " << " Func1 " << Func1 << " z1 " << z1 << endl ;
115 // Call to AdditionObjRef1 via dynamic invocation
117 outParams[ 0 ].Value <<= Func1 ;
119 outParams[ 1 ].Value <<= z1 ;
120 DynInvoke( DynAdder1 , "AddWithoutSleep" , inParams , ninParams ,
121 outParams , noutParams ) ;
122 outParams[ 0 ].Value >>= Func1 ;
123 outParams[ 1 ].Value >>= z1 ;
124 Func1 = DynAdder1->AddWithoutSleep( 1. , 2. , z1 ) ;
125 cout << i << ". TestFunctionsMemory DynInvoke " << " Func1 " << Func1 << " z1 " << z1
128 // Direct call to AdditionObjRef2
130 outParams[ 0 ].Value <<= Func2 ;
132 outParams[ 1 ].Value <<= z2 ;
133 DynInvoke( Adder2 , "AddWithoutSleep" , inParams , ninParams ,
134 outParams , noutParams ) ;
135 outParams[ 0 ].Value >>= Func2 ;
136 outParams[ 1 ].Value >>= z2 ;
137 cout << i << ". TestFunctions " << " Func2 " << Func2 << " z2 " << z2 << endl ;
139 // Call to AdditionObjRef2 via dynamic invocation
140 outParams[ 0 ].Value <<= Func2 ;
141 outParams[ 1 ].Value <<= z2 ;
142 DynInvoke( DynAdder2 , "AddWithoutSleep" , inParams , ninParams ,
143 outParams , noutParams ) ;
144 outParams[ 0 ].Value >>= Func2 ;
145 outParams[ 1 ].Value >>= z2 ;
146 cout << i << ". TestFunctionsMemory DynInvoke " << " Func2 " << Func2 << " z2 " << z2
150 delete [] outParams ;
155 DynAdder1->destroy() ;
157 DynAdder2->destroy() ;