2 * @file Loopback_Consumer.cpp
4 * @author Carlos O'Ryan <coryan@uci.edu>
7 #include "Loopback_Consumer.h"
8 #include "Implicit_Deactivator.h"
9 #include "orbsvcs/Event_Service_Constants.h"
12 Loopback_Consumer (CORBA::Long experiment_id
,
13 CORBA::Long event_type
,
14 Loopback_Supplier
*supplier
,
15 PortableServer::POA_ptr poa
)
16 : experiment_id_ (experiment_id
)
17 , event_type_ (event_type
)
18 , supplier_ (PortableServer::Servant_var
<Loopback_Supplier
>::_duplicate (supplier
))
19 , default_POA_ (PortableServer::POA::_duplicate (poa
))
24 Loopback_Consumer::connect (RtecEventChannelAdmin::EventChannel_ptr ec
)
26 RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin
=
30 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
31 if (!CORBA::is_nil (this->proxy_supplier_
.in ()))
34 this->proxy_supplier_
=
35 consumer_admin
->obtain_push_supplier ();
38 RtecEventComm::PushConsumer_var consumer
=
41 RtecEventChannelAdmin::ConsumerQOS consumer_qos
;
42 consumer_qos
.is_gateway
= 0;
43 consumer_qos
.dependencies
.length (2);
44 RtecEventComm::EventHeader
& h0
=
45 consumer_qos
.dependencies
[0].event
.header
;
46 h0
.type
= ACE_ES_DISJUNCTION_DESIGNATOR
;
49 RtecEventComm::EventHeader
& h1
=
50 consumer_qos
.dependencies
[1].event
.header
;
51 h1
.source
= this->experiment_id_
;
52 h1
.type
= this->event_type_
;
54 this->proxy_supplier_
->connect_push_consumer (consumer
.in (),
59 Loopback_Consumer::disconnect (void)
61 RtecEventChannelAdmin::ProxyPushSupplier_var proxy
;
63 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
64 if (CORBA::is_nil (this->proxy_supplier_
.in ()))
66 proxy
= this->proxy_supplier_
._retn ();
69 Implicit_Deactivator
deactivator (this);
73 proxy
->disconnect_push_supplier ();
75 catch (const CORBA::Exception
&){}
79 Loopback_Consumer::push (const RtecEventComm::EventSet
&events
)
81 // ACE_DEBUG ((LM_DEBUG, "Loopback_Consumer::push (%P|%t)\n"));
82 this->supplier_
->push (events
);
86 Loopback_Consumer::disconnect_push_consumer (void)
88 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
89 this->proxy_supplier_
=
90 RtecEventChannelAdmin::ProxyPushSupplier::_nil ();
93 PortableServer::POA_ptr
94 Loopback_Consumer::_default_POA (void)
96 return PortableServer::POA::_duplicate (this->default_POA_
.in ());