2 #include "Stock_Consumer.h"
4 #include "ace/streams.h"
6 Stock_Consumer::Stock_Consumer ()
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 (),
26 Stock_Consumer::disconnect ()
28 // Do not receive any more events...
29 this->supplier_proxy_
->disconnect_push_supplier ();
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
;
50 Stock_Consumer::disconnect_push_consumer ()
52 this->supplier_proxy_
=
53 RtecEventChannelAdmin::ProxyPushSupplier::_nil ();