]> git.saurik.com Git - apt.git/blame - apt-pkg/statechanges.h
refer to apt-secure(8) in unsecure repositories warning
[apt.git] / apt-pkg / statechanges.h
CommitLineData
b49068c5
DK
1#include <apt-pkg/pkgcache.h>
2#include <apt-pkg/cacheset.h>
3#include <apt-pkg/macros.h>
4
5#include <memory>
6
7namespace 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 */
13class APT_PUBLIC StateChanges
14{
15public:
16 // getter/setter for the different states
64e3414e
DK
17#define APT_GETTERSETTER(Name) \
18 APT::VersionVector& Name(); \
19 void Name(pkgCache::VerIterator const &Ver)
20 APT_GETTERSETTER(Hold);
21 APT_GETTERSETTER(Unhold);
22 APT_GETTERSETTER(Install);
23 APT_GETTERSETTER(Remove);
24 APT_GETTERSETTER(Purge);
b49068c5 25 APT::VersionVector& Error();
64e3414e 26#undef APT_GETTERSETTER
b49068c5 27
64e3414e
DK
28 // operate on all containers at once
29 void clear();
30 bool empty() const;
b49068c5
DK
31
32 /** commit the staged changes to the database(s).
33 *
34 * Makes the needed calls to store the requested states.
35 * After this call the state containers will hold only versions
36 * for which the storing operation succeeded. Versions where the
37 * storing operation failed are collected in #Error(). Note that
38 * error is an upper bound as states are changed in batches so it
39 * isn't always clear which version triggered the failure exactly.
40 *
41 * @param DiscardOutput controls if stdout/stderr should be used
42 * by subprocesses for (detailed) error reporting if needed.
43 * @return \b false if storing failed, true otherwise.
44 * Note that some states might be applied even if the whole operation failed.
45 */
46 bool Save(bool const DiscardOutput = false);
47
48 StateChanges();
49 StateChanges(StateChanges&&);
50 StateChanges& operator=(StateChanges&&);
51 ~StateChanges();
52
53private:
54 class APT_HIDDEN Private;
55 std::unique_ptr<Private> d;
56};
57
58}