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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
// $Id$
#include "Counting_Consumer.h"
#include "Counting_Supplier.h"
#include "orbsvcs/Time_Utilities.h"
#include "orbsvcs/Event_Utilities.h"
#include "orbsvcs/Event/EC_Event_Channel.h"
#include "orbsvcs/Event/EC_Default_Factory.h"
ACE_RCSID(EC_Tests, Bitmask, "$Id$")
int
main (int argc, char* argv[])
{
TAO_EC_Default_Factory::init_svcs ();
TAO_ENV_DECLARE_NEW_ENV;
ACE_TRY
{
// ORB initialization boiler plate...
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv, "" TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
CORBA::Object_var object =
orb->resolve_initial_references ("RootPOA" TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
PortableServer::POA_var poa =
PortableServer::POA::_narrow (object.in () TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
PortableServer::POAManager_var poa_manager =
poa->the_POAManager (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
poa_manager->activate (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
// ****************************************************************
TAO_EC_Event_Channel_Attributes attributes (poa.in (),
poa.in ());
attributes.consumer_reconnect = 1;
attributes.supplier_reconnect = 1;
TAO_EC_Event_Channel ec_impl (attributes);
ec_impl.activate (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
RtecEventChannelAdmin::EventChannel_var event_channel =
ec_impl._this (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
// ****************************************************************
// Obtain the consumer admin..
RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin =
event_channel->for_consumers (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
// Obtain the supplier admin..
RtecEventChannelAdmin::SupplierAdmin_var supplier_admin =
event_channel->for_suppliers (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
// ****************************************************************
const int milliseconds = 50;
EC_Counting_Supplier first_supplier;
first_supplier.activate (consumer_admin.in (),
milliseconds
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
first_supplier.connect (supplier_admin.in (),
0x00001111UL,
0x11110000UL,
0x00001111UL,
0x11110000UL
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
EC_Counting_Supplier second_supplier;
second_supplier.activate (consumer_admin.in (),
milliseconds
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
second_supplier.connect (supplier_admin.in (),
0x01100000UL,
0x00000110UL,
0x01100000UL,
0x00000110UL
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
// ****************************************************************
EC_Counting_Consumer consumer_bitmask_reject ("Consumer/bitmask/reject");
// Create a consumer, intialize its RT_Info structures, and
// connnect to the event channel....
{
ACE_ConsumerQOS_Factory consumer_qos;
consumer_qos.start_bitmask (0x00001111, 0x11110000);
consumer_qos.start_disjunction_group (1);
consumer_qos.insert (0x01100000, 0x00000110, 0);
consumer_bitmask_reject.connect (consumer_admin.in (),
consumer_qos.get_ConsumerQOS ()
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
// ****************************************************************
EC_Counting_Consumer consumer_bitmask_accept ("Consumer/bitmask/accept");
// Create a consumer, intialize its RT_Info structures, and
// connnect to the event channel....
{
ACE_ConsumerQOS_Factory consumer_qos;
consumer_qos.start_bitmask (0x01100110, 0x01100110);
consumer_qos.insert_null_terminator ();
consumer_bitmask_accept.connect (consumer_admin.in (),
consumer_qos.get_ConsumerQOS ()
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
// ****************************************************************
EC_Counting_Consumer consumer_bitmask_filter ("Consumer/bitmask/filter");
// Create a consumer, intialize its RT_Info structures, and
// connnect to the event channel....
{
ACE_ConsumerQOS_Factory consumer_qos;
consumer_qos.start_bitmask (0x00000110, 0x01100000);
consumer_qos.insert_null_terminator ();
consumer_bitmask_filter.connect (consumer_admin.in (),
consumer_qos.get_ConsumerQOS ()
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
// ****************************************************************
EC_Counting_Consumer consumer_bitmask_value ("Consumer/bitmask/value");
// Create a consumer, intialize its RT_Info structures, and
// connnect to the event channel....
{
ACE_ConsumerQOS_Factory consumer_qos;
consumer_qos.start_disjunction_group (1);
consumer_qos.insert_bitmasked_value (0x11110000, 0x00001111,
0x01100000, 0x00000110);
consumer_bitmask_value.connect (consumer_admin.in (),
consumer_qos.get_ConsumerQOS ()
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
// ****************************************************************
EC_Counting_Consumer consumer_bitmask_loose ("Consumer/bitmask/loose");
// Create a consumer, intialize its RT_Info structures, and
// connnect to the event channel....
{
ACE_ConsumerQOS_Factory consumer_qos;
consumer_qos.start_disjunction_group (1);
consumer_qos.insert_bitmasked_value (0x11111111, 0x11111111,
0x01100000, 0x00000110);
consumer_bitmask_loose.connect (consumer_admin.in (),
consumer_qos.get_ConsumerQOS ()
TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
// ****************************************************************
ACE_Time_Value tv (5, 0);
// Wait for events, using work_pending()/perform_work() may help
// or using another thread, this example is too simple for that.
orb->run (tv);
// ****************************************************************
consumer_bitmask_loose.disconnect (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
consumer_bitmask_value.disconnect (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
consumer_bitmask_filter.disconnect (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
consumer_bitmask_accept.disconnect (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
consumer_bitmask_reject.disconnect (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
// ****************************************************************
second_supplier.deactivate (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
second_supplier.disconnect (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
first_supplier.deactivate (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
first_supplier.disconnect (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
// ****************************************************************
event_channel->destroy (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
// ****************************************************************
poa->destroy (1, 1 TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
// ****************************************************************
consumer_bitmask_reject.dump_results (0, 5);
CORBA::ULong expected =
first_supplier.event_count
+ second_supplier.event_count;
consumer_bitmask_accept.dump_results (expected, 5);
expected = second_supplier.event_count;
consumer_bitmask_filter.dump_results (expected, 5);
expected = second_supplier.event_count;
consumer_bitmask_value.dump_results (expected, 5);
expected = second_supplier.event_count;
consumer_bitmask_loose.dump_results (expected, 5);
orb->destroy (TAO_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Service");
return 1;
}
ACE_ENDTRY;
return 0;
}
// ****************************************************************
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
#elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
|