Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / EC_MT_Mcast / Consumer.cpp
blob6c9004deb79ab3ce3c930b801283846b4db2fa42
1 // Reused from: $TAO_ROOT/orbsvcs/examples/RtEC/MCast
3 #include "Consumer.h"
4 #include "orbsvcs/RtecEventChannelAdminS.h"
5 #include "orbsvcs/Event_Service_Constants.h"
7 Consumer::Consumer ()
8 : event_count_ (0)
12 void
13 Consumer::connect (RtecEventChannelAdmin::ConsumerAdmin_ptr consumer_admin)
15 this->proxy_ =
16 consumer_admin->obtain_push_supplier ();
18 RtecEventComm::PushConsumer_var me =
19 this->_this ();
21 // Simple subscription, but usually the helper classes in
22 // $TAO_ROOT/orbsvcs/Event_Utils.h are a better way to do this.
23 RtecEventChannelAdmin::ConsumerQOS qos;
24 qos.is_gateway = 0;
26 qos.dependencies.length (2);
27 RtecEventComm::EventHeader& h0 =
28 qos.dependencies[0].event.header;
29 h0.type = ACE_ES_DISJUNCTION_DESIGNATOR;
30 h0.source = 1; // The disjunction has one element
32 RtecEventComm::EventHeader& h1 =
33 qos.dependencies[1].event.header;
34 h1.type = ACE_ES_EVENT_UNDEFINED; // first free event type
35 h1.source = ACE_ES_EVENT_SOURCE_ANY; // Any source is OK
37 this->proxy_->connect_push_consumer (me.in (), qos);
40 void
41 Consumer::disconnect ()
43 try
45 // Disconnect from the proxy
46 this->proxy_->disconnect_push_supplier ();
48 catch (const CORBA::Exception&)
50 // Ignore exceptions
52 this->proxy_ = RtecEventChannelAdmin::ProxyPushSupplier::_nil ();
54 // Deactivate this object
55 PortableServer::POA_var poa =
56 this->_default_POA ();
57 // Get the Object Id used for the servant..
58 PortableServer::ObjectId_var oid =
59 poa->servant_to_id (this);
60 // Deactivate the object
61 poa->deactivate_object (oid.in ());
64 void
65 Consumer::push (const RtecEventComm::EventSet& events)
67 if (events.length () == 0)
69 ACE_DEBUG ((LM_DEBUG,
70 "Consumer (%P|%t) no events\n"));
71 return;
74 this->event_count_ += events.length ();
75 if (this->event_count_ % 10000 == 0)
77 ACE_DEBUG ((LM_DEBUG,
78 "Consumer (%P|%t): %d events received\n",
79 this->event_count_));
83 void
84 Consumer::disconnect_push_consumer ()