OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
observable.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 /*
22  observable concept
23 
24  Author: Ansgar Philippsen
25 */
26 
27 #ifndef IMG_OBSERVABLE_H
28 #define IMG_OBSERVABLE_H
29 
30 #include <list>
31 #include "extent.hh"
32 
33 namespace ost { namespace img {
34 
35 // fw decl
36 class DataObserver;
37 
39 /*
40  manages a list of observers, which must
41  offer the methods ObserverRelease, ObserverInvalidate
42  and ObserverUpdate
43 */
44 class DLLEXPORT Observable {
45  typedef std::list<DataObserver *> ObserverList;
46  typedef ObserverList::iterator ObserverIter;
47  typedef ObserverList::const_iterator ObserverConstIter;
48 public:
49  Observable() ;
50  /*
51  copy logic: the observers are not copied
52  */
53  Observable(const Observable& o) ;
54 
55  ~Observable() ;
56 
57  /*
58  assignement logic: the observers are not copied
59  */
60  Observable& operator=(const Observable& o) ;
61 
62  void Attach(DataObserver* d) ;
63 
64  void Detach(DataObserver* o) ;
65 
66  void Notify() const ;
67  void Notify(const Extent& e) const ;
68  void Notify(const Point& p) const ;
69  int GetListSize() const ;
70 
71  long MemSize() const ;
72 
73  private:
74  ObserverList list_;
75 };
76 
77 
78 }} // namespace
79 
80 #endif
templated observable class
Definition: observable.hh:44
Defines lower and upper valid indices.
Definition: extent.hh:60
Abstract base class of data observer.
class encapsulating 1D to 3D point
Definition: point.hh:43