Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / docs / tutorials / Quoter / Event_Service / Stock_Consumer.cpp
blob836bdff39399efc150b94d95e7dba0b3a3319049
2 #include "Stock_Consumer.h"
3 #include "QuoterC.h"
4 #include "ace/streams.h"
6 Stock_Consumer::Stock_Consumer ()
10 void
11 Stock_Consumer::connect (CosEventChannelAdmin::EventChannel_ptr event_channel)
13 CosEventChannelAdmin::ConsumerAdmin_var consumer_admin =
14 event_channel->for_consumers ();
16 this->supplier_proxy_ =
17 consumer_admin->obtain_push_supplier ();
19 CosEventComm::PushConsumer_var myself = this->_this ();
20 this->supplier_proxy_->connect_push_consumer (myself.in ());
23 void
24 Stock_Consumer::disconnect ()
26 // Do not receive any more events...
27 this->supplier_proxy_->disconnect_push_supplier ();
30 void
31 Stock_Consumer::push (const CORBA::Any& data)
33 const Quoter::Event *event = 0;
34 if ((data >>= event) == 0)
35 return; // Invalid event
37 cout << "The new price for one stock in \""
38 << event->full_name.in ()
39 << "\" (" << event->symbol.in ()
40 << ") is " << event->price << endl;
43 void
44 Stock_Consumer::disconnect_push_consumer ()
46 this->supplier_proxy_ = CosEventChannelAdmin::ProxyPushSupplier::_nil ();