LibPkg
table.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 //
3 // Copyright 2003-2020 Graham Shaw
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef LIBPKG_TABLE
18 #define LIBPKG_TABLE
19 
20 #include <set>
21 
22 namespace pkg {
23 
29 class table
30 {
31 public:
32  class watcher;
33  friend class watcher;
34 private:
36  std::set<watcher*> _watchers;
37 public:
39  table();
40 
42  virtual ~table();
43 protected:
45  void notify();
46 private:
52  void register_watcher(watcher& w);
53 
58  void deregister_watcher(watcher& w);
59 };
60 
63 {
64 private:
66  std::set<table*> _tables;
67 public:
69  watcher();
70 
72  virtual ~watcher();
73 
77  void watch(table& t);
78 
82  void unwatch(table& t);
83 
87  virtual void handle_change(table& t)=0;
88 };
89 
90 }; /* namespace pkg */
91 
92 #endif
The namespace used to hold the package management library.
Definition: auto_dir.cc:23
A mixin class to allow an object to watch one or more tables.
Definition: table.h:62
table()
Construct table.
Definition: table.cc:21
virtual ~table()
Destroy table.
Definition: table.cc:24
friend class watcher
Definition: table.h:32
void notify()
Notify watchers that a change has occurred.
Definition: table.cc:42
A base class to represent a data table.
Definition: table.h:29

Reference Manual LibPkg Version 0.9.0 (4 Sep 2020)