LibPkg
component_update.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 // Copyright © 2013 Alan Buckley.
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_COMPONENT_UPDATE
7 #define LIBPKG_COMPONENT_UPDATE
8 
9 #include <vector>
10 #include <string>
11 
12 #include "libpkg/component.h"
13 
14 namespace pkg {
15 
16 using std::string;
17 
20 {
21 public:
22  typedef std::vector<component>::const_iterator const_iterator;
23  class commit_error;
24 private:
27  string _pathname;
28 
30  std::vector<component> _data;
31 public:
36  component_update(const string& pathname=string());
37 
39  virtual ~component_update();
40 
46  const component& operator[](const std::string &name) const;
47 
52  { return _data.begin(); }
53 
58  { return _data.end(); }
59 
64  const_iterator find(const std::string& name) const;
65 
71  void insert(const component& value);
72 
74  void insert(const component_update& table);
75 
76 
78  void clear();
79 
84  void commit();
85 
90  void rollback();
91 
93  void done();
94 private:
99  bool read(const string& pathname);
100 };
101 
104  public std::runtime_error
105 {
106 public:
108  commit_error();
109 };
110 
111 }; /* namespace pkg */
112 
113 #endif
const_iterator end() const
Get const iterator for end of the updates.
Definition: component_update.h:57
char * _data
Definition: zipfile.cc:68
virtual ~component_update()
Destroy component update.
Definition: component_update.cc:19
A class for managing the updating of package components.
Definition: component_update.h:19
void clear()
Clear status of all components.
Definition: component_update.cc:63
component_update(const string &pathname=string())
Construct component update.
Definition: component_update.cc:13
const component & operator[](const std::string &name) const
Get component details for a component name The updates cannot be modified using this operator...
Definition: component_update.cc:22
A class to represent a component of a package.
Definition: component.h:27
void rollback()
Roll back changes.
Definition: component_update.cc:108
An exception class for reporting failure to commit table.
Definition: component_update.h:103
commit_error()
Construct commit error.
Definition: component_update.cc:155
const_iterator begin() const
Get const iterator for start of the updates.
Definition: component_update.h:51
const_iterator find(const std::string &name) const
Find const iterator for a component name.
Definition: component_update.cc:32
void done()
The updates have been completed, so remove the file.
Definition: component_update.cc:119
void commit()
Commit changes.
Definition: component_update.cc:68
A base class to represent a data table.
Definition: table.h:18
std::vector< component >::const_iterator const_iterator
Definition: component_update.h:22
void insert(const component &value)
Add a component.
Definition: component_update.cc:42

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)