4 #include "zypp/ResPool.h"
5 #include "zypp/Pathname.h"
6 #include "zypp/PoolQuery.h"
7 #include "zypp/ZConfig.h"
14 * Singleton class which manipulate with locks file and apply locks on pool.
15 * for user information about locksfile and its format see
16 * <a>http://en.opensuse.org/Libzypp/Locksfile</a>
21 typedef std::list<PoolQuery> LockList;
22 typedef LockList::const_iterator const_iterator;
23 typedef LockList::size_type size_type;
28 * Gets instance of this class.
31 static Locks& instance();
33 const_iterator begin() const;
34 const_iterator end() const;
35 LockList::size_type size() const;
40 * toBeAdded{Begin,End,Size,Empty}
41 * toBeRemoved{Begin,End,Size,Empty}
45 * locks result of query and add this lock as toAdd
47 void addLock( const PoolQuery& query );
50 * add lock by identifier (e.g. Selectable->ident()
51 * and add this lock as toAdd
53 void addLock( const IdString& ident_r );
56 * add lock by name and kind and
57 * add this lock as toAdd
59 void addLock( const ResKind& kind_r, const IdString& name_r );
62 * add lock by name and kind and
63 * add this lock as toAdd
65 void addLock( const ResKind& kind_r, const C_Str& name_r );
68 * unlocks by result of query and add to toRemove.
70 * If unlock non-saved lock (so he is in toAdd list) then both is deleted
71 * and nathing happen during save
73 void removeLock( const PoolQuery& query );
76 * remove lock by identifier (e.g. Selectable->ident()
78 * If unlock non-saved lock (so he is in toAdd list) then both is deleted
79 * and nathing happen during save
81 void removeLock( const IdString& ident_r );
84 * remove lock by name and kind
86 * If unlock non-saved lock (so he is in toAdd list) then both is deleted
87 * and nathing happen during save
89 void removeLock( const ResKind& kind_r, const IdString& name_r );
90 void removeLock( const ResKind& kind_r, const C_Str & name_r );
93 * Optimalized version of read and apply.
97 void readAndApply( const Pathname& file = ZConfig::instance().locksFile() );
100 * Read locks from file to list of stable locks (locks which is not changed
103 void read( const Pathname& file = ZConfig::instance().locksFile() );
106 * Applies locks in stable list (locks which is not changed during session).
111 * Merges toAdd and ToRemove list to stable list and
112 * save that stable list to file.
113 * \see SavingLocksReport
115 void save( const Pathname& file = ZConfig::instance().locksFile() );
118 * Merges toAdd and ToRemove list to stable list.
119 * \note Can call callback if problem during merging occure
120 * \see SavingLocksReport
125 * Gets true if some lock doesn't lock any object in pool
126 * This can happen e.g. if package is removed or
127 * due to user bad definition of lock
129 bool existEmpty() const;
132 * Call callback for each empty lock.
134 * \see CleanEmptyLocksReport
135 * \note you must call \a save to write cleaned locks to file
140 * Delete all query duplicate in loaded locks.
141 * \note you must call \a save to write cleaned locks to file
143 void removeDuplicates();
148 RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;