Merge pull request #2306 from mitza-oci/warnings
[ACE_TAO.git] / TAO / orbsvcs / examples / Notify / ThreadPool / Supplier.h
blob5b263d76ae1a77e347a18d160c3266a60a0047e9
1 /* -*- C++ -*- */
2 /**
3 * @file Supplier.h
5 * @author Pradeep Gore <pradeep@oomworks.com>
6 */
8 #ifndef TAO_Notify_SUPPLIER_H
9 #define TAO_Notify_SUPPLIER_H
10 #include /**/ "ace/pre.h"
12 #include "ORB_Objects.h"
13 #include "tao/RTCORBA/RTCORBA.h"
14 #include "orbsvcs/CosNotifyChannelAdminS.h"
15 #include "orbsvcs/CosNotifyCommC.h"
16 #include "ace/Condition_Thread_Mutex.h"
18 #define TEST_MAX_CONSUMERS 10
20 /**
21 * @class TAO_Notify_ThreadPool_Supplier
23 * @brief Implement a Structured Supplier.
25 class TAO_Notify_ThreadPool_Supplier
26 : public POA_CosNotifyComm::StructuredPushSupplier
28 public:
29 /// Constructor.
30 TAO_Notify_ThreadPool_Supplier (TAO_Notify_ORB_Objects& orb_objects);
32 /// Init
33 void init (CosNotifyChannelAdmin::SupplierAdmin_var& admin, int expected_consumer_count, int max_events,
34 int proxy_consumer_thread_count);
36 /// Run
37 void run ();
39 protected:
40 // = Protected Methods
42 /// Connect the Supplier to the EventChannel.
43 /// Creates a new proxy consumer and connects to it.
44 void connect ();
46 /// Disconnect the supplier.
47 void disconnect ();
49 /// Deactivate.
50 void deactivate ();
52 /// Send one event.
53 virtual void send_event (const CosNotification::StructuredEvent& event);
55 /// Destructor
56 virtual ~TAO_Notify_ThreadPool_Supplier ();
58 // = NotifySubscribe
59 virtual void subscription_change (
60 const CosNotification::EventTypeSeq & added,
61 const CosNotification::EventTypeSeq & removed);
63 // = StructuredPushSupplier method
64 virtual void disconnect_structured_push_supplier ();
65 /// = Data members
67 /// ORB Objects.
68 TAO_Notify_ORB_Objects orb_objects_;
70 /// The proxy that we are connected to.
71 CosNotifyChannelAdmin::StructuredProxyPushConsumer_var proxy_consumer_;
73 /// This supplier's id.
74 CosNotifyChannelAdmin::ProxyID proxy_consumer_id_;
76 /// Number of Consumers expected to connect.
77 int expected_consumer_count_;
79 // The ORB that we use.
80 CORBA::ORB_var orb_;
82 // The Supplier Admin
83 CosNotifyChannelAdmin::SupplierAdmin_var admin_;
85 /// Lock to serialize internal state.
86 TAO_SYNCH_MUTEX lock_;
88 /// Condition that consumers are connected.
89 TAO_SYNCH_CONDITION consumers_connected_;
91 /// Number of consumers connected.
92 int consumer_count_;
94 /// Number of events to send.
95 int max_events_;
97 /// Number of Threads at the ProxyConsumer.
98 int proxy_consumer_thread_count_;
100 /// Array of events to send.
101 CosNotification::StructuredEvent event_[TEST_MAX_CONSUMERS];
104 #include /**/ "ace/post.h"
105 #endif /* TAO_Notify_SUPPLIER_H */