Observer.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef __OBSERVER_H
00011 #define __OBSERVER_H
00012 
00013 #include <string>
00014 
00015 class Subject;
00016 class Slot;
00017 
00018 /**
00019  *  Base class for objects to receive notification of attachment and
00020  *  detachment.
00021  *
00022  *  If an object needs to be notified when one of its slot methods is attached
00023  *  or detached from a subject, it needs to derive from %Observer and provide
00024  *  implementations of either or both of the attached and detached methods.
00025  *
00026  *  @see        Subject
00027  */
00028 class Observer
00029 {
00030 public:
00031    /**
00032     *  Method to call when a subject is attached to an observer.
00033     *
00034     *  @param   subject
00035     *           The subject being attached to.
00036     *  @param   signal
00037     *           The signal being attached to.
00038     *  @param   slot
00039     *           The slot being attached to.
00040     */
00041    virtual void attached(Subject &subject, const std::string &signal, 
00042       const Slot &slot) { }
00043 
00044    /**
00045     *  Method to call when a subject is detached from an observer.
00046     *
00047     *  @param   subject
00048     *           The subject being detached from.
00049     *  @param   signal
00050     *           The signal being detached from.
00051     *  @param   slot
00052     *           The slot being detached from.
00053     */
00054    virtual void detached(Subject &subject, const std::string &signal, 
00055       const Slot &slot) { }
00056 
00057 protected:
00058    /**
00059     * This should not be deleted directly.  It should be deleted according to
00060     * the instructions provided for the relevant subclass.
00061     */
00062    virtual ~Observer() {}
00063 };
00064 
00065 #endif

Software Development Kit - Opticks 4.9.0 Build 16218