Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Observable Class Reference

Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns text book and the Java Observable class. More...

#include <Observable.h>

Inheritance diagram for Observable:
Inheritance graph
[legend]
Collaboration diagram for Observable:
Collaboration graph
[legend]

Public Types

typedef void(Observer::* Action )(const Observable *)
 The member function of the Observer that is called.
typedef std::list< Observer * > ObserverList_t
 The type of STL container to maintain list of Observer objects.

Public Member Functions

void addObserver (Observer *)
 Adds an Observer to the Observer list.
const ObserverList_tgetObservers () const
 Returns the list of observers.
virtual void notifyObservers () const
 Notifies Observer objects of a change.
 Observable ()
 The default constructor.
void removeObserver (Observer *)
 Removes an Observer from the Observer list.
virtual ~Observable ()
 The destructor.

Protected Member Functions

void notifyObservers (Action action) const
 An internal method to iterate over all observers and to send the message action.

Private Attributes

ObserverList_t m_list
 The list of objects observing this Observable.

Detailed Description

Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns text book and the Java Observable class.

Todo:
We don't have a copy constructor. Determine if that a problem?
Author
Paul F. Kunz Paul_.nosp@m.Kunz.nosp@m.@slac.nosp@m..sta.nosp@m.nford.nosp@m..edu

Definition at line 39 of file Observable.h.

Member Typedef Documentation

typedef void( Observer::* Action)(const Observable *)

The member function of the Observer that is called.

Definition at line 86 of file Observable.h.

typedef std::list< Observer * > ObserverList_t

The type of STL container to maintain list of Observer objects.

Definition at line 45 of file Observable.h.

Constructor & Destructor Documentation

The default constructor.

Definition at line 39 of file Observable.cxx.

~Observable ( )
virtual

The destructor.

Does nothing but keep compiler warning messages away.

Note
needs to be public because of SIP.

Definition at line 45 of file Observable.cxx.

Member Function Documentation

void addObserver ( hippodraw::Observer observer)
const Observable::ObserverList_t & getObservers ( ) const

Returns the list of observers.

Definition at line 60 of file Observable.cxx.

void notifyObservers ( ) const
virtual

Notifies Observer objects of a change.

If interval counting is disabled, then Observer::Update is sent immediately. If interval counting is enabled, then the current count is incremented. If the current count is equal to the interval count, then the Observer::update message is sent and the current count reset to 0.

Reimplemented in NTuple, RootNTuple, NumArrayTuple, ListTuple, and FitsNTuple.

Definition at line 93 of file Observable.cxx.

References Observer::update().

Referenced by XyPlotter::addDataRep(), XyPlotter::addDataRepStacked(), FunctionController::addFunctionRep(), StHist1DProjector::addValues(), StHist2DProjector::addValues(), XyPlotter::autoScale(), Inspector::contourLevelsTextBox_returnPressed(), Inspector::contourSlider_valueChanged(), Inspector::contourTextBox_returnPressed(), FunctionRep::fitFunction(), XyPlotter::removeDataRep(), FunctionRep::restoreParameters(), DataRep::set(), CutPlotter::setActive(), PlotterBase::setAspectRatio(), XyPlotter::setAutoRanging(), XyPlotter::setBoxEdge(), QtDisplay::setContourLevels(), CutPlotter::setCutColor(), XyPlotter::setCutEnabled(), XyPlotter::setCutInverted(), XyPlotter::setCutRangeAt(), ProjectorBase::setDirty(), DataRep::setErrorDisplay(), XyPlotter::setHighRange(), PlotterBase::setLabel(), XyPlotter::setLabel(), DataSource::setLabelAt(), DataSource::setLabels(), XyPlotter::setLowRange(), DataSource::setName(), DisplayController::setNTuple(), FunctionRep::setParameters(), DyHistogram::setPointRep(), DyHistogramEqualEntries::setPointRep(), DataRep::setPointRep(), TextPlotter::setRepColor(), DataRep::setRepColor(), DataRep::setRepSize(), DataRep::setRepStyle(), XyPlotter::setReverse(), XyPlotter::setScaling(), XyPlotter::setShowGrid(), DataSource::setTitle(), PlotterBase::setTitle(), XyPlotter::setTransform(), XyPlotter::setValueRep(), NTupleProjector::update(), BinningProjector::update(), DataRep::update(), PlotterBase::update(), CutPlotter::update(), CutPlotter::updateTargets(), DataRep::~DataRep(), DataSource::~DataSource(), PlotterBase::~PlotterBase(), and RTuple::~RTuple().

void notifyObservers ( Action  action) const
protected

An internal method to iterate over all observers and to send the message action.

Definition at line 72 of file Observable.cxx.

void removeObserver ( hippodraw::Observer observer)

Member Data Documentation

ObserverList_t m_list
private

The list of objects observing this Observable.

Definition at line 51 of file Observable.h.


The documentation for this class was generated from the following files:

Generated for HippoDraw Class Library by doxygen