Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / orbsvcs / tests / EC_Custom_Marshal / ECM_Consumer.h
blob625bbcf9b5506dd1ffd048b376f951ae55360439
1 /* -*- C++ -*- */
2 //
3 // ============================================================================
4 //
5 // = DESCRIPTION
6 // An example on custom marshaling in TAO.
7 //
8 // ============================================================================
10 #ifndef ECM_CONSUMER_H
11 #define ECM_CONSUMER_H
13 #include "ace/Task.h"
15 #if !defined (ACE_LACKS_PRAGMA_ONCE)
16 # pragma once
17 #endif /* ACE_LACKS_PRAGMA_ONCE */
19 #include "orbsvcs/Channel_Clients_T.h"
20 #include "orbsvcs/RtecEventChannelAdminC.h"
21 #include "ace/OS_NS_time.h"
23 class Driver;
25 class Test_Consumer : public POA_RtecEventComm::PushConsumer
28 // = TITLE
29 // Receive the events.
31 // = DESCRIPTION
32 public:
33 Test_Consumer (Driver* driver, void* cookie);
35 void connect (int event_a,
36 int event_b,
37 RtecEventChannelAdmin::EventChannel_ptr ec);
38 // This method connects the consumer to the EC.
40 void disconnect ();
41 // Disconnect from the EC.
43 virtual void push (const RtecEventComm::EventSet& events);
44 virtual void disconnect_push_consumer ();
45 // The skeleton methods.
47 private:
48 Driver* driver_;
49 // The main driver for the test.
51 void* cookie_;
52 // A magic cookie passed by the driver that we pass back in our
53 // callbacks.
55 RtecEventChannelAdmin::ProxyPushSupplier_var supplier_proxy_;
56 // We talk to the EC using this proxy.
59 class Driver
62 // = TITLE
64 // = DESCRIPTION
66 public:
67 Driver ();
69 enum {
70 MAX_CONSUMERS = 16
71 // Maximum number of consumers.
74 int run (int argc, ACE_TCHAR* argv[]);
75 // Execute the test.
77 void push_consumer (void* consumer_cookie,
78 ACE_hrtime_t arrival,
79 const RtecEventComm::EventSet& events);
80 // Callback method for consumers, if any of our consumers has
81 // received events it will invoke this method.
83 private:
84 int parse_args (int argc, ACE_TCHAR* argv[]);
85 // parse the command line args
87 void connect_consumers (RtecEventChannelAdmin::EventChannel_ptr local_ec);
88 void disconnect_consumers ();
89 // Connect and disconnect the consumers.
91 private:
92 Test_Consumer* consumers_[Driver::MAX_CONSUMERS];
93 // The consumer array.
95 int n_consumers_;
96 // The number of consumers.
98 int event_count_;
99 // How many messages we will send in the suppliers
101 int event_a_;
102 int event_b_;
103 // We send two types of events, with different contents.
105 const ACE_TCHAR* pid_file_name_;
106 // The name of a file where the process stores its pid
108 TAO_SYNCH_MUTEX recv_count_mutex_;
109 int recv_count_;
110 // How many events we have received.
113 #endif /* ECM_CONSUMER_H */