1 // Copyright (C) 2007-2015 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
35 #include <SALOMEconfig.h>
36 #include CORBA_CLIENT_HEADER(AddComponent)
37 #include CORBA_CLIENT_HEADER(SALOME_Component)
39 #include "utilities.h"
40 #include "SALOME_NamingService.hxx"
41 #include "SALOME_LifeCycleCORBA.hxx"
44 #include "DynInvoke.hxx"
48 int main(int argc, char **argv) {
49 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
50 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
51 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
52 SALOME_NamingService _NS(orb) ;
53 SALOME_LifeCycleCORBA _LCC(&_NS) ;
55 Engines::EngineComponent_var AddComponent = _LCC.FindOrLoad_Component( "FactoryServer" ,
57 SuperVisionTest::AddComponent_var AddInterface ;
58 AddInterface = SuperVisionTest::AddComponent::_narrow( AddComponent );
61 for ( i = 0 ; i < 10000 ; i++ ) {
63 // Direct call to AdditionObjRef1
64 SuperVisionTest::Adder_var Adder1 ;
65 bool sts1 = AddInterface->AdditionObjRef1( Adder1 ) ;
67 Func1 = Adder1->AddWithoutSleep( 1. , 2. , z1 ) ;
68 cout << i << ". TestFunctionsMemory sts1 " << sts1 << " Func1 " << Func1 << " z1 " << z1 << endl ;
71 // Call to AdditionObjRef1 via dynamic invocation
73 ServicesAnyData * inParams = NULL ;
75 ServicesAnyData * outParams = new ServicesAnyData[noutParams] ;
77 outParams[ 0 ].Value <<= (CORBA::Any::from_boolean ) b ;
78 outParams[ 1 ].Value <<= CORBA::Object::_nil() ;
79 DynInvoke( AddInterface , "AdditionObjRef1" , inParams , ninParams ,
80 outParams , noutParams ) ;
81 outParams[ 0 ].Value >>= sts1 ;
82 CORBA::Object_ptr objptr ;
83 outParams[ 1 ].Value >>= objptr ;
84 SuperVisionTest::Adder_var DynAdder1 ;
85 DynAdder1 = SuperVisionTest::Adder::_narrow( objptr ) ;
86 CORBA::release( objptr ) ;
87 Func1 = DynAdder1->AddWithoutSleep( 1. , 2. , z1 ) ;
88 cout << i << ". TestFunctionsMemory DynInvoke sts1 " << sts1 << " Func1 " << Func1 << " z1 " << z1
90 DynAdder1->destroy() ;
92 // Direct call to AdditionObjRef2
93 SuperVisionTest::Adder_var Adder2 ;
95 AddInterface->AdditionObjRef2( sts2 , Adder2 ) ;
97 Func2 = Adder2->AddWithoutSleep( 1. , 2. , z2 ) ;
98 cout << i << ". TestFunctions sts2 " << sts2 << " Func2 " << Func2 << " z2 " << z2 << endl ;
101 // Call to AdditionObjRef2 via dynamic invocation
102 outParams[ 0 ].Value <<= (CORBA::Any::from_boolean ) b ;
103 outParams[ 1 ].Value <<= CORBA::Object::_nil() ;
104 DynInvoke( AddInterface , "AdditionObjRef2" , inParams , ninParams ,
105 outParams , noutParams ) ;
106 outParams[ 0 ].Value >>= sts2 ;
107 outParams[ 1 ].Value >>= objptr ;
108 SuperVisionTest::Adder_var DynAdder2 ;
109 DynAdder2 = SuperVisionTest::Adder::_narrow( objptr ) ;
110 CORBA::release( objptr ) ;
111 Func2 = DynAdder2->AddWithoutSleep( 1. , 2. , z2 ) ;
112 cout << i << ". TestFunctionsMemory DynInvoke sts2 " << sts2 << " Func2 " << Func2 << " z2 " << z2
114 DynAdder2->destroy() ;
116 delete [] outParams ;