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

main_obs.H

Go to the documentation of this file.
00001 /*
00002  * Copyright 2001, Brown University, Providence, RI.
00003  * 
00004  *                         All Rights Reserved
00005  * 
00006  * Permission to use, copy, modify, and distribute this software and its
00007  * documentation for any purpose other than its incorporation into a
00008  * commercial product is hereby granted without fee, provided that the
00009  * above copyright notice appear in all copies and that both that
00010  * copyright notice and this permission notice appear in supporting
00011  * documentation, and that the name of Brown University not be used in
00012  * advertising or publicity pertaining to distribution of the software
00013  * without specific, written prior permission.
00014  * 
00015  * BROWN UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
00016  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY
00017  * PARTICULAR PURPOSE.  IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE FOR
00018  * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00019  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00020  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00021  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00022  */
00023 #ifndef MAIN_OBS_H
00024 #define MAIN_OBS_H
00025 
00026 #include "std/list.H"
00027 
00028 class MAINobs {
00029    public :
00030       class data {
00031          public :
00032          data() { }
00033       };
00034    virtual void notify(const data &) = 0;
00035 };
00036 
00037 class MAIN_observers : public OBSlist<MAINobs> {
00038      int _main_has_run;
00039 
00040    public:
00041      MAIN_observers():_main_has_run(0) { }
00042 
00043      int has_main_run() { return _main_has_run; }
00044  
00045      void obs(MAINobs *o) { if (_main_has_run)
00046                               o->notify(MAINobs::data());
00047                             else OBSlist<MAINobs>::obs(o); 
00048                           }
00049 
00050      void notify()        { _main_has_run = 1;  
00051                             OBSlist<MAINobs>::notify(MAINobs::data()); }
00052 };
00053 
00054 extern DllImpExp MAIN_observers &MAINobservers();
00055 
00056 #endif

Generated on Mon Sep 15 16:25:56 2003 for gluebase by doxygen1.2.18