LibPkg
table.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 // Copyright © 2003-2005 Graham Shaw.
3 // Distribution and use are subject to the GNU Lesser General Public License,
4 // a copy of which may be found in the file !LibPkg.Copyright.
5 
6 #ifndef LIBPKG_TABLE
7 #define LIBPKG_TABLE
8 
9 #include <set>
10 
11 namespace pkg {
12 
18 class table
19 {
20 public:
21  class watcher;
22  friend class watcher;
23 private:
25  std::set<watcher*> _watchers;
26 public:
28  table();
29 
31  virtual ~table();
32 protected:
34  void notify();
35 private:
41  void register_watcher(watcher& w);
42 
47  void deregister_watcher(watcher& w);
48 };
49 
52 {
53 private:
55  std::set<table*> _tables;
56 public:
58  watcher();
59 
61  virtual ~watcher();
62 
66  void watch(table& t);
67 
71  void unwatch(table& t);
72 
76  virtual void handle_change(table& t)=0;
77 };
78 
79 }; /* namespace pkg */
80 
81 #endif
A mixin class to allow an object to watch one or more tables.
Definition: table.h:51
void unwatch(table &t)
Cease watching table.
Definition: table.cc:58
table()
Construct table.
Definition: table.cc:10
virtual ~table()
Destroy table.
Definition: table.cc:13
virtual ~watcher()
Destroy watcher.
Definition: table.cc:43
void notify()
Notify watchers that a change has occurred.
Definition: table.cc:31
virtual void handle_change(table &t)=0
Handle change to table.
void watch(table &t)
Begin watching table.
Definition: table.cc:52
watcher()
Construct watcher.
Definition: table.cc:40
A base class to represent a data table.
Definition: table.h:18

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)