LBroadcaster is a PowerPlant class that is used for creating Broadcast and Listen relationships between objects. A broadcaster object communicates to a Listener object by sending messages. This is udeful if you want to have an object that can send messages to many other objects.
Methods :
The methods in this class are:
Data Members:
The data members in this class are:
Operation:
A Broadcaster sends messages to its Listeners. LBroadcaster is an abstract, mix-in class. Broadcasters have a list of Listeners to which they send messages via the BroadcastMessage() method. You attach a Listener to a Broadcaster using the AddListener() function.
Classes derived from LBroadcaster should call the BroadcastMessage() method whenever they want to announce some happening in the code,
such as a change in state. For example, the destructor for LBroadcaster
sends a msg_BroadcasterDied message to its Listeners.
Source files:
See also:
Purpose:
The copy constructor for LBroadcaster makes a copy of the state of mIsBroadcasting data member. Listener links are not copied. The default constructor has no Listeners initially.
Access:
Prototype:
LBroadcaster();
LBroadcaster(const LBroadcaster& inOriginal);Parameters:
Return:
No return value for a constructor
Purpose:
The destructor destroys the LBroadcaster object, and notifies all Listeners that this Broadcaster object is going away.
Access:
Prototype:
virtual ~LBroadcaster();Parameters:
Return:
Purpose:
This method adds a Listener to a Broadcaster object. You must associate Broadcasters with Listeners, not the converse:
theBroadcaster->AddListener(theListener); // correct theListener->AddBroadcaster(theBroadcaster); // incorrect!
This method takes care of notifying the Listener to update its list of Broadcasters.
Access:
Prototype:
void AddListener( LListener *inListener );Parameters:
This method takes the following parameter:
|
Return:
Purpose:
This method broadcasts a message to all associated Listeners. Listeners are associated with a Broadcaster using AddListener(). This method does not send a message to its Listeners if broadcasting is turned off. Broadcasting is turned on using StartBroadcasting(), and can be turned off using StopBroadcasting().
Access:
Prototype:
void BroadcastMessage(MessageT inMessage,Parameters:
void *ioParam = nil);
This method takes the following parameters:
Return:
Remarks:
ioParam parameter depends on the message.
Purpose:
This method tells you whether broadcasting is turned on or not.
Access:
Prototype:
Boolean IsBroadcasting();Parameters:
Return:
A Boolean indicating "true" if broadcasting is turned on, or "false" otherwise.
Purpose:
This method tells a Listener to remove itself from the broadcast list. In response to this, a Listener should update its list of Broadcasters.
Access:
Prototype:
void RemoveListener( LListener *inListener );Parameters:
This method takes the following parameter:
Return:
Purpose:
This method enables broadcasting, by setting the mIsBroadcasting data member to true.
Access:
Prototype:
void StartBroadcasting();Parameters:
Return:
Purpose:
This method disables broadcasting, by setting the mIsBroadcasting data member to false. A Broadcaster that has broadcast turned off does not broadcast messages.
Access:
Prototype:
void StopBroadcasting();Parameters:
Return:
Purpose:
This data member is a list of pointers to LListener objects. In general, you should use the AddListener() and RemoveListener() methods to access this list.
Access:
Prototype:
TArray<LListener*> mListeners;
Purpose:
This data member indicates whether broadcasting is enabled or not. This member should be accessed using the IsBroadcasting() method.
Access:
Prototype:
Boolean mIsBroadcasting;