code::ActionSource Class Reference

Inheritance diagram for code::ActionSource:

code::AlgorithmControl code::FileChangeNotifier code::IndexBase code::LBActionSource code::ControlLB code::Index code::InMemoryIndex code::SQLIndex code::FAMIndex code::WebIndex code::XMLIndex code::XMLLBIndex code::PostgreSQLIndex List of all members.

Detailed Description

Base class which can be subclassed to make objects that can be observed.

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.

Author:
Charles Kerr, Lakshman
Version:
:
Id
code_ActionEvent.h,v 1.14 2009/12/10 20:08:39 lakshman Exp
See also:
ActionEvent

ActionListener

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.


Constructor & Destructor Documentation

virtual code::ActionSource::~ActionSource (  )  [inline, virtual]

On destruction of the ActionSource, all registered listeners are discarded.


Member Function Documentation

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Returns:
a source-specific type identifier to indicate what action occurred.

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 )

Parameters:
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.

Parameters:
lstnr the action listener to be unsubscribed.


Generated on Fri May 4 13:40:12 2012 for WDSS-IIw2 by  doxygen 1.4.7