2 //=============================================================================
4 * @file Counting_Consumer.h
6 * @author Carlos O'Ryan (coryan@cs.wustl.edu)
8 //=============================================================================
11 #ifndef CEC_COUNTING_CONSUMER_H
12 #define CEC_COUNTING_CONSUMER_H
14 #include "cectest_export.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include "orbsvcs/CosEventCommS.h"
21 #include "orbsvcs/CosEventChannelAdminC.h"
25 * @class CEC_Counting_Consumer
27 * @brief Simple consumer object to implement EC tests.
29 * This is a simple consumer that counts the events it receives.
31 class CEC_Test_Export CEC_Counting_Consumer
: public POA_CosEventComm::PushConsumer
35 CEC_Counting_Consumer (const char* name
);
37 /// Simple connect/disconnect methods..
38 void connect (CosEventChannelAdmin::ConsumerAdmin_ptr consumer_admin
);
41 /// Print out an error message if the event count is too far from the
43 void dump_results (int expected_count
, int tolerance
);
45 // = The CosEventComm::PushConsumer methods
47 /// The skeleton methods.
48 virtual void push (const CORBA::Any
& events
);
49 virtual void disconnect_push_consumer ();
51 /// Keep track of the number of events received.
52 CORBA::ULong event_count
;
54 /// Keep track of the number of disconnect calls received.
55 CORBA::ULong disconnect_count
;
59 CosEventChannelAdmin::ProxyPushSupplier_var supplier_proxy_
;
65 // ****************************************************************
68 * @class CEC_Pull_Counting_Consumer
70 * @brief Simple consumer object to implement EC tests.
72 * This is a simple consumer that counts the events it receives.
74 class CEC_Test_Export CEC_Pull_Counting_Consumer
: public POA_CosEventComm::PullConsumer
78 CEC_Pull_Counting_Consumer (const char* name
);
80 /// Simple connect/disconnect methods..
81 void connect (CosEventChannelAdmin::ConsumerAdmin_ptr consumer_admin
);
84 /// Print out an error message if the event count is too far from the
86 void dump_results (int expected_count
, int tolerance
);
89 CORBA::Any
*try_pull (CORBA::Boolean_out has_event
);
91 // = The CosEventComm::PullConsumer methods
92 /// The skeleton methods.
93 virtual void disconnect_pull_consumer ();
95 /// Keep track of the number of events received.
96 CORBA::ULong event_count
;
98 /// Keep track of the number of disconnect calls received.
99 CORBA::ULong disconnect_count
;
103 CosEventChannelAdmin::ProxyPullSupplier_var supplier_proxy_
;
109 // ****************************************************************
111 class CEC_Test_Export CEC_Counting_Consumer_Task
: public ACE_Task_Base
114 /// Create the task...
115 CEC_Counting_Consumer_Task (CEC_Pull_Counting_Consumer
*consumer
,
116 int milliseconds
= 0);
118 // = Check the ACE_Task_Base documentation.
122 CORBA::ULong
pull_count ();
124 /// Run a single iteration of the test
128 /// The consumer we are turning into an active object
129 CEC_Pull_Counting_Consumer
*consumer_
;
131 /// Set to 1 when the test must stop
134 /// Count the number of pull() calls
135 CORBA::ULong pull_count_
;
137 /// If not zero then pause for <milliseconds> before sending each
141 TAO_SYNCH_MUTEX lock_
;
144 #endif /* ECT_CONSUMER_H */