Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / Timeout / Notify_Structured_Push_Consumer.cpp
blob9faa3a457e709abc67f829d4a18c6f4319da9a51
1 // ******************************************************************
2 // Include Section
3 // ******************************************************************
5 #include "ace/OS_NS_unistd.h"
6 #include "Notify_Structured_Push_Consumer.h"
7 #include "Notify_Test_Client.h"
8 #include "orbsvcs/Notify/Notify_Extensions.h"
9 #include "common.h"
11 // ******************************************************************
12 // Subroutine Section
13 // ******************************************************************
15 Notify_Structured_Push_Consumer::Notify_Structured_Push_Consumer (
16 const char* name,
17 unsigned int expected,
18 Notify_Test_Client& client)
19 : name_ (name),
20 expected_ (expected),
21 count_ (0),
22 client_ (client)
24 this->client_.consumer_start (this);
28 void
29 Notify_Structured_Push_Consumer::_connect (
30 CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin)
32 CosNotifyComm::StructuredPushConsumer_var objref = this->_this ();
34 CosNotifyChannelAdmin::ProxySupplier_var proxysupplier =
35 consumer_admin->obtain_notification_push_supplier (
36 CosNotifyChannelAdmin::STRUCTURED_EVENT,
37 proxy_id_);
39 this->proxy_ =
40 CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow (
41 proxysupplier.in ());
43 this->proxy_->connect_structured_push_consumer (objref.in ());
45 CosNotification::EventTypeSeq added (1);
46 CosNotification::EventTypeSeq removed (1);
47 added.length (1);
48 removed.length (1);
50 added[0].domain_name = CORBA::string_dup ("*");
51 added[0].type_name = CORBA::string_dup ("examples");
53 removed[0].domain_name = CORBA::string_dup ("*");
54 removed[0].type_name = CORBA::string_dup ("*");
56 this->subscription_change (added, removed);
58 // give ownership to POA
59 this->_remove_ref ();
63 void
64 Notify_Structured_Push_Consumer::push_structured_event (
65 const CosNotification::StructuredEvent&)
67 ACE_DEBUG ((LM_DEBUG, "-"));
68 static const ACE_Time_Value sl (1, 0);
70 this->count_++;
71 if (this->count_ > this->expected_)
73 ACE_ERROR ((LM_ERROR,
74 ACE_TEXT ("Structured Consumer (%P|%t): ERROR: too ")
75 ACE_TEXT ("many events received.\n")));
78 if (this->count_ >= this->expected_)
80 ACE_DEBUG ((LM_DEBUG, "\nConsumer received %u events.\n", count_));
81 this->client_.consumer_done (this);
83 ACE_OS::sleep (sl);