HyperspaceExplorer 0.7.1
Classes | Public Member Functions | Protected Member Functions | Private Attributes
Subject< Parent > Class Template Reference

An object telling its state changes to all attached Observer s. More...

#include <Observer.h>

Collaboration diagram for Subject< Parent >:
Collaboration graph
[legend]

List of all members.

Classes

struct  Impl

Public Member Functions

virtual void attach (std::shared_ptr< Observer< Parent > > observer)
virtual void detach (std::shared_ptr< Observer< Parent > > observer)

Protected Member Functions

virtual void notify ()

Private Attributes

std::shared_ptr< ImplpImpl_

Detailed Description

template<class Parent>
class Subject< Parent >

An object telling its state changes to all attached Observer s.

An Observer can register itself for updates on the Subject's state change by calling attach() and deregister with detach().

Whenever the implementing Subject wants to update the registered Observer s of its changed state, it must call the notify() method.

This class is meant to be used as a base class for making a Subject out of a arbitrary class, without intrusion to the original class. The final implementation must insert calls to notify() wherever appropriate.

Example:

  class Minx {
    void jinx();
  };

  class MinxSubject: public Subject<Minx> {
    void jinx() {
      Minx::jinx();
      notify();
    }
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:18 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo