]> git.saurik.com Git - apt.git/blob - apt-pkg/statechanges.h
fa60c586491b603fda60a89f553ba4eb96494e43
[apt.git] / apt-pkg / statechanges.h
1 #include <apt-pkg/pkgcache.h>
2 #include <apt-pkg/cacheset.h>
3 #include <apt-pkg/macros.h>
4
5 #include <memory>
6
7 namespace APT
8 {
9
10 /** Simple wrapper class to abstract away the differences in storing different
11 * states in different places potentially in different versions.
12 */
13 class APT_PUBLIC StateChanges
14 {
15 public:
16 // getter/setter for the different states
17 APT::VersionVector& Hold();
18 void Hold(pkgCache::VerIterator const &Ver);
19 APT::VersionVector& Unhold();
20 void Unhold(pkgCache::VerIterator const &Ver);
21 APT::VersionVector& Error();
22
23 // forgets all unsaved changes
24 void Discard();
25
26 /** commit the staged changes to the database(s).
27 *
28 * Makes the needed calls to store the requested states.
29 * After this call the state containers will hold only versions
30 * for which the storing operation succeeded. Versions where the
31 * storing operation failed are collected in #Error(). Note that
32 * error is an upper bound as states are changed in batches so it
33 * isn't always clear which version triggered the failure exactly.
34 *
35 * @param DiscardOutput controls if stdout/stderr should be used
36 * by subprocesses for (detailed) error reporting if needed.
37 * @return \b false if storing failed, true otherwise.
38 * Note that some states might be applied even if the whole operation failed.
39 */
40 bool Save(bool const DiscardOutput = false);
41
42 StateChanges();
43 StateChanges(StateChanges&&);
44 StateChanges& operator=(StateChanges&&);
45 ~StateChanges();
46
47 private:
48 class APT_HIDDEN Private;
49 std::unique_ptr<Private> d;
50 };
51
52 }