00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // Copyright (C) 2003-2010 by the IPLT authors 00006 // 00007 // This library is free software; you can redistribute it and/or modify it under 00008 // the terms of the GNU Lesser General Public License as published by the Free 00009 // Software Foundation; either version 3.0 of the License, or (at your option) 00010 // any later version. 00011 // This library is distributed in the hope that it will be useful, but WITHOUT 00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00014 // details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this library; if not, write to the Free Software Foundation, Inc., 00018 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 //------------------------------------------------------------------------------ 00020 00021 /* 00022 observable concept 00023 00024 Author: Ansgar Philippsen 00025 */ 00026 00027 #ifndef IMG_OBSERVABLE_H 00028 #define IMG_OBSERVABLE_H 00029 00030 #include <list> 00031 #include "extent.hh" 00032 00033 namespace ost { namespace img { 00034 00035 // fw decl 00036 class DataObserver; 00037 00039 /* 00040 manages a list of observers, which must 00041 offer the methods ObserverRelease, ObserverInvalidate 00042 and ObserverUpdate 00043 */ 00044 class DLLEXPORT Observable { 00045 typedef std::list<DataObserver *> ObserverList; 00046 typedef ObserverList::iterator ObserverIter; 00047 typedef ObserverList::const_iterator ObserverConstIter; 00048 public: 00049 Observable() ; 00050 /* 00051 copy logic: the observers are not copied 00052 */ 00053 Observable(const Observable& o) ; 00054 00055 ~Observable() ; 00056 00057 /* 00058 assignement logic: the observers are not copied 00059 */ 00060 Observable& operator=(const Observable& o) ; 00061 00062 void Attach(DataObserver* d) ; 00063 00064 void Detach(DataObserver* o) ; 00065 00066 void Notify() const ; 00067 void Notify(const Extent& e) const ; 00068 void Notify(const Point& p) const ; 00069 int GetListSize() const ; 00070 00071 long MemSize() const ; 00072 00073 private: 00074 ObserverList list_; 00075 }; 00076 00077 00078 }} // namespace 00079 00080 #endif