26#undef ZYPP_BASE_LOGGER_LOGGROUP 
   27#define ZYPP_BASE_LOGGER_LOGGROUP "locks" 
   38  static Locks _instance;
 
 
   44template <
typename TPredicate>
 
   47  LockSet::iterator first = lockset_r.begin();
 
   48  LockSet::iterator last = lockset_r.end();
 
   49  while ( first != last )
 
   51    LockSet::iterator next = first;
 
   53    if ( pred_r( *first ) )
 
   54      lockset_r.erase( first );
 
 
  103{ 
return _pimpl->APIlocks().begin(); }
 
 
  106{ 
return _pimpl->APIlocks().end(); }
 
 
  109{ 
return _pimpl->locks().size(); }
 
 
  112{ 
return _pimpl->locks().empty(); }
 
 
  121      DBG << 
"lock "<< item.name();
 
 
 
  130template <
class OutputIterator>
 
  149  MIL << 
"read and apply locks from "<<file << endl;
 
  153    std::insert_iterator<LockSet> ii( 
_pimpl->MANIPlocks(), 
_pimpl->MANIPlocks().end() );
 
  155    readPoolQueriesFromFile( file, boost::make_function_output_iterator(lout) );
 
  158    MIL << 
"file does not exist(or cannot be stat), no lock added." << endl;
 
 
  164  MIL << 
"read locks from "<<file << endl;
 
  167    readPoolQueriesFromFile( file, std::insert_iterator<LockSet>(
_pimpl->MANIPlocks(), 
_pimpl->MANIPlocks().end()) );
 
  169    MIL << 
"file does not exist(or cannot be stat), no lock added." << endl;
 
 
  175  DBG << 
"apply locks" << endl;
 
 
  182  MIL << 
"add new lock" << endl;
 
  188  if ( 
_pimpl->toRemove.erase( query ) )
 
  190    DBG << 
"query removed from toRemove" << endl;
 
  194    DBG << 
"query added as new" << endl;
 
  195    _pimpl->toAdd.insert( query );
 
 
  217  DBG << 
"add lock by identifier" << endl;
 
 
  223  MIL << 
"remove lock" << endl;
 
  230  if ( 
_pimpl->toAdd.erase( query ) )
 
  232    DBG << 
"query removed from added" << endl;
 
  236    DBG << 
"need to remove some old lock" << endl;
 
  237    _pimpl->toRemove.insert( query );
 
 
  259  DBG << 
"remove lock by Selectable" << endl;
 
 
  301    switch (
report->execute(q))
 
  312      INT << 
"Unexpected return value from callback. Need to adapt switch statement." << std::endl;
 
 
 
  322  MIL << 
"clean of locks" << endl;
 
  325  size_t sum = 
_pimpl->locks().size();
 
  332    MIL << 
"cleaning aborted" << endl;
 
  341  if ( sum != 
_pimpl->locks().size() ) 
 
  342    _pimpl->locksDirty = 
true;
 
 
  356    bool intersect = 
false;
 
  359      if ( s.find(*it)!=s.end() )
 
  369    return intersect ? 1 : 0;
 
 
  383      DBG << 
"identical queries" << endl;
 
  401    MIL << 
"find conflict: " << cs << endl;
 
  402    switch (
report->conflict(q,cs))
 
  406      DBG << 
"abort merging" << endl;
 
  409      DBG << 
"force delete" << endl;
 
  412      DBG << 
"skip lock" << endl;
 
  415    INT << 
"Unexpected return value from callback. Need to adapt switch statement." << std::endl;
 
 
 
  424  MIL << 
"merge list old: " << 
locks().size()
 
  425    << 
