Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / docs / tutorials / Quoter / RT_Event_Service / Stock_Consumer.cpp
blob75b122b801de4e64d7610a665e450dc3336edae2
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 (RtecEventChannelAdmin::EventChannel_ptr event_channel,
12 const RtecEventChannelAdmin::ConsumerQOS &subscriptions)
14 RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin =
15 event_channel->for_consumers ();
17 this->supplier_proxy_ =
18 consumer_admin->obtain_push_supplier ();
20 RtecEventComm::PushConsumer_var myself = this->_this ();
21 this->supplier_proxy_->connect_push_consumer (myself.in (),
22 subscriptions);
25 void
26 Stock_Consumer::disconnect ()
28 // Do not receive any more events...
29 this->supplier_proxy_->disconnect_push_supplier ();
32 void
33 Stock_Consumer::push (const RtecEventComm::EventSet &data)
35 for (CORBA::ULong i = 0; i != data.length (); ++i) {
36 const RtecEventComm::Event &e = data[i];
38 const Quoter::Event *event = 0;
39 if ((e.data.any_value >>= event) == 0)
40 continue; // Invalid event
42 cout << "The new price for one stock in \""
43 << event->full_name.in ()
44 << "\" (" << event->symbol.in ()
45 << ") is " << event->price << endl;
49 void
50 Stock_Consumer::disconnect_push_consumer ()
52 this->supplier_proxy_ =
53 RtecEventChannelAdmin::ProxyPushSupplier::_nil ();