LibPkg
commit.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_COMMIT
7 #define LIBPKG_COMMIT
8 
9 #include "libpkg/thread.h"
10 #include "libpkg/log.h"
11 
12 namespace pkg {
13 
14 class control_binary;
15 class pkgbase;
16 class download;
17 class unpack;
18 
20 class commit:
21  public thread
22 {
23 public:
25  typedef unsigned long long size_type;
26 
28  static const size_type npos=static_cast<size_type>(-1);
29 
30  // An enumeration for describing the state of the commit operation. */
32  {
62  };
63 private:
65  pkgbase& _pb;
66 
68  state_type _state;
69 
71  std::set<string> _packages_to_process;
72 
74  std::set<string> _packages_to_download;
75 
79  std::set<string> _packages_to_unpack;
80 
84  std::set<string> _packages_to_configure;
85 
89  std::set<string> _packages_to_purge;
90 
92  std::set<string> _components_to_remove;
93 
95  std::set<string> _files_to_boot;
97  std::set<string> _files_to_run;
99  std::set<string> _files_to_add_to_apps;
100 
102  string _pkgname;
103 
105  download* _dload;
106 
108  unpack* _upack;
109 
111  size_type _files_done;
112 
114  size_type _files_total;
115 
117  size_type _bytes_done;
118 
120  size_type _bytes_total;
121 
124  string _message;
125 
126  struct progress;
127 
129  std::map<string,progress> _progress_table;
130 
133  std::set<string> _files_that_conflict;
134 
136  log *_log;
137 
139  log *_warnings;
140 
141 public:
146  commit(pkgbase& pb,const std::set<string>& packages);
147 
149  virtual ~commit();
150 
155  { return _state; }
156 
161  { return _files_done; }
162 
167  { return _files_total; }
168 
173  { return _bytes_done; }
174 
179  { return _bytes_total; }
180 
186  string message() const
187  { return _message; }
188 
195  const std::set<string>& files_that_conflict() const
196  { return _files_that_conflict; }
197 
201  void log_to(log *use_log);
202 
206  log *warnings() const {return _warnings;}
213  log *detach_warnings() {log *w = _warnings; _warnings = 0; return w;}
214 
215 protected:
216  virtual void poll();
217 private:
222  void update_download_progress();
223 
230  void warning(LogCode code, const std::string &item, const std::string &what);
231 };
232 
235 {
246  progress();
247 };
248 
249 }; /* namespace pkg */
250 
251 #endif
The state in which the sprite pool is updated.
Definition: commit.h:48
size_type files_total() const
Get total number of files to process.
Definition: commit.h:166
The state in which packages are being purged.
Definition: commit.h:44
The state in which packages are being downloaded.
Definition: commit.h:38
The state in which all operations have been successfully completed.
Definition: commit.h:59
size_type bytes_total() const
Get total number of bytes to process.
Definition: commit.h:178
void log_to(log *use_log)
Set the log to add to.
Definition: commit.cc:653
virtual void poll()
Poll this thread.
Definition: commit.cc:56
The state in which packages are being unpacked or removed.
Definition: commit.h:40
The state in which the RISC OS boot option files are updated.
Definition: commit.h:50
The state in which an error has occurred.
Definition: commit.h:61
The state in which files are added to the current apps virtual directory.
Definition: commit.h:56
const std::set< string > & files_that_conflict() const
Get the set of destination pathnames that conflict with files already on the system.
Definition: commit.h:195
A class for unpacking and removing sets of packages.
Definition: unpack.h:33
The state in which packages are being configured.
Definition: commit.h:42
The state in which the list of system variables is updated.
Definition: commit.h:46
unsigned long long size_type
A type for representing byte counts.
Definition: commit.h:25
state_type state() const
Get current state of the commit operation.
Definition: commit.h:154
commit(pkgbase &pb, const std::set< string > &packages)
Construct commit operation.
Definition: commit.cc:28
The state in which packages are being considered for download.
Definition: commit.h:36
size_type files_done() const
Get number of files processed.
Definition: commit.h:160
progress()
Construct progress structure.
Definition: commit.cc:671
The state in which files added to the boot run files are run.
Definition: commit.h:54
A mixin class to represent a cooperative thread.
Definition: thread.h:12
string message() const
Get error message.
Definition: commit.h:186
log * detach_warnings()
Detach warnings log.
Definition: commit.h:213
Class to log actions that occur in LibPkg.
Definition: log.h:189
size_type bytes_done() const
Get number of bytes processed.
Definition: commit.h:172
state_type
Definition: commit.h:31
A class for representing the collection of package database tables.
Definition: pkgbase.h:22
log * warnings() const
Return warnings log.
Definition: commit.h:206
size_type bytes_done
The number of bytes downloaded.
Definition: commit.h:237
size_type bytes_total
The total number of bytes to download, or npos if not known.
Definition: commit.h:239
static const size_type npos
A null value for use in place of a byte count.
Definition: commit.h:28
A class for downloading a file from a URL.
Definition: download.h:19
A structure for monitoring the download progress of one source.
Definition: commit.h:234
size_type bytes_ctrl
The total number of bytes specified in the control record, or npos if no total was given...
Definition: commit.h:242
virtual ~commit()
Destroy commit operation.
Definition: commit.cc:51
A class for installing, removing and purging packages.
Definition: commit.h:20
LogCode
An enumeration of all the items that can be logged.
Definition: log.h:19
The state in which paths for components are set.
Definition: commit.h:34
The state in which files added to the boot look at and boot run files are booted. ...
Definition: commit.h:52

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)