Author: jreidinger Date: Tue Apr 22 15:40:49 2008 New Revision: 9781 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9781&view=rev Log: change locks api - - make more functions const - replace add/remove by selectable to add/remove by ident or name and kind Modified: trunk/libzypp/VERSION.cmake trunk/libzypp/zypp/Locks.cc trunk/libzypp/zypp/Locks.h trunk/libzypp/zypp/PoolQuery.cc trunk/libzypp/zypp/PoolQuery.h Modified: trunk/libzypp/VERSION.cmake URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=9781&r1=9780&r2=9781&view=diff ============================================================================== --- trunk/libzypp/VERSION.cmake (original) +++ trunk/libzypp/VERSION.cmake Tue Apr 22 15:40:49 2008 @@ -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") Modified: trunk/libzypp/zypp/Locks.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Locks.cc?rev=9781&r1=9780&r2=9781&view=diff ============================================================================== --- trunk/libzypp/zypp/Locks.cc (original) +++ trunk/libzypp/zypp/Locks.cc Tue Apr 22 15:40:49 2008 @@ -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 @@ 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::apply() +void Locks::apply() const { DBG << "apply locks" << endl; for_each(begin(), end(), ApplyLock()); @@ -144,14 +145,25 @@ } } -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 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 @@ removeLock(q); } -bool Locks::existEmpty() +bool Locks::existEmpty() const { for_( it, _pimpl->locks.begin(), _pimpl->locks.end() ) { Modified: trunk/libzypp/zypp/Locks.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Locks.h?rev=9781&r1=9780&r2=9781&view=diff ============================================================================== --- trunk/libzypp/zypp/Locks.h (original) +++ trunk/libzypp/zypp/Locks.h Tue Apr 22 15:40:49 2008 @@ -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 @@ { 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 @@ 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 @@ */ 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(); Modified: trunk/libzypp/zypp/PoolQuery.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9781&r1=9780&r2=9781&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolQuery.cc (original) +++ trunk/libzypp/zypp/PoolQuery.cc Tue Apr 22 15:40:49 2008 @@ -846,11 +846,11 @@ { 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); Modified: trunk/libzypp/zypp/PoolQuery.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.h?rev=9781&r1=9780&r2=9781&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolQuery.h (original) +++ trunk/libzypp/zypp/PoolQuery.h Tue Apr 22 15:40:49 2008 @@ -73,9 +73,9 @@ /** */ const_iterator end() const; /** */ - bool empty(); + bool empty() const; /** */ - size_type size(); + size_type size() const; //@} /** -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org