Inheritance diagram for code::ActionSource:
An ActionSource object can have more than one observer. An observer may be any object that subclasses from the abstract base class ActionListener. After an ActionSource instance changes, the ActionSource calls its fireActionEvent method, which causes all of its observers to be notified of the change by a call to their actionPerformed method.
Like Dialog/DialogListener and ListModel/ListListener, this is another instance of the "Observer/Observable" pattern, discussed in "Design Patterns: Elements of Reusable Object-Oriented Software" (Gamma, Helm, Johnson, Vlissides, 1995).
Note that the order in which ActionListeners will be invoked is not defined. If this is important to you, see MultipleListeners.
Public Member Functions | |
void | copyListenersFrom (const ActionSource &other) |
copy all the listeners from the other source (replacing our own) | |
virtual | ~ActionSource () |
On destruction of the ActionSource, all registered listeners are discarded. | |
size_t | getNumListeners () const |
returns the number of listeners linked to this source. | |
std::string | getDir () |
Returns a source-specific disk directory. | |
void | addActionListener (SmartPtr< ActionListener > lstnr) |
Subscribe lstnr such that it receives all events from this ActionSource. | |
void | addActionListener (const std::string &event_type, SmartPtr< ActionListener > lstnr) |
Subscribe lstnr such that it receives only this event type from this ActionSource. | |
void | removeActionListener (SmartPtr< ActionListener > lstner) |
Unsubscribe lstnr such that it no longer receives events from this ActionSource. | |
void | removeActionListener (const std::string &eventType, SmartPtr< ActionListener > lstner) |
Unsubscribe the listener so that it does not respond to the the event type noted. | |
void | fireActionPerformed (const ActionEvent &e) |
Convenience function for subclasses to notify ActionListeners of events. | |
void | fireActionPerformed (const ActionEvent *e) |
Convenience function for subclasses to notify ActionListeners of events. | |
void | fireActionPerformed (const std::string &type) |
Convenience function for subclasses to notify ActionListeners of events. | |
Classes | |
struct | ListenerHandle |
Listener Handle holds an ActionListener and makes < comparisions based on the pointer address possible. |
virtual code::ActionSource::~ActionSource | ( | ) | [inline, virtual] |
On destruction of the ActionSource, all registered listeners are discarded.
void code::ActionSource::addActionListener | ( | const std::string & | event_type, | |
SmartPtr< ActionListener > | lstnr | |||
) | [inline] |
Subscribe lstnr such that it receives only this event type from this ActionSource.
evt_type | the event type we are subscribing to | |
lstnr | the action listener to be subscribed. |
void code::ActionSource::addActionListener | ( | SmartPtr< ActionListener > | lstnr | ) | [inline] |
Subscribe lstnr such that it receives all events from this ActionSource.
l | the action listener to be subscribed. |
void code::ActionSource::copyListenersFrom | ( | const ActionSource & | other | ) | [inline] |
copy all the listeners from the other source (replacing our own)
void code::ActionSource::fireActionPerformed | ( | const std::string & | type | ) | [inline] |
Convenience function for subclasses to notify ActionListeners of events.
type | the type of the ActionEvent to be passed along to the action listeners. |
void code::ActionSource::fireActionPerformed | ( | const ActionEvent * | e | ) | [inline] |
Convenience function for subclasses to notify ActionListeners of events.
actionEvent | the event to be passed along to the action listeners. |
void code::ActionSource::fireActionPerformed | ( | const ActionEvent & | e | ) | [inline] |
Convenience function for subclasses to notify ActionListeners of events.
actionEvent | the event to be passed along to the action listeners. |
std::string code::ActionSource::getDir | ( | ) | [inline] |
Returns a source-specific disk directory.
Default implementation does nothing --- this should be overridden.
size_t code::ActionSource::getNumListeners | ( | ) | const [inline] |
returns the number of listeners linked to this source.
void code::ActionSource::removeActionListener | ( | const std::string & | eventType, | |
SmartPtr< ActionListener > | lstner | |||
) | [inline] |
Unsubscribe the listener so that it does not respond to the the event type noted.
This works only if the listener was added via addActionListener( type, SmartPtr )
type | The event type | |
lstnr | The listener to remove |
void code::ActionSource::removeActionListener | ( | SmartPtr< ActionListener > | lstner | ) | [inline] |
Unsubscribe lstnr such that it no longer receives events from this ActionSource.
lstnr | the action listener to be unsubscribed. |