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 #include "libpkg/trigger.h"
12 
13 namespace pkg {
14 
15 class control_binary;
16 class pkgbase;
17 class download;
18 class unpack;
19 class trigger_run;
20 class triggers;
21 class trigger;
22 
24 class commit:
25  public thread
26 {
27 public:
29  typedef unsigned long long size_type;
30 
32  static const size_type npos=static_cast<size_type>(-1);
33 
34  // An enumeration for describing the state of the commit operation. */
36  {
72  };
73 private:
75  pkgbase& _pb;
76 
78  state_type _state;
79 
81  std::set<string> _packages_to_process;
82 
84  std::set<string> _packages_to_download;
85 
89  std::set<string> _packages_to_unpack;
90 
94  std::set<string> _packages_to_configure;
95 
99  std::set<string> _packages_to_purge;
100 
102  std::set<string> _components_to_remove;
103 
105  std::set<string> _files_to_boot;
107  std::set<string> _files_to_run;
109  std::set<string> _files_to_add_to_apps;
110 
112  string _pkgname;
113 
115  download* _dload;
116 
118  unpack* _upack;
119 
121  size_type _files_done;
122 
124  size_type _files_total;
125 
127  size_type _bytes_done;
128 
130  size_type _bytes_total;
131 
134  string _message;
135 
136  struct progress;
137 
139  std::map<string,progress> _progress_table;
140 
143  std::set<string> _files_that_conflict;
144 
146  trigger_run *_trigger_run;
147 
149  triggers *_triggers;
150 
152  trigger *_trigger;
153 
155  log *_log;
156 
158  log *_warnings;
159 
160 public:
165  commit(pkgbase& pb,const std::set<string>& packages);
166 
168  virtual ~commit();
169 
174  { return _state; }
175 
179  size_type files_done() const
180  { return _files_done; }
181 
185  size_type files_total() const
186  { return _files_total; }
187 
191  size_type bytes_done() const
192  { return _bytes_done; }
193 
197  size_type bytes_total() const
198  { return _bytes_total; }
199 
205  string message() const
206  { return _message; }
207 
208  bool has_substate_text() const;
210  std::string substate_text() const;
211 
218  const std::set<string>& files_that_conflict() const
219  { return _files_that_conflict; }
220 
222  void use_trigger_run(trigger_run *tr);
223 
227  void log_to(log *use_log);
228 
232  log *warnings() const {return _warnings;}
239  log *detach_warnings() {log *w = _warnings; _warnings = 0; return w;}
240 
241 protected:
242  virtual void poll();
243 private:
248  void update_download_progress();
249 
256  void warning(LogCode code, const std::string &item, const std::string &what);
257 };
258 
261 {
272  progress();
273 };
274 
275 }; /* namespace pkg */
276 
277 #endif
std::string substate_text() const
Definition: commit.cc:766
The state in which post remove triggers are run.
Definition: commit.h:62
A class to manage the package triggers executed during the commiting of the packages.
Definition: triggers.h:27
The state in which the sprite pool is updated.
Definition: commit.h:52
size_type bytes_total() const
Get total number of bytes to process.
Definition: commit.h:197
The state in which packages are being purged.
Definition: commit.h:48
The namespace used to hold the package management library.
Definition: auto_dir.cc:12
size_type bytes_done() const
Get number of bytes processed.
Definition: commit.h:191
The state in which packages are being downloaded.
Definition: commit.h:42
log * warnings() const
Return warnings log.
Definition: commit.h:232
void use_trigger_run(trigger_run *tr)
Set the class to run triggers.
Definition: commit.cc:772
size_type files_total() const
Get total number of files to process.
Definition: commit.h:185
The state in which post install triggers are run.
Definition: commit.h:64
The state in which all operations have been successfully completed.
Definition: commit.h:69
void log_to(log *use_log)
Set the log to add to.
Definition: commit.cc:777
virtual void poll()
Poll this thread.
Definition: commit.cc:62
The state in which packages are being unpacked or removed.
Definition: commit.h:44
The state in which the RISC OS boot option files are updated.
Definition: commit.h:54
The state in which an error has occurred.
Definition: commit.h:71
The state in which files are added to the current apps virtual directory.
Definition: commit.h:60
A class for unpacking and removing sets of packages.
Definition: unpack.h:38
The state in which packages are being configured.
Definition: commit.h:46
The state in which the list of system variables is updated.
Definition: commit.h:50
unsigned long long size_type
A type for representing byte counts.
Definition: commit.h:29
class to represent a trigger action from a script
Definition: trigger.h:22
commit(pkgbase &pb, const std::set< string > &packages)
Construct commit operation.
Definition: commit.cc:30
The state in which packages are being considered for download.
Definition: commit.h:40
The state in which files added to the boot run files are run.
Definition: commit.h:58
A mixin class to represent a cooperative thread.
Definition: thread.h:12
log * detach_warnings()
Detach warnings log.
Definition: commit.h:239
size_type files_done() const
Get number of files processed.
Definition: commit.h:179
Class to log actions that occur in LibPkg.
Definition: log.h:215
string message() const
Get error message.
Definition: commit.h:205
state_type
Definition: commit.h:35
Interface to execute a trigger.
Definition: trigger.h:66
bool has_substate_text() const
Definition: commit.cc:753
A class for representing the collection of package database tables.
Definition: pkgbase.h:24
state_type state() const
Get current state of the commit operation.
Definition: commit.h:173
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:218
The state in which work files and variables for triggers are cleaned up.
Definition: commit.h:66
size_type bytes_done
The number of bytes downloaded.
Definition: commit.h:263
size_type bytes_total
The total number of bytes to download, or npos if not known.
Definition: commit.h:265
static const size_type npos
A null value for use in place of a byte count.
Definition: commit.h:32
A class for downloading a file from a URL.
Definition: download.h:26
A structure for monitoring the download progress of one source.
Definition: commit.h:260
size_type bytes_ctrl
The total number of bytes specified in the control record, or npos if no total was given...
Definition: commit.h:268
virtual ~commit()
Destroy commit operation.
Definition: commit.cc:56
bool clear_substate_text_changed()
Definition: commit.cc:758
A class for installing, removing and purging packages.
Definition: commit.h:24
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:38
The state in which files added to the boot look at and boot run files are booted. ...
Definition: commit.h:56

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)