" to add: " << 
toAdd.size() << 
" to remove: " << 
toRemove.size() << endl;
 
  428    std::set<sat::Solvable> s(it->begin(),it->end());
 
  432  if (!report->progress())
 
  435  for ( 
const auto & q : 
toAdd ) {
 
  437    if ( not 
b &&  i->comment() != q.comment() )
 
  438      i->setComment( q.comment() ); 
 
 
  449  if( (
_pimpl->toAdd.size() | 
_pimpl->toRemove.size())==0)
 
  456  if (!
_pimpl->mergeList(report))
 
  461  DBG << 
"locks merged" << endl;
 
  463  _pimpl->locksDirty = 
true;
 
 
  468  if( ((
_pimpl->toAdd.size() | 
_pimpl->toRemove.size())==0)
 
  471    DBG << 
"nothing changed in locks - no write to file" << endl;
 
  478  if ((
_pimpl->toAdd.size() | 
_pimpl->toRemove.size())!=0)
 
  480    if (!
_pimpl->mergeList(report))
 
  487  DBG << 
"wrote "<< 
_pimpl->locks().size() << 
"locks" << endl;
 
  488  writePoolQueriesToFile( file, 
_pimpl->locks().begin(), 
_pimpl->locks().end() );
 
 
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Access to the sat-pools string space.
std::string asString() const
Conversion to std::string
LocksCleanPredicate(size_t count, callback::SendReport< CleanEmptyLocksReport > &_report)
callback::SendReport< CleanEmptyLocksReport > & report
bool operator()(const PoolQuery &q)
LocksRemovePredicate(std::set< sat::Solvable > &s, const PoolQuery &q, callback::SendReport< SavingLocksReport > &r)
bool operator()(const PoolQuery &q)
callback::SendReport< SavingLocksReport > & report
std::set< sat::Solvable > & solvs
int contains(const PoolQuery &q, std::set< sat::Solvable > &s)
const LockSet & locks() const
bool mergeList(callback::SendReport< SavingLocksReport > &report)
const LockList & APIlocks() const
void removeEmpty()
Call callback for each empty lock.
void apply() const
Applies locks in stable list (locks which is not changed during session).
void merge()
Merges toAdd and ToRemove list to stable list.
void save(const Pathname &file=ZConfig::instance().locksFile())
Merges toAdd and ToRemove list to stable list and save that stable list to file.
const_iterator end() const
void addLock(const PoolQuery &query)
TODO add: toBeAdded{Begin,End,Size,Empty} toBeRemoved{Begin,End,Size,Empty}.
std::list< PoolQuery > LockList
void readAndApply(const Pathname &file=ZConfig::instance().locksFile())
Optimalized version of read and apply.
void removeDuplicates()
Delete all query duplicate in loaded locks.
const_iterator begin() const
LockList::size_type size() const
void removeLock(const PoolQuery &query)
unlocks by result of query and add to toRemove.
LockList::const_iterator const_iterator
bool existEmpty() const
Gets true if some lock doesn't lock any object in pool This can happen e.g.
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
static Locks & instance()
Gets instance of this class.
void read(const Pathname &file=ZConfig::instance().locksFile())
Read locks from file to list of stable locks (locks which is not changed during session)
Combining sat::Solvable and ResStatus.
ResStatus & status() const
Returns the current status.
void setMatchExact()
Set to match exact string instead of substring.
void setCaseSensitive(bool value=true)
Turn case sentitivity on or off (unsets or sets SEARCH_NOCASE flag).
bool empty() const
Whether the result is empty.
void addKind(const ResKind &kind)
Filter by selectable kind.
void addAttribute(const sat::SolvAttr &attr, const std::string &value="")
Filter by the value of the specified attr attribute.
const_iterator end() const
An iterator pointing to the end of the query result.
const_iterator begin() const
Query result accessers.
bool setLock(bool toLock_r, TransactByValue causer_r)
Apply a lock (prevent transaction).
Wrapper class for stat/lstat.
bool isExist() const
Return whether valid stat info exists.
static const SolvAttr name
Iterable< PoolItem_iterator > poolItem() const
Helper that splits an identifier into kind and name or vice versa.
Easy-to use interface to the ZYPP dependency resolver.
void remove_if(LockSet &lockset_r, TPredicate pred_r)
const ResKind ResTraits< Package >::kind(ResKind::package)
std::set< PoolQuery > LockSet
void operator()(const PoolQuery &query) const
@ ABORTED
cleaning aborted by user
@ ABORT
abort and return error
@ DELETE
delete empty lock
iterator that takes lock, lock all solvables from query and send query to output iterator
void operator()(const PoolQuery &query) const
LockingOutputIterator(OutputIterator &out_)
@ DELETE
delete conflicted lock
@ IGNORE
skip conflict lock
@ ABORT
abort and return error
ConflictState
type of conflict of old and new lock
@ INTERSECT
locks lock some file and unlocking lock unlock only part of iti, so removing old lock can unlock more...
@ SAME_RESULTS
locks lock same item in pool but its parameters are different
@ ABORTED
cleaning aborted by user
#define for_(IT, BEG, END)
Convenient for-loops using iterator.