blob: 8a1fca47def78145714d20e84858d5844e9253af (
plain)
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
|
#include "TestListener.h"
TestListener::TestListener(
CORBA::ORB * p_orb,
std::string const & rc_channelIor,
std::string const & rc_filterExpression
)
{
CORBA::Object_var v_poa =
p_orb->resolve_initial_references("RootPOA");
mv_rootPOA = PortableServer::POA::_narrow (v_poa.in ());
PortableServer::ServantBase * p_servant = this;
mv_oid = mv_rootPOA->activate_object(p_servant);
mv_this = mv_rootPOA->id_to_reference(mv_oid.in());
CORBA::Object_var v_obj = p_orb->string_to_object(rc_channelIor.c_str());
mv_eventChannel = CosNotifyChannelAdmin::EventChannel::_narrow(v_obj.in());
mv_consumerAdmin = mv_eventChannel->new_for_consumers(
CosNotifyChannelAdmin::AND_OP,
m_consumerAdminId
);
CosNotifyFilter::FilterFactory_var v_filterFactory =
mv_eventChannel->default_filter_factory();
// setup a filter at the consumer admin
CosNotifyFilter::Filter_var v_filter =
// v_filterFactory->create_filter("ETCL");
v_filterFactory->create_filter("EXTENDED_TCL");
// v_filterFactory->create_filter("TCL");
CosNotifyFilter::ConstraintExpSeq constraintSeq(1);
constraintSeq.length(1);
// Set up constraint expression for new filter
constraintSeq[0].event_types.length(1);
constraintSeq[0].event_types[0].domain_name = "Test";
constraintSeq[0].event_types[0].type_name = "Data";
constraintSeq[0].constraint_expr = rc_filterExpression.c_str();
v_filter->add_constraints (constraintSeq);
mv_consumerAdmin->add_filter(v_filter.in());
v_obj = mv_rootPOA->id_to_reference(mv_oid.in());
mv_structuredPushConsumer = CosNotifyComm::StructuredPushConsumer::_narrow(v_obj.in());
CosNotifyChannelAdmin::ProxySupplier_var v_proxySupplier =
mv_consumerAdmin->obtain_notification_push_supplier(
CosNotifyChannelAdmin::STRUCTURED_EVENT,
m_proxySupplierId
);
mv_proxySupplier =
CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(
v_proxySupplier.in()
);
mv_proxySupplier->connect_structured_push_consumer(mv_structuredPushConsumer.in());
}
TestListener::~TestListener()
{
if(!CORBA::is_nil(mv_proxySupplier.in()))
{
// calls to disconnect_structured_push_supplier implicitely destroy
// the proxy, so we must set the proxy reference as nil.
mv_proxySupplier->disconnect_structured_push_supplier();
mv_proxySupplier = CosNotifyChannelAdmin::StructuredProxyPushSupplier_var();
}
if(!CORBA::is_nil(mv_structuredPushConsumer.in()) && !CORBA::is_nil(mv_rootPOA.in()))
{
mv_rootPOA->deactivate_object(mv_oid.in());
}
}
void TestListener::push_structured_event (
const CosNotification::StructuredEvent & notification
)
{
CORBA::Long data;
notification.remainder_of_body >>= data;
m_receivedData.push_back(data);
}
void TestListener::disconnect_structured_push_consumer ( )
{
}
void TestListener::offer_change(
const CosNotification::EventTypeSeq & ,
const CosNotification::EventTypeSeq &
)
{
}
|