Mailinglist Archive: zypp-commit (606 mails)

< Previous Next >
[zypp-commit] r9820 - in /trunk/libzypp/zypp: Locks.h ZYppCallbacks.h
  • From: jreidinger@xxxxxxxxxxxxxxxx
  • Date: Fri, 25 Apr 2008 13:22:05 -0000
  • Message-id: <20080425132206.1B75733707@xxxxxxxxxxxxxxxx>
Author: jreidinger
Date: Fri Apr 25 15:22:05 2008
New Revision: 9820

URL: http://svn.opensuse.org/viewcvs/zypp?rev=9820&view=rev
Log:
improve lock documentation

Modified:
trunk/libzypp/zypp/Locks.h
trunk/libzypp/zypp/ZYppCallbacks.h

Modified: trunk/libzypp/zypp/Locks.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Locks.h?rev=9820&r1=9819&r2=9820&view=diff
==============================================================================
--- trunk/libzypp/zypp/Locks.h (original)
+++ trunk/libzypp/zypp/Locks.h Fri Apr 25 15:22:05 2008
@@ -8,6 +8,13 @@

namespace zypp
{
+ /** \name Locks */
+ //@{
+ /**
+ * Singleton class which manipulate with locks file and apply locks on pool.
+ * for user information about locksfile and its format see
+ * <a>http://en.opensuse.org/Libzypp/Locksfile</a>
+ */
class Locks
{
public:
@@ -16,6 +23,10 @@
public:
class Impl;

+ /**
+ * Gets instance of this class.
+ * Singleton method.
+ */
static Locks& instance();

const_iterator begin() const;
@@ -25,57 +36,99 @@

/**
* TODO add:
- * applied{Begin,End,Size,Empty}
* toBeAdded{Begin,End,Size,Empty}
* toBeRemoved{Begin,End,Size,Empty}
- * bool dirty();
*/

/**
- * locks all solvables which is result of query
+ * locks result of query and add this lock as toAdd
*/
void addLock( const PoolQuery& query );

/**
- * add lock by identifier (f.e. Selectable->ident()
+ * add lock by identifier (e.g. Selectable->ident()
+ * and add this lock as toAdd
*/
void addLock( const IdString& ident_r );

/**
- * add lock by name and kind
+ * add lock by name and kind and
+ * add this lock as toAdd
*/
void addLock( const ResKind& kind_r, const IdString& name_r );
+
+ /**
+ * add lock by name and kind and
+ * add this lock as toAdd
+ */
void addLock( const ResKind& kind_r, const C_Str& name_r );

/**
- * unlocks all solvables which is result of query.
- * Can call callback
+ * unlocks by result of query and add to toRemove.
+ *
+ * If unlock non-saved lock (so he is in toAdd list) then both is deleted
+ * and nathing happen during save
*/
void removeLock( const PoolQuery& query );

/**
- * add lock by identifier (f.e. Selectable->ident()
+ * remove lock by identifier (e.g. Selectable->ident()
+ *
+ * If unlock non-saved lock (so he is in toAdd list) then both is deleted
+ * and nathing happen during save
*/
void removeLock( const IdString& ident_r );

/**
- * add lock by name and kind
- */
+ * remove lock by name and kind
+ *
+ * If unlock non-saved lock (so he is in toAdd list) then both is deleted
+ * and nathing happen during save
+ */
void removeLock( const ResKind& kind_r, const IdString& name_r );
void removeLock( const ResKind& kind_r, const C_Str & name_r );

+ /**
+ * Optimalized version of read and apply.
+ * \see read
+ * \see apply
+ */
void readAndApply( const Pathname& file = ZConfig::instance().locksFile()
);

+ /**
+ * Read locks from file to list of stable locks (locks which is not changed
+ * during session)
+ */
void read( const Pathname& file = ZConfig::instance().locksFile() );

+ /**
+ * Applies locks in stable list (locks which is not changed during
session).
+ */
void apply() const;

+ /**
+ * Merges toAdd and ToRemove list to stable list and
+ * save that stable list to file.
+ * \see SavingLocksReport
+ */
void save( const Pathname& file = ZConfig::instance().locksFile() );

+ /**
+ * Gets true if some lock doesn't lock any object in pool
+ * This can happen e.g. if package is removed or
+ * due to user bad definition of lock
+ */
bool existEmpty() const;

+ /**
+ * Call callback for each empty lock.
+ * \see existEmpty
+ * \see CleanEmptyLocksReport
+ * \note you must call \a save to write cleaned locks to file
+ */
void removeEmpty();

+ //@}
private:
Locks();


Modified: trunk/libzypp/zypp/ZYppCallbacks.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZYppCallbacks.h?rev=9820&r1=9819&r2=9820&view=diff
==============================================================================
--- trunk/libzypp/zypp/ZYppCallbacks.h (original)
+++ trunk/libzypp/zypp/ZYppCallbacks.h Fri Apr 25 15:22:05 2008
@@ -624,66 +624,107 @@

class PoolQuery;

+ /** \name Locks */
+ //@{
+ /**
+ * Callback for cleaning locks which doesn't lock anything in pool.
+ */
+
struct CleanEmptyLocksReport : public callback::ReportBase
{
+ /**
+ * action performed by cleaning api to specific lock
+ */
enum Action {
- ABORT, // abort and return error
- DELETE, // delete empty lock
- IGNORE // skip empty lock
+ ABORT, /**< abort and return error */
+ DELETE, /**< delete empty lock */
+ IGNORE /**< skip empty lock */
};

+ /**
+ * result of cleaning
+ */
enum Error {
- NO_ERROR,
- ABORTED // cleaning aborted
+ NO_ERROR, /**< no problem */
+ ABORTED /** cleaning aborted by user */
};

+ /**
+ * cleaning is started
+ */
virtual void start(
) {}

+ /**
+ * progress of cleaning specifies in percents
+ * \return if continue
+ */
virtual bool progress(int /*value*/)
{ return true; }

/**
* When find empty lock ask what to do with it
+ * \return action
*/
virtual Action execute(
const PoolQuery& /*error*/
) { return DELETE; }

+ /**
+ * cleaning is done
+ */
virtual void finish(
Error /*error*/
) {}

};

+ /**
+ * this callback handles merging old locks with newly added or removed
+ */
struct SavingLocksReport : public callback::ReportBase
{
+ /**
+ * action for old lock which is in conflict
+ * \see ConflictState
+ */
enum Action {
- ABORT, // abort and return error
- DELETE, // delete conflicted lock
- IGNORE // skip conflict lock
+ ABORT, /**< abort and return error*/
+ DELETE, /**< delete conflicted lock */
+ IGNORE /**< skip conflict lock */
};

+ /**
+ * result of merging
+ */
enum Error {
- NO_ERROR,
- ABORTED // cleaning aborted
+ NO_ERROR, /**< no problem */
+ ABORTED /**< cleaning aborted by user */
};

+ /**
+ * type of conflict of old and new lock
+ */
enum ConflictState{
- SAME_RESULTS,
- INTERSECT
+ SAME_RESULTS, /**< locks lock same item in pool but his parameters is
different */
+ INTERSECT /**< locks lock some file and unlocking lock unlock only part
+ * of iti, so removing old lock can unlock more items in pool */
};

virtual void start() {}

- virtual bool progress() /*still alive*/
+ /**
+ * merging still live
+ * \return if continue
+ */
+ virtual bool progress()
{ return true; }

/**
* When user unlock something which is locked by non-identical query
*/
virtual Action conflict(
- const PoolQuery&, /*problematic query*/
+ const PoolQuery&, /**< problematic query*/
ConflictState
) { return DELETE; }


--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages