Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / tests / Two_Objects / client.cpp
blob34f7b8cb30f97bc376bcc7ee78fd263ad8f97b7c
1 #include "Two_ObjectsC.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("r:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'r':
16 ior = get_opts.opt_arg ();
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-r <ior> "
24 "\n",
25 argv [0]),
26 -1);
28 // Indicates successful parsing of the command line
29 return 0;
32 int
33 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
35 // Used to declare the CORBA::Environment variable
37 try
39 // Initialize the ORB
40 CORBA::ORB_var orb =
41 CORBA::ORB_init (argc, argv);
43 // Parse the arguments
44 if (parse_args (argc, argv) != 0)
45 return 1;
47 // Convert the ior string to an object reference.
48 // The object reference obtained is a reference to the factory
49 // object.
50 CORBA::Object_var tmp =
51 orb->string_to_object(ior);
53 // Narrow the object reference to the appropriate type
54 Two_Objects_Test::Object_Factory_var factory =
55 Two_Objects_Test::Object_Factory::_narrow(tmp.in ());
57 if (CORBA::is_nil (factory.in ()))
59 ACE_ERROR_RETURN ((LM_DEBUG,
60 "Nil Two_Objects_Test::Object_Factory reference <%s>\n",
61 ior),
62 1);
65 Two_Objects_Test::First_var first;
66 Two_Objects_Test::Second_var second;
68 // Use the factory object to create the first and second interfaces
69 first = factory->create_first();
70 second = factory->create_second();
72 // Call the oneway method
73 first->oneway_method ();
75 ACE_DEBUG ((LM_DEBUG, "Client : one way call done\n"));
77 Two_Objects_Test::Octet_Seq_var reply_seq =
78 second->twoway_method ();
80 ACE_DEBUG ((LM_DEBUG, "Client : length of returned data is %d\n",
81 reply_seq->length() ));
83 second->shutdown ();
85 orb->destroy ();
87 catch (const CORBA::Exception& ex)
89 ex._tao_print_exception ("Exception caught:");
90 return 1;
93 return 0;