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...
10 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
12 // There must be at least two arguments, the first is the factory
13 // name, the rest are the names of the stock symbols we want to
16 cerr
<< "Usage: " << argv
[0] << " Factory_IOR symbol symbol..." << endl
;
20 // Use the first argument to create the factory object reference,
21 // in real applications we use the naming service, but let's do
22 // the easy part first!
23 CORBA::Object_var factory_object
= orb
->string_to_object (argv
[1]);
25 // Now downcast the object reference to the appropriate type
26 Quoter::Stock_Factory_var factory
= Quoter::Stock_Factory::_narrow (factory_object
.in ());
28 // Now get the full name and price of the other arguments:
29 for (int i
= 2; i
!= argc
; ++i
) {
31 // Get the stock object
32 Quoter::Stock_var stock
= factory
->get_stock (ACE_TEXT_ALWAYS_CHAR (argv
[i
]));
34 // Get its name, put it on a _var so it is automatically
36 CORBA::String_var full_name
= stock
->full_name ();
39 CORBA::Double price
= stock
->price ();
41 Quoter::Stock::StockHistory_var history
= stock
->history();
43 cout
<< "The price of a stock in \"" << full_name
.in () << "\" is $" << price
<< endl
;
44 cout
<< " history: " << history
[0] << " " << history
[1] << " ... " << history
[history
->length()-1] << endl
;
45 } catch (Quoter::Invalid_Stock_Symbol
&) {
46 cerr
<< "Invalid stock symbol <" << argv
[i
] << ">" << endl
;
50 // Finally destroy the ORB
53 catch (const CORBA::Exception
& e
) {
54 cerr
<< "CORBA exception raised: " << e
<< endl
;