change locks api -
authorJosef Reidinger <jreidinger@suse.cz>
Tue, 22 Apr 2008 13:40:49 +0000 (13:40 +0000)
committerJosef Reidinger <jreidinger@suse.cz>
Tue, 22 Apr 2008 13:40:49 +0000 (13:40 +0000)
- make more functions const
- replace add/remove by selectable to add/remove by ident or name and kind

VERSION.cmake
zypp/Locks.cc
zypp/Locks.h
zypp/PoolQuery.cc
zypp/PoolQuery.h

index bd905b9..9bff196 100644 (file)
@@ -45,6 +45,6 @@
 #
 
 SET(LIBZYPP_MAJOR "4")
-SET(LIBZYPP_MINOR "13")
-SET(LIBZYPP_COMPATMINOR "13")
-SET(LIBZYPP_PATCH "3")
+SET(LIBZYPP_MINOR "14")
+SET(LIBZYPP_COMPATMINOR "14")
+SET(LIBZYPP_PATCH "0")
index 2ba1ea1..e276e6a 100644 (file)
@@ -21,6 +21,7 @@
 #include "zypp/PoolQueryUtil.tcc"
 #include "zypp/ZYppCallbacks.h"
 #include "zypp/sat/SolvAttr.h"
+#include "zypp/sat/Solvable.h"
 #include "zypp/PathInfo.h"
 
 #undef ZYPP_BASE_LOGGER_LOGGROUP
@@ -53,16 +54,16 @@ public:
 
 Locks::Locks() : _pimpl(new Impl){}
 
-Locks::iterator Locks::begin()
+Locks::const_iterator Locks::begin() const
 { return _pimpl->locks.begin(); }
 
-Locks::iterator Locks::end()
+Locks::const_iterator Locks::end() const
 { return _pimpl->locks.end(); }
 
-Locks::LockList::size_type Locks::size()
+Locks::LockList::size_type Locks::size() const
 { return _pimpl->locks.size(); }
 
-bool Locks::empty()
+bool Locks::empty() const
 { return _pimpl->locks.empty(); }
 
 struct ApplyLock
@@ -115,7 +116,7 @@ void Locks::read( const Pathname& file )
 }
 
 
-void Locks::apply()
+void Locks::apply() const
 { 
   DBG << "apply locks" << endl;
   for_each(begin(), end(), ApplyLock());
@@ -144,14 +145,25 @@ void Locks::addLock( const PoolQuery& query )
   }
 }
 
-void Locks::addLock(const ui::Selectable& selectable)
+void Locks::addLock( const IdString& ident_r )
+{
+  sat::Solvable::SplitIdent id(ident_r);
+  addLock(id.kind(),id.name());
+}
+
+void Locks::addLock( const ResKind& kind_r, const C_Str & name_r )
+{
+  addLock(kind_r,IdString(name_r));
+}
+
+void Locks::addLock( const ResKind& kind_r, const IdString& name_r )
 {
   PoolQuery q;
-  q.addAttribute( sat::SolvAttr::name,selectable.name() );
-  q.addKind( selectable.kind() );
+  q.addAttribute( sat::SolvAttr::name,name_r.asString() );
+  q.addKind( kind_r );
   q.setMatchExact();
   q.setCaseSensitive(true);
-  DBG << "add lock by selectactable" << endl;
+  DBG << "add lock by identifier" << endl;
   addLock( q );
 }
 
@@ -178,11 +190,22 @@ void Locks::removeLock( const PoolQuery& query )
   }
 }
 
