3 //=============================================================================
5 * @file Broadcaster_i.h
7 * Defines the implementation header for the Broadcaster interface.
9 * @author Pradeep Gore <pradeep@cs.wustl.edu>
11 //=============================================================================
14 #ifndef BROADCASTER_I_H
15 #define BROADCASTER_I_H
17 #include "BroadcasterS.h"
18 #include "ReceiverC.h"
19 #include "tao/Utils/ORB_Manager.h"
20 #include "ace/Containers.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "ace/SString.h"
29 * @class Broadcaster_i
31 * @brief The implementation of the Broadcaster class, which is the
32 * servant object for the chat server.
34 class Broadcaster_i
: public POA_Broadcaster
38 Broadcaster_i () = default;
41 virtual ~Broadcaster_i () = default;
43 /// Saves receiver references in a list.
44 virtual void add (Receiver_ptr receiver
,
45 const char *nickname
);
47 /// Removes receiver references from the list.
48 virtual void remove (Receiver_ptr receiver
);
50 /// Called by Broadcaster clients to send messages.
51 virtual void say (Receiver_ptr receiver
,
56 TAO_ORB_Manager orb_manager_
;
58 /// Broadcasts the text to all registered clients.
59 void broadcast (const char* text
);
62 * @class Receiver_Data
64 * @brief Per-client info.
66 * Saves the Receiver_var and user nickname.
71 /// The == op required by the ACE_Unbounded set.
72 bool operator == (const Receiver_Data
&receiver_data
) const;
74 /// Stores the receiver reference.
75 Receiver_var receiver_
;
77 /// Stores the client nickname.
78 ACE_CString nickname_
;
81 typedef ACE_Unbounded_Set
<Receiver_Data
>
83 typedef ACE_Unbounded_Set_Iterator
<Receiver_Data
>
84 RECEIVER_SET_ITERATOR
;
86 /// Set of registered clients.
87 RECEIVER_SET receiver_set_
;
90 #endif /* BROADCASTER_I_H */