2 // Include the generated names....
4 #include "ace/streams.h"
6 int ACE_TMAIN (int argc
, ACE_TCHAR
* argv
[])
9 // First initialize the ORB, that will remove some arguments...
11 CORBA::ORB_init (argc
, argv
);
13 // There must be at least two arguments, the first is the factory
14 // name, the rest are the names of the stock symbols we want to
17 cerr
<< "Usage: " << argv
[0]
18 << " Factory_IOR symbol symbol..." << endl
;
22 // Use the first argument to create the factory object reference,
23 // in real applications we use the naming service, but let's do
24 // the easy part first!
25 CORBA::Object_var factory_object
=
26 orb
->string_to_object (argv
[1]);
28 // Now downcast the object reference to the appropriate type
29 Quoter::Stock_Factory_var factory
=
30 Quoter::Stock_Factory::_narrow (factory_object
.in ());
32 // Now get the full name and price of the other arguments:
33 for (int i
= 2; i
!= argc
; ++i
) {
35 // Get the stock object
36 Quoter::Stock_var stock
=
37 factory
->get_stock (ACE_TEXT_ALWAYS_CHAR (argv
[i
]));
39 // Get its name, put it on a _var so it is automatically
41 CORBA::String_var full_name
= stock
->full_name ();
44 CORBA::Double price
= stock
->price ();
46 cout
<< "The price of a stock in \""
47 << full_name
.in () << "\" is $"
50 catch (Quoter::Invalid_Stock_Symbol
&) {
51 cerr
<< "Invalid stock symbol <"
52 << argv
[i
] << ">" << endl
;
56 // Finally destroy the ORB
59 catch (const CORBA::Exception
&) {
60 cerr
<< "CORBA exception raised!" << endl
;