Notice.h

Classes

Notice -- abstract base class for notices (full description)
NoticeSource -- base class for notice originators (full description)
NoticeTarget -- abstract base class for notice receptors (full description)

class Notice

Interface

Public Members
Notice()
virtual ~Notice()
virtual uInt type() const = 0
virtual int operator==(const Notice &) const = 0

Description

Review Status

Reviewed By:
Friso Olnon
Date Reviewed:
1995/03/16

Synopsis

A Notice is the piece of information passed around between a NoticeSource and a NoticeTarget. This abstract base class is only a skeleton intended to be derived from. It does not contain any relevant information -- that must be added by the derived classes --, but it enforces derived classes to implement the comparison operator == and the function type().

Example

ListNotice, derived from Notice, is the notification which is passed between List and ListIter to keep cursors and container in sync.

Member Description

Notice()

virtual ~Notice()

virtual uInt type() const = 0

Return the identification number of the Notice type.

virtual int operator==(const Notice &) const = 0

Compare two Notices.


class NoticeSource

Interface

NoticeSource() : curIters(0)
virtual ~NoticeSource()
void notify(const Notice & note)
Private Members
Link<NoticeTarget*> *&head()

Description

Review Status

Reviewed By:
Friso Olnon
Date Reviewed:
1995/03/16

Synopsis

A NoticeSource maintains a list of all of the NoticeTargets which are interested in Notices from this NoticeSource. Its member function notify() sends the specified Notice to all the NoticeTargets in the list.

Classes which have many other dependent objects which need to be updated, should derive from this class.

Example

List, the linked list class, is derived from NoticeSource. It mainly contains status information; all the manipulation functions are located in the ListIter classes. The linked list and its iterators communicate with each other via the notice system. List does not provide any further notice functionality; everything is taken care of by its base class NoticeSource.

Member Description

NoticeSource() : curIters(0)

virtual ~NoticeSource()

void notify(const Notice & note)

Sends the note to all NoticeTargets in the target list.

Link<NoticeTarget*> *&head()


class NoticeTarget

Interface

Public Members
virtual ~NoticeTarget()
Bool isValid() const
Bool isAttached() const
void invalidate()
virtual void notify(const Notice &) = 0
Protected Members
NoticeTarget() : ilink(0), container(0), valid(False)
NoticeTarget(NoticeSource *v) : ilink(0), container(0), valid(False)
NoticeTarget(NoticeSource &v) : ilink(0),container(0), valid(False)
NoticeTarget(NoticeTarget &other) : ilink(0), container(0), valid(False)
NoticeTarget(NoticeTarget *other) : ilink(0), container(0), valid(False)
void unlink()
void link(const NoticeTarget &other)
void link(const NoticeTarget *other)
Link<NoticeTarget*> *next()
const Link<NoticeTarget*> *next() const
void attach(NoticeSource *v)
void attach(NoticeSource &v)

Description

Review Status

Reviewed By:
Friso Olnon
Date Reviewed:
1995/03/16

Synopsis

A NoticeTarget receives the Notices from the NoticeSource to which it is linked. A target can only be linked to one source.

Classes which are dependent upon a particular NoticeSource should derive from this class.

Example

ListIter and its parent class ConstListIter are the iterators or "dynamic" cursors in the linked List. They are derived from NoticeTarget, and the notice system ensures that multiple cursors are updated as elements are added and removed from the list, according to the following scheme:
  1. An iterator changes something to the underlying list.
  2. The iterator creates a ListNotice containing all the necessary information about the change.
  3. The iterator passes the notice to the NoticeSource List.
  4. The list relays the notice to all other iterators operating on the list (kept in the "target list").
  5. Every iterator catches the notice and changes its state accordingly.

Member Description

virtual ~NoticeTarget()

Destructs this NoticeTarget.

Bool isValid() const

Returns a boolean value telling whether this NoticeTarget is still "valid".

Bool isAttached() const

Returns a boolean value telling whether this NoticeTarget is still attached to a NoticeSource or not.

void invalidate()

Makes the current NoticeTarget "invalid".

virtual void notify(const Notice &) = 0

Hook through which NoticeTargets are notified (by NoticeSources).

NoticeTarget() : ilink(0), container(0), valid(False)

Creates an unlinked, "invalid" NoticeTarget. An invalid NoticeTarget does not occur in the target list of any NoticeSource.

NoticeTarget(NoticeSource *v) : ilink(0), container(0), valid(False)
NoticeTarget(NoticeSource &v) : ilink(0),container(0), valid(False)

Creates a "valid" NoticeTarget linked to the specified NoticeSource. The NoticeTarget will be added to the target list in that NoticeSource.

NoticeTarget(NoticeTarget &other) : ilink(0), container(0), valid(False)
NoticeTarget(NoticeTarget *other) : ilink(0), container(0), valid(False)

Creates a "valid" NoticeTarget linked to the same NoticeSource as the other NoticeTarget. So, both NoticeTargets will occur in the same target list.

void unlink()

Unlinks this NoticeTarget from its NoticeSource. The NoticeTarget will be removed from the target list.

void link(const NoticeTarget &other)
void link(const NoticeTarget *other)

Links this NoticeTarget to the same NoticeSource as the other NoticeTarget. Any previous link will be undone.

Link<NoticeTarget*> *next()
const Link<NoticeTarget*> *next() const

Retrieves the next NoticeTarget in the target list of the associated NoticeSource.

void attach(NoticeSource *v)
void attach(NoticeSource &v)

Adds this NoticeTarget to the target list in the specified NoticeSource, so that it will receive all notices sent out by that NoticeSource.