LibPkg
status.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
7 #define LIBPKG_STATUS
8 
9 #include <utility>
10 #include <string>
11 #include <stdexcept>
12 #include <iosfwd>
13 
14 namespace pkg {
15 
16 using std::string;
17 
33 class status
34 {
35 public:
37  {
57  };
58  enum flag_type
59  {
69  };
71  {
84  };
85  class parse_error;
86 private:
88  state_type _state;
90  unsigned short _flags;
92  unsigned short _iflags;
96  string _version;
100  string _environment_id;
101 public:
105  status();
106 
113  status(state_type state,const string& version, const string &environment_id);
114 
116  ~status();
117 
122  { return _state; }
123 
128  bool flag(flag_type flag) const
129  { return (_flags>>flag)&1; }
130 
136  { return (_iflags>>flag)&1; }
137 
141  unsigned int flags() const
142  { return _flags; }
143 
147  string version() const
148  { return _version; }
149 
153  string environment_id() const
154  { return _environment_id;}
155 
159  void state(state_type state);
160 
165  void flag(flag_type flag,bool value);
166 
171  void flag(internal_flag_type flag,bool value);
172 
176  void version(const string& version);
177 
181  void environment_id(const string &environment_id);
182 };
183 
186  public std::runtime_error
187 {
188 public:
192  parse_error(const string& message);
193 };
194 
200 bool operator==(const status& lhs,const status& rhs);
201 
207 bool operator!=(const status& lhs,const status& rhs);
208 
214 std::ostream& operator<<(std::ostream& out,
215  const std::pair<string,status>& pkgstat);
216 
222 std::istream& operator>>(std::istream& in,std::pair<string,status>& pkgstat);
223 
235 bool unpack_req(const status& curstat,const status& selstat);
236 
248 bool remove_req(const status& curstat,const status& selstat);
249 
262 bool config_req(const status& curstat,const status& selstat);
263 
274 bool purge_req(const status& curstat,const status& selstat);
275 
276 }; /* namespace pkg */
277 
278 #endif
std::ostream & operator<<(std::ostream &out, const component &comp)
Write component record to output stream.
Definition: component.cc:179
string environment_id() const
Get environment id.
Definition: status.h:153
bool remove_req(const status &curstat, const status &selstat)
Determine whether a package should be removed.
Definition: status.cc:233
A flag to indicate that this package must be removed.
Definition: status.h:75
A flag to indicate that a package has been installed automatically to meet a dependency (and should t...
Definition: status.h:64
state_type state() const
Get installation state.
Definition: status.h:121
bool flag(flag_type flag) const
Get status flag.
Definition: status.h:128
The namespace used to hold the package management library.
Definition: auto_dir.cc:12
bool unpack_req(const status &curstat, const status &selstat)
Determine whether a package should be unpacked.
Definition: status.cc:225
A class to represent the current or required status of a package.
Definition: status.h:33
A flag to indicate that a package has been placed on hold (which prevents any change of state unless ...
Definition: status.h:68
A state to indicate that a package has been removed but its configuration files may remain...
Definition: status.h:43
std::istream & operator>>(std::istream &in, component &comp)
Read component record from input stream.
Definition: component.cc:193
bool purge_req(const status &curstat, const status &selstat)
Determine whether a package should be purged.
Definition: status.cc:249
A state to indicate that a package is partially configured.
Definition: status.h:53
An exception class for reporting parse errors.
Definition: status.h:185
internal_flag_type
Definition: status.h:70
bool flag(internal_flag_type flag) const
Get internal flag.
Definition: status.h:135
A state to indicate that a package is partially unpacked or partially removed.
Definition: status.h:47
~status()
Destroy status.
Definition: status.cc:66
A state to indicate that a package has either been purged or was never installed. ...
Definition: status.h:40
unsigned int flags() const
Get status flags.
Definition: status.h:141
flag_type
Definition: status.h:58
status()
Construct status.
Definition: status.cc:52
A class to represent a package version.
Definition: version.h:21
A state to indicate that a package has been unpacked but not configured.
Definition: status.h:50
bool operator!=(const status &lhs, const status &rhs)
Test whether two status records are unequal.
Definition: status.cc:108
A flag to indicate that this package must be installed.
Definition: status.h:79
bool operator==(const status &lhs, const status &rhs)
Test whether two status records are equal.
Definition: status.cc:100
A state to indicate that a package has been successfully unpacked and configured. ...
Definition: status.h:56
string version() const
Get package version.
Definition: status.h:147
state_type
Definition: status.h:36
bool config_req(const status &curstat, const status &selstat)
Determine whether a package should be configured.
Definition: status.cc:241
A flag to indicate that this package must be upgraded.
Definition: status.h:83

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)