3b6965bb6f72fe1a0e2572aeb9c4b98a647a85d4
[platform/upstream/libzypp.git] / zypp / Locks.h
1 #ifndef ZYPP_LOCKS_H
2 #define ZYPP_LOCKS_H
3
4 #include "zypp/ResPool.h"
5 #include "zypp/Pathname.h"
6 #include "zypp/PoolQuery.h"
7 #include "zypp/ZConfig.h"
8 #include "zypp/ui/Selectable.h"
9  
10 namespace zypp
11 {
12   class Locks
13   {
14   public:
15     typedef std::list<PoolQuery> LockList;
16     typedef LockList::const_iterator iterator;
17   public:
18     class Impl;
19
20     static Locks& instance();
21
22     iterator begin();
23     iterator end();
24     LockList::size_type size();
25     bool empty();
26
27     /**
28      * TODO add:
29      * applied{Begin,End,Size,Empty}
30      * toBeAdded{Begin,End,Size,Empty}
31      * toBeRemoved{Begin,End,Size,Empty}
32      * bool dirty();
33      */
34
35     /**
36      * locks all solvables which is result of query
37      */
38     void addLock( const PoolQuery& query );
39
40     /**
41      * locks selectable
42      */
43     void addLock( const ui::Selectable& selectable );
44
45     /**
46      * unlocks all solvables which is result of query.
47      * Can call callback
48      */
49     void removeLock( const PoolQuery& query );
50
51     void removeLock( const ui::Selectable& selectable );
52
53     void readAndApply( const Pathname& file = ZConfig::instance().locksFile() );
54
55     void read( const Pathname& file = ZConfig::instance().locksFile() );
56
57     void apply();
58
59     void save( const Pathname& file = ZConfig::instance().locksFile() );
60     
61     bool existEmpty();
62
63     void removeEmpty();
64
65   private:
66     Locks();
67     
68     RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
69
70   };
71 }
72     
73 #endif