diff options
Diffstat (limited to 'TAO/docs/tutorials/Quoter/RTCORBA/StockNameConsumer_i.cpp')
-rw-r--r-- | TAO/docs/tutorials/Quoter/RTCORBA/StockNameConsumer_i.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/TAO/docs/tutorials/Quoter/RTCORBA/StockNameConsumer_i.cpp b/TAO/docs/tutorials/Quoter/RTCORBA/StockNameConsumer_i.cpp new file mode 100644 index 00000000000..8fe636bcd96 --- /dev/null +++ b/TAO/docs/tutorials/Quoter/RTCORBA/StockNameConsumer_i.cpp @@ -0,0 +1,77 @@ +// $Id$ + +// local headers +#include "StockNameConsumer_i.h" +#include "Broker_i.h" + +// Implementation skeleton constructor +Stock_StockNameConsumer_i::Stock_StockNameConsumer_i (Stock_StockBroker_i &context, + const char *stock_name) + : context_ (context), + stock_name_ (stock_name) +{ +} + +// Implementation skeleton destructor +Stock_StockNameConsumer_i::~Stock_StockNameConsumer_i (void) +{ +} + +void Stock_StockNameConsumer_i::push_StockName (::Stock::StockNames *the_stockname) + throw (::CORBA::SystemException) +{ + for (CORBA::ULong i = 0; + i < the_stockname->names ().length (); + ++i) + { + if (ACE_OS::strcmp (this->stock_name_, + the_stockname->names ()[i]) == 0) + { + // Get the quoter for the connection from the <context_>. + ACE_DEBUG ((LM_DEBUG, + "*** message: getting the quoter connection\n")); + Stock::StockQuoter_var quoter = + this->context_.get_connection_quoter_info (); + + try + { + // Request more information from the StockQuoter. + ACE_DEBUG ((LM_DEBUG, + "*** message: requesting the stock info from the quoter\n")); + Stock::StockInfo_var stock_info = + quoter->get_stock_info (the_stockname->names()[i]); + + // Display the current value of the stock. + ACE_DEBUG ((LM_DEBUG, + "Current value of %s is $%d\n", + stock_info->name.in (), + stock_info->last)); + } + catch (Stock::Invalid_Stock &e) + { + ACE_PRINT_EXCEPTION (e, "Stock exception: invalid stock name: "); + } + catch (CORBA::Exception &ex) + { + ACE_PRINT_EXCEPTION (ex, "Stock_StockNameConsumer_i::push_StockName: "); + } + } + } +} + + +::Stock::Cookie * +Stock_StockNameConsumer_i::cookie () + throw (::CORBA::SystemException) +{ + return this->cookie_.in (); +} + +void +Stock_StockNameConsumer_i::cookie (::Stock::Cookie *cookie) + throw (::CORBA::SystemException) +{ + this->cookie_ = cookie; + cookie->_add_ref (); +} + |