Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / Event_Comm / Event_Comm_i.h
blob14ae32a1fa55310cde03803c2952f214a2fa34b7
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Event_Comm_i.h
7 * Class interface for the implementation of the distributed
8 * event notification mechanism.
10 * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu) and Pradeep Gore <pradeep@cs.wustl.edu>
12 //=============================================================================
15 #ifndef _EVENT_COMM_I_H
16 #define _EVENT_COMM_I_H
18 #include "ace/Map_Manager.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/Synch.h"
25 #include "ace/SString.h"
26 #include "Event_CommS.h"
27 #include "ace/Reactor.h"
28 #include "ace/Null_Mutex.h"
30 /**
31 * @class ShutdownCallback
33 * @brief Helper callback class to shutdown the application.
35 class ShutdownCallback
37 public:
38 /// Destructor.
39 virtual ~ShutdownCallback (void);
41 /// This method is to be called to shutdown the application.
42 virtual void close (void) = 0;
45 /**
46 * @class Consumer_i
48 * @brief Defines the implementation class for event <Consumers>.
50 class Consumer_i : public POA_Event_Comm::Consumer
52 public:
53 /// Constructor.
54 Consumer_i (void);
56 /// Destructor.
57 ~Consumer_i (void);
59 /// set the <ACE_Reactor> to use when quitting.
60 void set_reactor (ACE_Reactor *reactor);
62 /// Pass the <event> to the <Consumer>.
63 virtual void push (const Event_Comm::Event & event);
65 virtual void disconnect (const char * reason);
67 // Disconnect the <Consumer> from the <Notifier>, giving it the
68 // <reason>.
70 /// Set the Shutdown callback.
71 void set (ShutdownCallback *_shutdown);
73 private:
74 /// The callback to shutdown the consumer application.
75 ShutdownCallback *shutdown;
78 // Forward reference.
79 class Consumer_Entry;
81 /**
82 * @class Notifier_i
84 * @brief Defines the implementation class for event <Notifiers>.
86 class Notifier_i : public POA_Event_Comm::Notifier
88 public:
89 enum
91 DEFAULT_SIZE = 1024
92 // Default max number of Event_Comm::Consumers.
95 /// Initialize a Notifier_i object with the specified size hint.
96 Notifier_i (size_t size_hint = Notifier_i::DEFAULT_SIZE);
98 /// Disconnect all the receivers, giving them the <reason>.
99 virtual void disconnect (const char *reason);
101 /// Send the <event> to all the consumers who have subscribed and who
102 /// match the filtering criteria.
103 virtual void push (const Event_Comm::Event &event);
105 /// Subscribe the <Consumer> to receive events that match
106 /// <filtering_criteria> applied by the <Notifier>.
107 virtual void subscribe (Event_Comm::Consumer_ptr Consumer,
108 const char * filtering_criteria);
110 /// Unsubscribe the <Consumer>.
111 void unsubscribe (Event_Comm::Consumer *consumer,
112 const char *filtering_criteria);
114 private:
115 typedef ACE_Map_Manager <Event_Comm::Consumer_ptr, Consumer_Entry *, ACE_Null_Mutex>
116 MAP_MANAGER;
117 typedef ACE_Map_Iterator <Event_Comm::Consumer_ptr, Consumer_Entry *, ACE_Null_Mutex>
118 MAP_ITERATOR;
119 typedef ACE_Map_Entry <Event_Comm::Consumer_ptr, Consumer_Entry *>
120 MAP_ENTRY;
122 /// Table that maps a <Event_Comm::Consumer *> to a <Consumer_Entry *>.
123 MAP_MANAGER map_;
126 #endif /* _EVENT_COMM_I_H */