LibPkg
update.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_UPDATE
7 #define LIBPKG_UPDATE
8 
9 #include <string>
10 #include <map>
11 #include <set>
12 #include <iosfwd>
13 
14 #include "libpkg/source_table.h"
16 #include "libpkg/thread.h"
17 
18 namespace pkg {
19 
20 using std::string;
21 
22 class pkgbase;
23 class download;
24 class log;
25 
30 class update:
31  public thread
32 {
33 public:
35  typedef unsigned long long size_type;
36 
38  static const size_type npos=static_cast<size_type>(-1);
39 
42  {
58  };
59 private:
61  pkgbase& _pb;
62 
64  state_type _state;
65 
67  string _url;
68 
70  download* _dload;
71 
73  std::set<string> _sources_to_download;
74 
76  std::set<string> _sources_to_build;
77 
80  std::set<binary_control_table::key_type> _packages_written;
81 
83  std::ostream* _out;
84 
86  size_type _bytes_done;
87 
89  size_type _bytes_total;
90 
93  string _message;
94 
95  struct progress;
96 
98  std::map<string,progress> _progress_table;
99 
101  log *_log;
102 public:
106  update(pkgbase& pb);
107 
109  virtual ~update();
110 
115  { return _state; }
116 
120  size_type bytes_done() const
121  { return _bytes_done; }
122 
126  size_type bytes_total() const
127  { return _bytes_total; }
128 
134  string message() const
135  { return _message; }
136 
140  void log_to(log *use_log);
141 
142 protected:
143  void poll();
144 private:
150  void _poll();
151 
156  void update_progress();
157 };
158 
161 {
172  progress();
173 };
174 
175 }; /* namespace pkg */
176 
177 #endif
The state in which the update operation failed.
Definition: update.h:57
state_type
An enumeration for describing the state of the update operation.
Definition: update.h:41
A class for updating the package database.
Definition: update.h:30
void log_to(log *use_log)
Set the log to add to.
Definition: update.cc:272
virtual ~update()
Destroy update operation.
Definition: update.cc:28
The namespace used to hold the package management library.
Definition: auto_dir.cc:12
unsigned long long size_type
A type for representing byte counts.
Definition: update.h:35
size_type bytes_done
The number of bytes downloaded.
Definition: update.h:163
The state in which local packages are incorporated into the available list.
Definition: update.h:52
The state in which the package indexes are being downloaded.
Definition: update.h:46
size_type bytes_prev
The total number of bytes when most recently downloaded, or npos if no previous total is available...
Definition: update.h:168
A mixin class to represent a cooperative thread.
Definition: thread.h:12
Class to log actions that occur in LibPkg.
Definition: log.h:213
state_type state() const
Get current state.
Definition: update.h:114
A class for representing the collection of package database tables.
Definition: pkgbase.h:24
The state in which the sources list is being read.
Definition: update.h:44
A structure for monitoring the progress of one source.
Definition: update.h:160
size_type bytes_done() const
Get number of bytes downloaded.
Definition: update.h:120
A class for downloading a file from a URL.
Definition: download.h:26
size_type bytes_total() const
Get total number of bytes to download.
Definition: update.h:126
string message() const
Get error message.
Definition: update.h:134
The state in which remote sources are incorporated into the available list.
Definition: update.h:49
static const size_type npos
A null value for use in place of a byte count.
Definition: update.h:38
size_type bytes_total
The total number of bytes to download, or npos if not known.
Definition: update.h:165
void poll()
Poll this thread.
Definition: update.cc:31
The state in which the update operation has been successfully completed.
Definition: update.h:55
update(pkgbase &pb)
Construct update operation.
Definition: update.cc:18

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)