1 //=============================================================================
5 * Class interface for the implementation of the distributed
6 * event notification mechanism.
8 * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) and Pradeep Gore <pradeep@cs.wustl.edu>
10 //=============================================================================
12 #ifndef _EVENT_COMM_I_H
13 #define _EVENT_COMM_I_H
15 #include "ace/Map_Manager.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Synch.h"
22 #include "ace/SString.h"
23 #include "Event_CommS.h"
24 #include "ace/Reactor.h"
25 #include "ace/Null_Mutex.h"
28 * @class ShutdownCallback
30 * @brief Helper callback class to shutdown the application.
32 class ShutdownCallback
36 virtual ~ShutdownCallback ();
38 /// This method is to be called to shutdown the application.
39 virtual void close () = 0;
45 * @brief Defines the implementation class for event <Consumers>.
47 class Consumer_i
: public POA_Event_Comm::Consumer
56 /// set the ACE_Reactor to use when quitting.
57 void set_reactor (ACE_Reactor
*reactor
);
59 /// Pass the q event to the <Consumer>.
60 virtual void push (const Event_Comm::Event
& event
);
62 // Disconnect the <Consumer> from the <Notifier>, giving it the
64 virtual void disconnect (const char * reason
);
66 /// Set the Shutdown callback.
67 void set (ShutdownCallback
*_shutdown
);
70 /// The callback to shutdown the consumer application.
71 ShutdownCallback
*shutdown
;
80 * @brief Defines the implementation class for event <Notifiers>.
82 class Notifier_i
: public POA_Event_Comm::Notifier
88 // Default max number of Event_Comm::Consumers.
91 /// Initialize a Notifier_i object with the specified size hint.
92 Notifier_i (size_t size_hint
= Notifier_i::DEFAULT_SIZE
);
94 /// Disconnect all the receivers, giving them the @a reason.
95 virtual void disconnect (const char *reason
);
97 /// Send the @a event to all the consumers who have subscribed and who
98 /// match the filtering criteria.
99 virtual void push (const Event_Comm::Event
&event
);
101 /// Subscribe the @a consumer to receive events that match
102 /// @a filtering_criteria applied by the <Notifier>.
103 virtual void subscribe (Event_Comm::Consumer_ptr Consumer
,
104 const char * filtering_criteria
);
106 /// Unsubscribe the @a Consumer.
107 void unsubscribe (Event_Comm::Consumer
*consumer
,
108 const char *filtering_criteria
);
111 typedef ACE_Map_Manager
<Event_Comm::Consumer_ptr
, Consumer_Entry
*, ACE_Null_Mutex
>
113 typedef ACE_Map_Iterator
<Event_Comm::Consumer_ptr
, Consumer_Entry
*, ACE_Null_Mutex
>
115 typedef ACE_Map_Entry
<Event_Comm::Consumer_ptr
, Consumer_Entry
*>
118 /// Table that maps a <Event_Comm::Consumer *> to a <Consumer_Entry *>.
122 #endif /* _EVENT_COMM_I_H */