summaryrefslogtreecommitdiff
path: root/trunk/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.cpp')
-rw-r--r--trunk/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/trunk/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.cpp b/trunk/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.cpp
new file mode 100644
index 00000000000..395e31bf6b0
--- /dev/null
+++ b/trunk/TAO/docs/tutorials/Quoter/RT_Event_Service/Stock_Consumer.cpp
@@ -0,0 +1,60 @@
+//
+// $Id$
+//
+
+#include "Stock_Consumer.h"
+#include "QuoterC.h"
+#include "ace/streams.h"
+
+Stock_Consumer::Stock_Consumer ()
+{
+}
+
+void
+Stock_Consumer::connect (RtecEventChannelAdmin::EventChannel_ptr event_channel,
+ const RtecEventChannelAdmin::ConsumerQOS &subscriptions)
+{
+ RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin =
+ event_channel->for_consumers ();
+
+ this->supplier_proxy_ =
+ consumer_admin->obtain_push_supplier ();
+
+ RtecEventComm::PushConsumer_var myself = this->_this ();
+ this->supplier_proxy_->connect_push_consumer (myself.in (),
+ subscriptions);
+}
+
+void
+Stock_Consumer::disconnect ()
+{
+ // Do not receive any more events...
+ this->supplier_proxy_->disconnect_push_supplier ();
+}
+
+void
+Stock_Consumer::push (const RtecEventComm::EventSet &data
+ ACE_ENV_ARG_DECL_NOT_USED)
+ throw (CORBA::SystemException)
+{
+ for (CORBA::ULong i = 0; i != data.length (); ++i) {
+ const RtecEventComm::Event &e = data[i];
+
+ Quoter::Event *event;
+ if ((e.data.any_value >>= event) == 0)
+ continue; // Invalid event
+
+ cout << "The new price for one stock in \""
+ << event->full_name.in ()
+ << "\" (" << event->symbol.in ()
+ << ") is " << event->price << endl;
+ }
+}
+
+void
+Stock_Consumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ throw (CORBA::SystemException)
+{
+ this->supplier_proxy_ =
+ RtecEventChannelAdmin::ProxyPushSupplier::_nil ();
+}