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;
97 public:
101  status();
102 
108  status(state_type state,const string& version);
109 
111  ~status();
112 
117  { return _state; }
118 
123  bool flag(flag_type flag) const
124  { return (_flags>>flag)&1; }
125 
131  { return (_iflags>>flag)&1; }
132 
136  unsigned int flags() const
137  { return _flags; }
138 
142  string version() const
143  { return _version; }
144 
148  void state(state_type state);
149 
154  void flag(flag_type flag,bool value);
155 
160  void flag(internal_flag_type flag,bool value);
161 
165  void version(const string& version);
166 };
167 
170  public std::runtime_error
171 {
172 public:
176  parse_error(const string& message);
177 };
178 
184 bool operator==(const status& lhs,const status& rhs);
185 
191 bool operator!=(const status& lhs,const status& rhs);
192 
198 std::ostream& operator<<(std::ostream& out,
199  const std::pair<string,status>& pkgstat);
200 
206 std::istream& operator>>(std::istream& in,std::pair<string,status>& pkgstat);
207 
219 bool unpack_req(const status& curstat,const status& selstat);
220 
232 bool remove_req(const status& curstat,const status& selstat);
233 
246 bool config_req(const status& curstat,const status& selstat);
247 
258 bool purge_req(const status& curstat,const status& selstat);
259 
260 }; /* namespace pkg */
261 
262 #endif
std::ostream & operator<<(std::ostream &out, const component &comp)
Write component record to output stream.
Definition: component.cc:175
bool remove_req(const status &curstat, const status &selstat)
Determine whether a package should be removed.
Definition: status.cc:212
A flag to indicate that this package must be removed.
Definition: status.h:75
parse_error(const string &message)
Construct parse error.
Definition: status.cc:90
A flag to indicate that a package has been installed automatically to meet a dependency (and should t...
Definition: status.h:64
unsigned int flags() const
Get status flags.
Definition: status.h:136
bool unpack_req(const status &curstat, const status &selstat)
Determine whether a package should be unpacked.
Definition: status.cc:205
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:189
bool purge_req(const status &curstat, const status &selstat)
Determine whether a package should be purged.
Definition: status.cc:226
bool flag(internal_flag_type flag) const
Get internal flag.
Definition: status.h:130
A state to indicate that a package is partially configured.
Definition: status.h:53
An exception class for reporting parse errors.
Definition: status.h:169
internal_flag_type
Definition: status.h:70
A state to indicate that a package is partially unpacked or partially removed.
Definition: status.h:47
~status()
Destroy status.
Definition: status.cc:65
bool flag(flag_type flag) const
Get status flag.
Definition: status.h:123
A state to indicate that a package has either been purged or was never installed. ...
Definition: status.h:40
state_type state() const
Get installation state.
Definition: status.h:116
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
string version() const
Get package version.
Definition: status.h:142
bool operator!=(const status &lhs, const status &rhs)
Test whether two status records are unequal.
Definition: status.cc:101
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:94
A state to indicate that a package has been successfully unpacked and configured. ...
Definition: status.h:56
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:219
A flag to indicate that this package must be upgraded.
Definition: status.h:83

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)