solarpowerlog trunk
/home/tobi/workspace/solarpowerlog/src/patterns/IObserverSubject.h
Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  solarpowerlog
00003  Copyright (C) 2009  Tobias Frost
00004 
00005  This file is part of solarpowerlog.
00006 
00007  Solarpowerlog is free software; However, it is dual-licenced
00008  as described in the file "COPYING".
00009 
00010  For this file (IObserverSubject.h), the license terms are:
00011 
00012  You can redistribute it and/or  modify it under the terms of the GNU Lesser
00013  General Public License (LGPL) as published by the Free Software Foundation;
00014  either version 3 of the License, or (at your option) any later version.
00015 
00016  This program is distributed in the hope that it will be useful, but
00017  WITHOUT ANY WARRANTY; without even the implied warranty of
00018  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  Lesser General Public License for more details.
00020 
00021  You should have received a copy of the GNU Library General Public
00022  License along with this proramm; if not, see
00023  <http://www.gnu.org/licenses/>.
00024  ----------------------------------------------------------------------------
00025  */
00026 
00033 #ifndef OBSERVERSUBJECT_H_
00034 #define OBSERVERSUBJECT_H_
00035 
00036 #ifdef HAVE_CONFIG_H
00037 #include "config.h"
00038 #endif
00039 
00040 #include <list>
00041 
00042 using namespace std;
00043 
00044 class IObserverObserver;
00045 
00051 class IObserverSubject
00052 {
00053 public:
00054 
00055      virtual ~IObserverSubject();
00056 
00057      virtual void Subscribe( class IObserverObserver* observer );
00058 
00059      virtual void UnSubscribe( class IObserverObserver* observer );
00060 
00061      virtual void SetSubscription( class IObserverObserver* observer,
00062           bool subscribe = true );
00063 
00064      virtual bool CheckSubscription( class IObserverObserver *observer );
00065 
00066      virtual void Notify( void );
00067 
00068      virtual unsigned int GetNumSubscribers( void );
00069 
00070 protected:
00071      IObserverSubject();
00072 
00073 private:
00074      std::list<IObserverObserver*> listobservers;
00075 
00076 };
00077 
00078 #endif /* OBSERVERSUBJECT_H_ */
00079 
00080 /*
00081  Infos on pattern
00082  See:
00083  http://www.cs.clemson.edu/~malloy/courses/patterns/observerCo.html
00084  */