File: statechanges.h

package info (click to toggle)
apt 1.8.2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 19,680 kB
  • sloc: cpp: 67,708; sh: 24,865; xml: 5,187; perl: 577; ansic: 190; makefile: 28; python: 28
file content (58 lines) | stat: -rw-r--r-- 1,743 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <apt-pkg/cacheset.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/pkgcache.h>

#include <memory>

namespace APT
{

/** Simple wrapper class to abstract away the differences in storing different
 *  states in different places potentially in different versions.
 */
class APT_PUBLIC StateChanges
{
public:
   // getter/setter for the different states
#define APT_GETTERSETTER(Name) \
   APT::VersionVector& Name(); \
   void Name(pkgCache::VerIterator const &Ver)
   APT_GETTERSETTER(Hold);
   APT_GETTERSETTER(Unhold);
   APT_GETTERSETTER(Install);
   APT_GETTERSETTER(Remove);
   APT_GETTERSETTER(Purge);
   APT::VersionVector& Error();
#undef APT_GETTERSETTER

   // operate on all containers at once
   void clear();
   bool empty() const;

   /** commit the staged changes to the database(s).
    *
    * Makes the needed calls to store the requested states.
    * After this call the state containers will hold only versions
    * for which the storing operation succeeded. Versions where the
    * storing operation failed are collected in #Error(). Note that
    * error is an upper bound as states are changed in batches so it
    * isn't always clear which version triggered the failure exactly.
    *
    * @param DiscardOutput controls if stdout/stderr should be used
    *   by subprocesses for (detailed) error reporting if needed.
    * @return \b false if storing failed, true otherwise.
    *   Note that some states might be applied even if the whole operation failed.
    */
   bool Save(bool const DiscardOutput = false);

   StateChanges();
   StateChanges(StateChanges&&);
   StateChanges& operator=(StateChanges&&);
   ~StateChanges();

private:
   class APT_HIDDEN Private;
   std::unique_ptr<Private> d;
};

}