1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// $Id$
#include "EC_Per_Supplier_Filter.h"
#include "EC_Event_Channel.h"
#include "EC_ProxyPushSupplier_Set.h"
#include "EC_ProxySupplier.h"
#include "EC_ProxyConsumer.h"
#include "EC_QOS_Info.h"
#include "orbsvcs/Event_Service_Constants.h"
#if ! defined (__ACE_INLINE__)
#include "EC_Per_Supplier_Filter.i"
#endif /* __ACE_INLINE__ */
ACE_RCSID(Event, EC_Per_Supplier_Filter, "$Id$")
TAO_EC_Per_Supplier_Filter::
TAO_EC_Per_Supplier_Filter (TAO_EC_Event_Channel* ec)
: event_channel_ (ec)
{
this->supplier_set_ =
this->event_channel_->create_proxy_push_supplier_set ();
}
TAO_EC_Per_Supplier_Filter::~TAO_EC_Per_Supplier_Filter (void)
{
this->event_channel_->destroy_proxy_push_supplier_set (this->supplier_set_);
this->supplier_set_ = 0;
}
void
TAO_EC_Per_Supplier_Filter::bind (TAO_EC_ProxyPushConsumer* consumer)
{
this->consumer_ = consumer;
}
void
TAO_EC_Per_Supplier_Filter::unbind (TAO_EC_ProxyPushConsumer* consumer)
{
if (this->consumer_ != 0 && this->consumer_ != consumer)
return;
this->consumer_ = 0;
}
void
TAO_EC_Per_Supplier_Filter::connected (TAO_EC_ProxyPushSupplier* supplier,
CORBA::Environment &ACE_TRY_ENV)
{
if (this->consumer_ == 0)
return;
const RtecEventChannelAdmin::SupplierQOS& pub =
this->consumer_->publications ();
for (CORBA::ULong j = 0; j < pub.publications.length (); ++j)
{
const RtecEventComm::Event& event =
pub.publications[j].event;
RtecEventComm::EventType type = event.header.type;
// ACE_DEBUG ((LM_DEBUG, "In %x trying to match %d\n", this, type));
// if (0 <= type && type < ACE_ES_EVENT_UNDEFINED)
// continue;
if (supplier->can_match (event.header))
{
// ACE_DEBUG ((LM_DEBUG, " Matches %x\n", supplier));
this->supplier_set_->connected (supplier, ACE_TRY_ENV);
return;
}
}
}
void
TAO_EC_Per_Supplier_Filter::disconnected (TAO_EC_ProxyPushSupplier* supplier,
CORBA::Environment &ACE_TRY_ENV)
{
this->supplier_set_->disconnected (supplier, ACE_TRY_ENV);
}
void
TAO_EC_Per_Supplier_Filter::push (const RtecEventComm::EventSet& event,
CORBA::Environment &ACE_TRY_ENV)
{
for (CORBA::ULong j = 0; j < event.length (); ++j)
{
const RtecEventComm::Event& e = event[j];
RtecEventComm::Event* buffer =
ACE_const_cast(RtecEventComm::Event*, &e);
RtecEventComm::EventSet single_event (1, 1, buffer, 0);
ACE_GUARD_THROW_EX (TAO_EC_ProxyPushSupplier_Set::Busy_Lock,
ace_mon, this->supplier_set_->busy_lock (),
RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());
ACE_CHECK;
TAO_EC_ProxyPushSupplier_Set::SupplierSetIterator end =
this->supplier_set_->end ();
for (TAO_EC_ProxyPushSupplier_Set::SupplierSetIterator i =
this->supplier_set_->begin ();
i != end;
++i)
{
TAO_EC_QOS_Info qos_info;
(*i)->filter (single_event, qos_info, ACE_TRY_ENV);
ACE_CHECK;
}
}
}
// ****************************************************************
TAO_EC_SupplierFiltering*
TAO_EC_Per_Supplier_Filter_Builder::create (
RtecEventChannelAdmin::SupplierQOS&)
{
return new TAO_EC_Per_Supplier_Filter (this->event_channel_);
}
void
TAO_EC_Per_Supplier_Filter_Builder::destroy (
TAO_EC_SupplierFiltering* x)
{
delete x;
}
|