LibPkg
status_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_STATUS_TABLE
7 #define LIBPKG_STATUS_TABLE
8 
9 #include <map>
10 #include <string>
11 
12 #include "libpkg/status.h"
13 #include "libpkg/table.h"
14 
15 namespace pkg {
16 
17 using std::string;
18 
21  public table
22 {
23 public:
24  typedef string key_type;
26  typedef std::map<key_type,mapped_type>::const_iterator const_iterator;
27  class commit_error;
28 private:
31  string _pathname;
32 
34  std::map<key_type,mapped_type> _data;
35 public:
39  status_table(const string& pathname=string());
40 
42  virtual ~status_table();
43 
49  const mapped_type& operator[](const key_type& key) const;
50 
54  const_iterator begin() const
55  { return _data.begin(); }
56 
60  const_iterator end() const
61  { return _data.end(); }
62 
67  const_iterator find(const key_type& key) const;
68 
75  void insert(const key_type& key,const mapped_type& value);
76 
80  void insert(const status_table& table);
81 
83  void clear();
84 
89  void commit();
90 
95  void rollback();
96 private:
101  bool read(const string& pathname);
102 };
103 
106  public std::runtime_error
107 {
108 public:
110  commit_error();
111 };
112 
113 }; /* namespace pkg */
114 
115 #endif
void insert(const key_type &key, const mapped_type &value)
Set status of package.
Definition: status_table.cc:36
const_iterator begin() const
Get const iterator for start of table.
Definition: status_table.h:54
status mapped_type
Definition: status_table.h:25
virtual ~status_table()
Destroy status table.
Definition: status_table.cc:20
status_table(const string &pathname=string())
Construct status table.
Definition: status_table.cc:14
The namespace used to hold the package management library.
Definition: auto_dir.cc:12
const mapped_type & operator[](const key_type &key) const
Get status of package.
Definition: status_table.cc:24
std::map< key_type, mapped_type >::const_iterator const_iterator
Definition: status_table.h:26
A class to represent the current or required status of a package.
Definition: status.h:33
void commit()
Commit changes.
Definition: status_table.cc:57
const_iterator end() const
Get const iterator for end of table.
Definition: status_table.h:60
An exception class for reporting failure to commit table.
Definition: status_table.h:105
string key_type
Definition: status_table.h:24
void clear()
Clear status of all packages.
Definition: status_table.cc:51
A class for mapping package name to package status.
Definition: status_table.h:20
void rollback()
Roll back changes.
Definition: status_table.cc:99
const_iterator find(const key_type &key) const
Find const iterator for package.
Definition: status_table.cc:31
A base class to represent a data table.
Definition: table.h:18

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)