Stock NameConsumer implementation for the Stock Quoter Publisher/Subscriber Real-time CORBA Service


Implementation of StockNameConsumer interface

This interface is used as a callback interface used by the Stock Distributor server to notify Stock Broker clients of updates. This class is ALSO used as a signal handler to catch SIGINT and properly unsubscribe from the Stock Distributor server.

The Stock_StockNameConsumer_i class is generated automatically by the IDL compiler (using the -GI flag), which is a subclass of POA_Stock::StockNameConsumer class.

Implementing the Constructor

    Stock_StockNameConsumer_i::Stock_StockNameConsumer_i (Stock_StockBroker_i &context,
                                                          const char *stock_name)
      : context_ (context),
        stock_name_ (stock_name)
The "context_" and "stock_name_" are two private members of the Stock_StockNameConsumer_i class. They stand for the context of the StockNameConsumer object and the name of the stock to listen to respectively.

Implementing the push_StockName () member function

The main steps of this function are described as follows:

  • Verify this is the correct stock: Check if the StockName parameter in this function is equal to the "stock_name_" private member. If this is not the stock that we are interested in then we need to stop and return.
  • Get the quoter for the connection from the context_ private member.
  •     Stock::StockQuoter_var quoter = context_->get_connection_quoter_info ();
    
  • Request more information from the quoter.
  •     Stock::StockInfo_var stock_info = quoter->get_stock_info (the_stockname->name());
    

    Implementing the access operations of the cookie attribute.

  • Get the cookie attribute:
  •     return this->cookie_.in ();
    
  • Set the cookie attribute:
  •     this->cookie_ = cookie;
        cookie->_add_ref ();
    

    Email: shanshan.jiang@vanderbilt.edu