Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / docs / tutorials / Quoter / RTCORBA / StockNameConsumer_i.cpp
blob167b035f472251f68003e27da22415791c375e51
1 // local headers
2 #include "StockNameConsumer_i.h"
3 #include "Broker_i.h"
5 // Implementation skeleton constructor
6 Stock_StockNameConsumer_i::Stock_StockNameConsumer_i (Stock_StockBroker_i &context,
7 const char *stock_name)
8 : context_ (context),
9 stock_name_ (stock_name)
13 // Implementation skeleton destructor
14 Stock_StockNameConsumer_i::~Stock_StockNameConsumer_i (void)
18 void Stock_StockNameConsumer_i::push_StockName (::Stock::StockNames *the_stockname)
20 for (CORBA::ULong i = 0;
21 i < the_stockname->names ().length ();
22 ++i)
24 if (ACE_OS::strcmp (this->stock_name_.in (),
25 the_stockname->names ()[i]) == 0)
27 // Get the quoter for the connection from the <context_>.
28 ACE_DEBUG ((LM_DEBUG,
29 "*** message: getting the quoter connection\n"));
30 Stock::StockQuoter_var quoter =
31 this->context_.get_connection_quoter_info ();
33 try
35 // Request more information from the StockQuoter.
36 ACE_DEBUG ((LM_DEBUG,
37 "*** message: requesting the stock info from the quoter\n"));
38 Stock::StockInfo_var stock_info =
39 quoter->get_stock_info (the_stockname->names()[i]);
41 // Display the current value of the stock.
42 ACE_DEBUG ((LM_DEBUG,
43 "Current value of %s is $%d\n",
44 stock_info->name.in (),
45 stock_info->last));
47 catch (Stock::Invalid_Stock &e)
49 e._tao_print_exception ("Stock exception: invalid stock name: ");
51 catch (const CORBA::Exception &ex)
53 ex._tao_print_exception ("Stock_StockNameConsumer_i::push_StockName: ");
59 ::Stock::Cookie *
60 Stock_StockNameConsumer_i::cookie_ ()
62 return this->cookie__.in ();
65 void
66 Stock_StockNameConsumer_i::cookie_ (::Stock::Cookie *cookie)
68 this->cookie__ = cookie;
69 cookie->_add_ref ();