ACE+TAO-7_0_8
[ACE_TAO.git] / TAO / tests / Objref_Sequence_Test / client.cpp
blob27798aeba9b979b937750cf6cd3a4a3991b839ad
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.opt_arg ();
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-k <ior> "
24 "\n",
25 argv [0]),
26 -1);
28 // Indicates successful parsing of the command line
29 return 0;
33 int
34 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
39 try
41 CORBA::ORB_var orb =
42 CORBA::ORB_init (argc,
43 argv);
45 if (parse_args (argc, argv) == -1)
46 return -1;
48 // Connect to the server
49 CORBA::Object_var tmp =
50 orb->string_to_object(ior);
52 Server_var server = Server::_narrow (tmp.in ());
54 // Create object instances
55 // This portion of the test was given by Petr Tuma and am just
56 // leaving it alone -- Bala
57 ServerSequence_var vServers;
58 ServerSequence_var vAddition;
60 CORBA::ULong iStep;
61 CORBA::ULong iSize, iOldSize, iAddSize;
62 CORBA::ULong iCount;
64 ACE_NEW_RETURN (vServers,
65 ServerSequence (),
66 -1);
68 iSize = 1;
69 iStep = 1;
70 while (iSize <= 50000)
72 iOldSize = vServers->length ();
73 iAddSize = iSize - iOldSize;
75 server->CreateExtra (iAddSize,
76 vAddition.out ());
79 vServers->length (iSize);
80 for (iCount = 0 ; iCount < iAddSize ; iCount ++)
82 vServers [iOldSize + iCount] =
83 Server::_duplicate (vAddition [iCount]);
86 vAddition = 0;
88 if (iStep * 5 > iSize)
90 iSize += iStep;
92 else
94 iStep *= 10;
95 iSize = iStep;
99 //------------- End of donated untouched section
101 ACE_DEBUG ((LM_DEBUG,
102 "(%P|%t) Call delete on the server\n"));
104 server->DeleteExtra (vServers.in ());
106 ACE_DEBUG ((LM_DEBUG,
107 "(%P|%t) Calling shutdown\n"));
108 server->shutdown ();
111 catch (const CORBA::Exception& ex)
113 ex._tao_print_exception ("");
116 return 0;