summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Notify_Event_Manager.h
blob: 78fe19a3be8e0136b267ee84e4be660a3c0a58a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/* -*- C++ -*- */
// $Id$
// ==========================================================================
//
// = LIBRARY
//   Orbsvcs
//
// = FILENAME
//   Notify_Event_Manager.h
//
// = DESCRIPTION
//   An Event Manager for the Notification Service.
//
// = AUTHOR
//    Pradeep Gore <pradeep@cs.wustl.edu>
//
// ==========================================================================

#ifndef TAO_NOTIFY_EVENT_MANAGER
#define TAO_NOTIFY_EVENT_MANAGER
#include "ace/pre.h"
#include "orbsvcs/CosNotificationC.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "notify_export.h"
#include "Notify_Listeners.h"
#include "Notify_Collection.h"

class TAO_Notify_EventChannel_i;
class TAO_Notify_Event;
class TAO_Notify_Event_Processor;
class TAO_Notify_Event_Map;
class TAO_Notify_Update_Dispatcher;
class TAO_Notify_EventSource;
class TAO_Notify_EventListener;
class TAO_Notify_Worker_Task;
class TAO_Notify_EMO_Factory;
class TAO_Notify_Event_Processor;
class TAO_Notify_AdminProperties;

class TAO_Notify_Export TAO_Notify_Event_Manager
{
  // = TITLE
  //   TAO_Notify_Event_Manager
  //
  // = DESCRIPTION
  //   Handles all aspects of event propogation thru the channel.
  //   Also keeps track of publications and subscriptions.

 public:
  // = Initialization and termination code.
  TAO_Notify_Event_Manager (TAO_Notify_EventChannel_i* parent,
                            TAO_Notify_EMO_Factory* emo_factory);
  // Constructor.

  ~TAO_Notify_Event_Manager ();
  // Destructor.

  void init (TAO_ENV_SINGLE_ARG_DECL);
  // Init

  void shutdown (TAO_ENV_SINGLE_ARG_DECL);
  // Shutdown operations.

  // = Publish/Subscribe management
  // = Subscription
  void subscribe_for_events (TAO_Notify_EventListener* event_listener, const CosNotification::EventTypeSeq & added, const CosNotification::EventTypeSeq & removed TAO_ENV_ARG_DECL);
  // Subscribes <event_listener> for events <added>.
  // Unsubscribes <event_listener> for events <removed>.

  // = Publications
  void update_publication_list (const CosNotification::EventTypeSeq & added, const CosNotification::EventTypeSeq & removed TAO_ENV_ARG_DECL);
  // Suppliers can send anonymous requests to the Event Manager to indicate
  // what kind of events they expect to produce.

  // = Updates
  void register_for_subscription_updates (TAO_Notify_UpdateListener* update_listener TAO_ENV_ARG_DECL);
  // Registers the subscription update listener with the Event Manager.

  void unregister_from_subscription_updates (TAO_Notify_UpdateListener* update_listener TAO_ENV_ARG_DECL);
  // Unregister from subscription updates.

  void register_for_publication_updates (TAO_Notify_UpdateListener* update_listener TAO_ENV_ARG_DECL);
  // Registers the publication update listener with the Event Manager.

  void unregister_from_publication_updates (TAO_Notify_UpdateListener* update_listener TAO_ENV_ARG_DECL);
  // Unregister from publication updates.

  // = Accessors
  CosNotification::EventTypeSeq* obtain_offered_types(void);
  // Obtain the publication list.

  CosNotification::EventTypeSeq* obtain_subscription_types (void);
  // Obtain the subscription list.

  TAO_Notify_Event_Map* event_map (void);
  // Get the event map.

  TAO_Notify_Event_Processor* event_processor (void);
  // Get the Event Processor.

  TAO_Notify_AdminProperties* admin_properties (void);
  // Get the Admin Properties.

  TAO_Notify_EMO_Factory* resource_factory (void);
  // Get the Resource Factory.

  // = Event forwarding methods.
  void process_event (TAO_Notify_Event* event,
                      TAO_Notify_EventSource* event_source
                      TAO_ENV_ARG_DECL);
  // Delivers the event to listeners subscribed for <event>
  // <event_source> is the <event> source to the Event Manager.

protected:
  // = Event dispatching methods.
  void dispatch_updates_i (TAO_Notify_UpdateListener_List* update_listener_list,
                           TAO_Notify_EventType_List& added,
                           TAO_Notify_EventType_List& removed
                           TAO_ENV_ARG_DECL);
  // Dispatch the updates to the <update_listener_list>

  // = Data members.
  TAO_Notify_EventChannel_i * event_channel_;
  // The Event Channel that we're managing for.

  TAO_Notify_Event_Map* event_map_;
  // Container for event <-> source/sinks mappings.

  TAO_Notify_Event_Processor * event_processor_;
  // Handles processing of events.

  TAO_Notify_Worker_Task * updates_dispatching_task_;
  // Dispatches updates to update listeners.

  TAO_Notify_EMO_Factory* emo_factory_;
  // Event manager objects factory.

  ACE_Lock* lock_;
  // The locking strategy.

  TAO_Notify_AdminProperties* admin_properties_;
  // Admin properties.
};

/**************************************************************************/

class TAO_Notify_Export TAO_Notify_Update_Worker : public TAO_ESF_Worker<TAO_Notify_UpdateListener>
{
  // = TITLE
  //   TAO_Notify_Update_Worker
  //
  // = DESCRIPTION
  //   Worker to send update commands to the updates dispatching task.
  //
 public:
  // = Initialization and termination code.
  TAO_Notify_Update_Worker (TAO_Notify_Worker_Task * updates_dispatching_task, TAO_Notify_EventType_List& added, TAO_Notify_EventType_List& removed);

  // = TAO_ESF_Worker method
  void work (TAO_Notify_UpdateListener* listener TAO_ENV_ARG_DECL);
 protected:
  // = Data members.
  TAO_Notify_EventType_List& added_;
  TAO_Notify_EventType_List& removed_;
  // Data to transmit.

  TAO_Notify_Worker_Task * updates_dispatching_task_;
  // Update dispatcher
};

#if defined (__ACE_INLINE__)
#include "Notify_Event_Manager.i"
#endif /* __ACE_INLINE__ */

#include "ace/post.h"
#endif /* TAO_NOTIFY_EVENT_MANAGER */