2 //=============================================================================
6 * Class to demo structured event subscription.
8 * @author Pradeep Gore <pradeep@cs.wustl.edu>
10 //=============================================================================
13 #ifndef NOTIFY_SUBSCRIBE_CLIENT_H
14 #define NOTIFY_SUBSCRIBE_CLIENT_H
16 #include "orbsvcs/CosNotifyChannelAdminS.h"
17 #include "orbsvcs/CosNotifyCommC.h"
18 #include "orbsvcs/CosNamingC.h"
20 class Subscribe_StructuredPushConsumer
;
21 class Subscribe_StructuredPushSupplier
;
28 * Shows how consumers subscribe for events.
37 void init (int argc
, ACE_TCHAR
*argv
[]);
42 /// Called when all events we are waiting for have occurred.
46 /// Initializes the ORB.
47 void init_ORB (int argc
, ACE_TCHAR
*argv
[]);
49 /// Try to get hold of a running naming service.
50 void resolve_naming_service (void);
52 /// Try to resolve the Notify factory from the Naming service.
53 void resolve_Notify_factory (void);
56 void create_EC (void);
58 /// Create the Supplier Admin.
59 void create_supplieradmin(void);
61 /// Create the Consumer Admin.
62 void create_consumeradmin (void);
64 /// Create and initialize the consumers.
65 void create_consumers (void);
67 /// create and initialize the suppliers.
68 void create_suppliers (void);
71 void send_events (void);
74 /// Reference to the root poa.
75 PortableServer::POA_var root_poa_
;
77 /// The ORB that we use.
80 /// Handle to the name service.
81 CosNaming::NamingContext_var naming_context_
;
84 CosNotifyChannelAdmin::EventChannelFactory_var notify_factory_
;
86 /// The one channel that we create using the factory.
87 CosNotifyChannelAdmin::EventChannel_var ec_
;
89 /// The group operator between admin-proxy's.
90 CosNotifyChannelAdmin::InterFilterGroupOperator ifgop_
;
92 /// Initial qos specified to the factory when creating the EC.
93 CosNotification::QoSProperties initial_qos_
;
95 /// Initial admin props specified to the factory when creating the EC.
96 CosNotification::AdminProperties initial_admin_
;
98 /// The consumer admin used by consumers.
99 CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin_
;
101 /// The supplier admin used by suppliers.
102 CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin_
;
104 Subscribe_StructuredPushConsumer
* consumer_1_
;
105 Subscribe_StructuredPushConsumer
* consumer_2_
;
107 Subscribe_StructuredPushSupplier
* supplier_1_
;
108 Subscribe_StructuredPushSupplier
* supplier_2_
;
110 /// Set this flag to exit the run loop.
111 CORBA::Boolean done_
;
114 /*****************************************************************/
115 class Subscribe_StructuredPushConsumer
116 : public POA_CosNotifyComm::StructuredPushConsumer
119 // Subscribe_StructuredPushConsumer
122 // Consumer for the Subscribe example.
126 Subscribe_StructuredPushConsumer (Subscribe
* subscribe
);
128 /// Connect the Consumer to the EventChannel.
129 /// Creates a new proxy supplier and connects to it.
130 void connect (CosNotifyChannelAdmin::ConsumerAdmin_ptr consumer_admin
);
132 /// Disconnect from the supplier.
133 virtual void disconnect (void);
135 /// Accessor for the Proxy that we're connected to.
136 CosNotifyChannelAdmin::StructuredProxyPushSupplier_ptr
get_proxy_supplier (void);
138 // public data member for evaluating the results of subscription.
139 CosNotification::EventTypeSeq expected_subscription_
;
142 /// The proxy that we are connected to.
143 CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxy_supplier_
;
145 /// The proxy_supplier id.
146 CosNotifyChannelAdmin::ProxyID proxy_supplier_id_
;
149 Subscribe
* subscribe_
;
153 virtual ~Subscribe_StructuredPushConsumer (void);
155 // = NotifyPublish method
156 virtual void offer_change (
157 const CosNotification::EventTypeSeq
& added
,
158 const CosNotification::EventTypeSeq
& removed
);
160 // = StructuredPushSupplier methods
161 virtual void push_structured_event (
162 const CosNotification::StructuredEvent
& notification
);
164 virtual void disconnect_structured_push_consumer ();
167 /*****************************************************************/
169 class Subscribe_StructuredPushSupplier
170 : public POA_CosNotifyComm::StructuredPushSupplier
173 // Subscribe_StructuredPushSupplier
176 // Supplier for the SUBSCRIBE example.
180 Subscribe_StructuredPushSupplier (void);
182 /// Connect the Supplier to the EventChannel.
183 /// Creates a new proxy consumer and connects to it.
184 void connect (CosNotifyChannelAdmin::SupplierAdmin_ptr supplier_admin
);
186 /// Disconnect from the supplier.
187 void disconnect (void);
190 virtual void send_event (const CosNotification::StructuredEvent
& event
);
194 /// The proxy that we are connected to.
195 CosNotifyChannelAdmin::StructuredProxyPushConsumer_var proxy_consumer_
;
197 /// This supplier's id.
198 CosNotifyChannelAdmin::ProxyID proxy_consumer_id_
;
200 // = Protected Methods
202 virtual ~Subscribe_StructuredPushSupplier ();
205 virtual void subscription_change (
206 const CosNotification::EventTypeSeq
& added
,
207 const CosNotification::EventTypeSeq
& removed
);
209 // = StructuredPushSupplier method
210 virtual void disconnect_structured_push_supplier ();
213 #endif /* NOTIFY_SUBSCRIBE_CLIENT_H */