Topic: Additions to the STL : Callback/Observer pair


Author: rmcinnis@gate.net (Robert B McInnis)
Date: 1996/04/05
Raw View
I would like to propose a Callback/Observer construct for the Standard
Template Library.  This could be a base class pair with the Observer
being primarily templates.  This would allow for a consistent
Callback/Observer pattern to be used across applications.  This would
also familiarize people with the pattern and promote different design
decisions when designing an app.

The Callback class should be a simple list of Observers that the owner, or
possibly anyone, depending on access, would be able to invoke or disable.

An Observer should be dynamic enough so that if the receiver instance,
that is attached directly to the Observer instance, were to be deleted,
then the Observer object would know to just disable its node on its
associated Callback list.

This would lead to the concept of Observible destruction of objects.

What about observible construction on a class.  This would allow my class to
know when an instance of itself has been created, then fire off an initialize
VIRTUAL, since this really can't be done in the constructor without EVERY
descendent having to know about the initialize method.

This would eventually allow for observible files on a file system.  Imagine
that!  Biff would be a trivial app (even on DOS) without a polling mechanism.
Or maybe just for version control, to know when certain files have updated on
a LARGE network based development effort.

Just a thought.  If anyone is actually listening, it'd be nice to know what's
thought of this.  Need an example of a callback/observer pair?  Just eMail me.

Thanks for the time,

Rob

---------------------------
Robert McInnis
9th Bit Software
(eMail)  rmcinnis@gate.net
(web  )  http://www.gate.net/~rmcinnis
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]