Merge pull request #2222 from jwillemsen/jwi-dllexportwarning
[ACE_TAO.git] / TAO / docs / tutorials / Quoter / Simple / Client / client.cpp
blobfcadf491daa6cf7b6e063d164ab42c52eb16e6cd
2 // Include the generated names....
3 #include "QuoterC.h"
4 #include "ace/streams.h"
6 int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
8 try {
9 // First initialize the ORB, that will remove some arguments...
10 CORBA::ORB_var orb =
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
15 // get quotes for.
16 if (argc < 3) {
17 cerr << "Usage: " << argv[0]
18 << " Factory_IOR symbol symbol..." << endl;
19 return 1;
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) {
34 try {
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
40 // released!
41 CORBA::String_var full_name = stock->full_name ();
43 // Now get the price
44 CORBA::Double price = stock->price ();
46 cout << "The price of a stock in \""
47 << full_name.in () << "\" is $"
48 << price << endl;
50 catch (Quoter::Invalid_Stock_Symbol &) {
51 cerr << "Invalid stock symbol <"
52 << argv[i] << ">" << endl;
56 // Finally destroy the ORB
57 orb->destroy ();
59 catch (const CORBA::Exception &) {
60 cerr << "CORBA exception raised!" << endl;
62 return 0;