-void Locks::removeLock( const ui::Selectable& s )
+void Locks::removeLock( const IdString& ident_r )
+{
+  sat::Solvable::SplitIdent id(ident_r);
+  removeLock(id.kind(),id.name());
+}
+
+void Locks::removeLock( const ResKind& kind_r, const C_Str & name_r )
+{
+  removeLock(kind_r,IdString(name_r));
+}
+
+void Locks::removeLock( const ResKind &kind_r, const IdString &name_r )
 {
   PoolQuery q;
-  q.addAttribute( sat::SolvAttr::name,s.name() );
-  q.addKind( s.kind() );
+  q.addAttribute( sat::SolvAttr::name,name_r.asString() );
+  q.addKind( kind_r );
   q.setMatchExact();
   q.setCaseSensitive(true);
   q.requireAll();
@@ -190,7 +213,7 @@ void Locks::removeLock( const ui::Selectable& s )
   removeLock(q);
 }
 
-bool Locks::existEmpty()
+bool Locks::existEmpty() const
 {
   for_( it, _pimpl->locks.begin(), _pimpl->locks.end() )
   {
index 3b6965b..f6e4120 100644 (file)
@@ -5,7 +5,6 @@
 #include "zypp/Pathname.h"
 #include "zypp/PoolQuery.h"
 #include "zypp/ZConfig.h"
-#include "zypp/ui/Selectable.h"
  
 namespace zypp
 {
@@ -13,16 +12,16 @@ namespace zypp
   {
   public:
     typedef std::list<PoolQuery> LockList;
-    typedef LockList::const_iterator iterator;
+    typedef LockList::const_iterator const_iterator;
   public:
     class Impl;
 
     static Locks& instance();
 
-    iterator begin();
-    iterator end();
-    LockList::size_type size();
-    bool empty();
+    const_iterator begin() const;
+    const_iterator end() const;
+    LockList::size_type size() const;
+    bool empty() const;
 
     /**
      * TODO add:
@@ -38,9 +37,15 @@ namespace zypp
     void addLock( const PoolQuery& query );
 
     /**
-     * locks selectable
+     * add lock by identifier (f.e. Selectable->ident()
      */
-    void addLock( const ui::Selectable& selectable );
+    void addLock( const IdString& ident_r );
+
+    /**
+     * add lock by name and kind
+     */ 
+    void addLock( const ResKind& kind_r, const IdString& name_r );
+    void addLock( const ResKind& kind_r, const C_Str& name_r );
 
     /**
      * unlocks all solvables which is result of query.
@@ -48,17 +53,26 @@ namespace zypp
      */
     void removeLock( const PoolQuery& query );
 
-    void removeLock( const ui::Selectable& selectable );
+    /**
+     * add lock by identifier (f.e. Selectable->ident()
+     */
+    void removeLock( const IdString& ident_r );
+
+    /**
+     * add lock by name and kind
+     */ 
+    void removeLock( const ResKind& kind_r, const IdString& name_r );
+    void removeLock( const ResKind& kind_r, const C_Str & name_r );
 
     void readAndApply( const Pathname& file = ZConfig::instance().locksFile() );
 
     void read( const Pathname& file = ZConfig::instance().locksFile() );
 
-    void apply();
+    void apply() const;
 
     void save( const Pathname& file = ZConfig::instance().locksFile() );
     
-    bool existEmpty();
+    bool existEmpty() const;
 
     void removeEmpty();
 
index 0e23ede..7ed3b72 100644 (file)
@@ -846,11 +846,11 @@ attremptycheckend:
   { return _pimpl->end(); }
 
 
-  bool PoolQuery::empty()
+  bool PoolQuery::empty() const
   { return _pimpl->begin() == _pimpl->end(); }
 
   //! \todo collect the result, reuse if not dirty
-  PoolQuery::size_type PoolQuery::size()
+  PoolQuery::size_type PoolQuery::size() const
   {
     size_type count = 0;
     for(const_iterator it = _pimpl->begin(); it != _pimpl->end(); ++it, ++count);
index e63ff36..9fe3f68 100644 (file)
@@ -73,9 +73,9 @@ namespace zypp
     /** */
     const_iterator end() const;
     /** */
-    bool empty();
+    bool empty() const;
     /** */
-    size_type size();
+    size_type size() const;
     //@}
 
     /**