2 //=============================================================================
6 * @author Carlos O'Ryan (coryan@cs.wustl.edu)
8 //=============================================================================
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include "orbsvcs/RtecEventCommS.h"
21 #include "orbsvcs/RtecEventChannelAdminC.h"
22 #include "ace/OS_NS_time.h"
23 #include "ace/High_Res_Timer.h"
28 * @brief Simple consumer object to implement EC tests.
30 * This class is a consumer of events.
31 * The class is just a helper to simplify common tasks in EC
32 * tests, such as subscribing for a range of events, disconnecting
33 * from the EC, informing the driver of shutdown messages, etc.
34 * There are several ways to connect and disconnect this class,
35 * and it is up to the driver program to use the right one.
37 class EC_Test_Export EC_Consumer
: public POA_RtecEventComm::PushConsumer
41 EC_Consumer (EC_Driver
* driver
, void* cookie
);
43 /// The driver program can build the QoS attributes and obtain the
44 /// ConsumerAdmin, we do the rest.
45 virtual void connect (
46 RtecEventChannelAdmin::ConsumerAdmin_ptr consumer_admin
,
47 const RtecEventChannelAdmin::ConsumerQOS
& qos
,
48 int shutdown_event_type
);
51 * The driver program can build the QoS attributes and we use
52 * whatevet supplier_proxy we already have (useful for reconnection
55 virtual void connect (
56 const RtecEventChannelAdmin::ConsumerQOS
& qos
,
57 int shutdown_event_type
);
59 /// returns 0 if it is not connected
60 virtual int connected (void) const;
62 /// The application can invoke this method to disconnect from the EC
63 /// and deactivate this class.
64 void disconnect (void);
66 /// The application is shutting down, deactivate the consumer.
69 /// Accumulate our statistics to the totals.
70 void accumulate (ACE_Throughput_Stats
& throughput
) const;
72 /// Printout the statistics
73 virtual void dump_results (
74 const ACE_TCHAR
* name
,
75 ACE_High_Res_Timer::global_scale_factor_type global_scale_factor
);
77 // = The RtecEventComm::PushConsumer methods
79 /// The skeleton methods.
80 virtual void push (const RtecEventComm::EventSet
& events
);
81 virtual void disconnect_push_consumer (void);
84 /// The main driver for the test.
87 /// A magic cookie passed by the driver that we pass back in our
91 /// We talk to the EC using this proxy.
92 RtecEventChannelAdmin::ProxyPushSupplier_var supplier_proxy_
;
94 /// Protect internal state
95 TAO_SYNCH_MUTEX lock_
;
97 /// The timestamp for the first message received
98 ACE_hrtime_t throughput_start_
;
100 /// Used for reporting stats
101 ACE_Throughput_Stats throughput_
;
103 /// The number of push() calls
106 /// The type used to indicate shutdown
107 int shutdown_event_type_
;
109 /// Is the consumer active in the POA?
112 /// Cache the object reference to speed up connect/disconnect calls.
113 RtecEventComm::PushConsumer_var myself_
;
116 #endif /* ECT_CONSUMER_H */