Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / CosEvent / lib / Counting_Consumer.h
blob7147c48795853c12d52759738d3d6c24277c0dba
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
4 * @file Counting_Consumer.h
6 * @author Carlos O'Ryan (coryan@cs.wustl.edu)
7 */
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)
17 # pragma once
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include "orbsvcs/CosEventCommS.h"
21 #include "orbsvcs/CosEventChannelAdminC.h"
22 #include "ace/Task.h"
24 /**
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
33 public:
34 /// Constructor
35 CEC_Counting_Consumer (const char* name);
37 /// Simple connect/disconnect methods..
38 void connect (CosEventChannelAdmin::ConsumerAdmin_ptr consumer_admin);
39 void disconnect ();
41 /// Print out an error message if the event count is too far from the
42 /// expected count.
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;
57 protected:
58 /// The proxy
59 CosEventChannelAdmin::ProxyPushSupplier_var supplier_proxy_;
61 /// The name
62 const char* name_;
65 // ****************************************************************
67 /**
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
76 public:
77 /// Constructor
78 CEC_Pull_Counting_Consumer (const char* name);
80 /// Simple connect/disconnect methods..
81 void connect (CosEventChannelAdmin::ConsumerAdmin_ptr consumer_admin);
82 void disconnect ();
84 /// Print out an error message if the event count is too far from the
85 /// expected count.
86 void dump_results (int expected_count, int tolerance);
88 CORBA::Any *pull ();
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;
101 protected:
102 /// The proxy
103 CosEventChannelAdmin::ProxyPullSupplier_var supplier_proxy_;
105 /// The name
106 const char* name_;
109 // ****************************************************************
111 class CEC_Test_Export CEC_Counting_Consumer_Task : public ACE_Task_Base
113 public:
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.
119 int svc ();
121 void stop ();
122 CORBA::ULong pull_count ();
124 /// Run a single iteration of the test
125 void run ();
127 private:
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
132 int stop_flag_;
134 /// Count the number of pull() calls
135 CORBA::ULong pull_count_;
137 /// If not zero then pause for <milliseconds> before sending each
138 /// event.
139 int milliseconds_;
141 TAO_SYNCH_MUTEX lock_;
144 #endif /* ECT_CONSUMER_H */