Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

watchble.cpp

Go to the documentation of this file.
00001 // $Id$
00002 
00003 //**********************************************************************
00004 //                                                                     *
00005 //    Description:   Watchable object base class.                      *
00006 //                                                                     *
00007 //    Author:        Chris White (whitecf@bcs.org.uk)                  *
00008 //                                                                     *
00009 //    Copyright (C) 2003  Monitor Computing Services Ltd.              *
00010 //                                                                     *
00011 //    This program is free software; you can redistribute it and/or    *
00012 //    modify it under the terms of the GNU General Public License      *
00013 //    as published by the Free Software Foundation; either version 2   *
00014 //    of the License, or any later version.                            *
00015 //                                                                     *
00016 //    This program is distributed in the hope that it will be useful,  *
00017 //    but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00018 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00019 //    GNU General Public License for more details.                     *
00020 //                                                                     *
00021 //    You should have received a copy of the GNU General Public        *
00022 //    License (http://www.gnu.org/copyleft/gpl.html) along with this   *
00023 //    program; if not, write to:                                       *
00024 //       The Free Software Foundation Inc.,                            *
00025 //       59 Temple Place - Suite 330,                                  *
00026 //       Boston, MA  02111-1307,                                       *
00027 //       USA.                                                          *
00028 //                                                                     *
00029 //**********************************************************************
00030 //                                                                     *
00031 //    Notes:                                                           *
00032 //                                                                     *
00033 //**********************************************************************
00034 
00035 
00036 
00037 #include <cllbklst.h>
00038 #include <mytrace.h>
00039 
00040 #include "watchble.h"
00041 
00042 
00043 using namespace Monitor::Utility;
00044 
00045 
00046 
00047 Watchable::Watchable()
00048     :
00049     watchList(new CallbackList()),
00050     frozen(0)
00051 {
00052     _USEMYTRACE_("Watchable::Watchable()")
00053 }
00054 
00055 
00056 
00057 Watchable::~Watchable()
00058 {
00059     _USEMYTRACE_("Watchable::~Watchable()")
00060 
00061 
00062     delete watchList, watchList = 0;
00063 }
00064 
00065 
00066 
00067 const CallbackBase&
00068 Watchable::addWatch(const CallbackBase&    newWatch) const
00069 {
00070     _USEMYTRACE_("Watchable::addWatch(newWatch)")
00071 
00072 
00073     watchList->addCallback(newWatch);
00074 
00075     return newWatch;
00076 }
00077 
00078 
00079 
00080 void
00081 Watchable::removeWatch(const CallbackBase&    oldWatch) const
00082 {
00083     _USEMYTRACE_("Watchable::removeWatch(oldWatch)")
00084 
00085 
00086     watchList->removeCallback(oldWatch);
00087 }
00088 
00089 
00090 
00091 void
00092 Watchable::removeWatcher(const void*    watcher) const
00093 {
00094     _USEMYTRACE_("Watchable::removeWatcher(watcher)")
00095 
00096 
00097     watchList->removeTarget(watcher);
00098 }
00099 
00100 
00101 
00102 void
00103 Watchable::updated(const void    *updateData) const
00104 {
00105     _USEMYTRACE_("Watchable::updated(updateData)")
00106 
00107 
00108     if (!frozen)
00109     {
00110         watchList->invoke(updateData);
00111     }
00112 }
00113 
00114 
00115 
00116 void
00117 Watchable::freeze() const
00118 {
00119     _USEMYTRACE_("Watchable::freeze()")
00120 
00121 
00122     frozen = !0;
00123 }
00124 
00125 
00126 
00127 void
00128 Watchable::thaw() const
00129 {
00130     _USEMYTRACE_("Watchable::thaw()")
00131 
00132 
00133     frozen = 0;
00134 }

Generated on Wed Oct 29 21:30:11 2003 for Utility C++ by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002