Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / Bug_3688b_Regression / TestBroadcaster.cpp
blob0077fb4b1fe44126e08d7d00fcf38a0b24a40e1b
1 #include "TestBroadcaster.h"
3 TestBroadcaster::TestBroadcaster()
7 TestBroadcaster::~TestBroadcaster() noexcept
9 // ensure nothrow guarantee
10 try
12 disconnect();
13 } /* end of try */
14 catch(...)
19 bool TestBroadcaster::connect(
20 CORBA::ORB_ptr p_orb,
21 std::string const & rc_channelIor)
23 try
25 CosNotifyChannelAdmin::EventChannel_var v_eventChannel;
26 CosNotifyChannelAdmin::SupplierAdmin_var v_supplierAdmin;
27 CosNotifyChannelAdmin::ProxyConsumer_var v_proxyConsumer;
28 CosNotifyChannelAdmin::AdminID supplierAdminId;
29 CosNotifyChannelAdmin::ProxyID proxyConsumerId;
31 CORBA::Object_var v_obj = p_orb->string_to_object(rc_channelIor.c_str());
33 v_eventChannel = CosNotifyChannelAdmin::EventChannel::_narrow(v_obj.in());
35 v_supplierAdmin =
36 v_eventChannel->new_for_suppliers (
37 CosNotifyChannelAdmin::OR_OP,
38 supplierAdminId);
40 v_proxyConsumer = v_supplierAdmin->obtain_notification_push_consumer(
41 CosNotifyChannelAdmin::SEQUENCE_EVENT,
42 proxyConsumerId);
44 mv_sequenceProxyPushConsumer =
45 CosNotifyChannelAdmin::SequenceProxyPushConsumer::_narrow(
46 v_proxyConsumer.in());
48 mv_sequenceProxyPushConsumer->connect_sequence_push_supplier(
49 CosNotifyComm::SequencePushSupplier::_nil());
51 catch(...)
53 return false;
56 return true;
59 bool TestBroadcaster::disconnect()
61 try
63 if(isConnected())
65 mv_sequenceProxyPushConsumer->disconnect_sequence_push_consumer();
66 mv_sequenceProxyPushConsumer = CosNotifyChannelAdmin::SequenceProxyPushConsumer_var();
68 } /* end of try */
69 catch(...)
71 return false;
74 return true;
75 } /* end of TestBroadcaster::disconnect */
78 bool TestBroadcaster::sendData()
80 try
82 CosNotification::EventBatch events;
83 events.length(5);
85 for (CORBA::ULong idx = 0, max = events.length(); idx < max; ++idx)
87 events[idx].header.fixed_header.event_type.domain_name = "Test";
88 events[idx].header.fixed_header.event_type.type_name = "Data";
89 events[idx].header.fixed_header.event_name = "Info";
90 events[idx].header.variable_header.length(0);
92 // provide filter criteria
93 events[idx].filterable_data.length(1);
94 events[idx].filterable_data[0].name = "data";
95 events[idx].filterable_data[0].value <<= idx;
97 events[idx].remainder_of_body <<= idx;
98 } /* end of for */
100 mv_sequenceProxyPushConsumer->push_structured_events(events);
102 catch(...)
104 return false;
107 return true;
110 bool TestBroadcaster::isConnected() const
112 return !CORBA::is_nil(mv_sequenceProxyPushConsumer.in());