Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

IObserver.h

Go to the documentation of this file.
00001 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
00002 /*
00003  * Copyright (C) 2005 Dell Inc.
00004  *  by Michael Brown <Michael_E_Brown@dell.com>
00005  * Licensed under the Open Software License version 2.1 
00006  * 
00007  * Alternatively, you can redistribute it and/or modify 
00008  * it under the terms of the GNU General Public License as published 
00009  * by the Free Software Foundation; either version 2 of the License, 
00010  * or (at your option) any later version.
00011 
00012  * This program is distributed in the hope that it will be useful, but 
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of 
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
00015  * See the GNU General Public License for more details.
00016  */
00017 
00018 
00019 #ifndef IOBSERVER_H
00020 #define IOBSERVER_H
00021 
00022 // compat header should always be first header
00023 #include "smbios/compat.h"
00024 
00025 #include <list>
00026 
00027 // abi_prefix should be last header included before declarations
00028 #include "smbios/config/abi_prefix.hpp"
00029 
00030 namespace observer
00031 {
00032     // forward declarations
00033     class IObservable;
00034 
00035     class IObserver
00036     {
00037     public:
00038         virtual ~IObserver();
00039         virtual void update( const IObservable *whatChanged, void *param = 0 ) = 0;
00040     protected:
00041         IObserver();
00042     };
00043 
00044     class IObservable
00045     {
00046     public:
00047         virtual ~IObservable();
00048 
00049         virtual void attach( IObserver * ) const;
00050         virtual void detach( IObserver * ) const;
00051         virtual void notify( void *param = 0 ) const;
00052     protected:
00053         IObservable();
00054 
00055     private:
00056         mutable std::list<IObserver *> observers;
00057     };
00058 
00059 }
00060 
00061 // always should be last thing in header file
00062 #include "smbios/config/abi_suffix.hpp"
00063 
00064 #endif /* IOBSERVER_H */

Generated on Wed Apr 11 16:25:10 2007 for SMBIOS Library by doxygen 1.3.5