ProblemSolutionUnlock.cc

Go to the documentation of this file.
00001 
00002 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00003 /* ProblemSolution.cc
00004  *
00005  * Easy-to use interface to the ZYPP dependency resolver
00006  *
00007  * Copyright (C) 2000-2002 Ximian, Inc.
00008  * Copyright (C) 2005 SUSE Linux Products GmbH
00009  *
00010  * This program is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU General Public License,
00012  * version 2, as published by the Free Software Foundation.
00013  *
00014  * This program is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00022  * 02111-1307, USA.
00023  */
00024 
00025 #include <sstream>
00026 
00027 #include "zypp/base/String.h"
00028 #include "zypp/base/Gettext.h"
00029 #include "zypp/base/Algorithm.h"
00030 #include "zypp/ResPool.h"
00031 #include "zypp/ResFilters.h"
00032 #include "zypp/CapFilters.h"
00033 #include "zypp/solver/detail/ProblemSolutionUnlock.h"
00034 
00035 using namespace std;
00036 
00038 namespace zypp
00039 { 
00040 
00041   namespace solver
00042   { 
00043 
00044     namespace detail
00045     { 
00046 
00047 IMPL_PTR_TYPE(ProblemSolutionUnlock);
00048 
00049 //---------------------------------------------------------------------------
00050 
00051 struct LockReset : public resfilter::PoolItemFilterFunctor
00052 {
00053     ProblemSolutionUnlock & _problemSolutionUnlock;
00054     LockReset( ProblemSolutionUnlock & solution )
00055         : _problemSolutionUnlock( solution )
00056     { }
00057 
00058     bool operator()( PoolItem_Ref item )
00059     {
00060         _problemSolutionUnlock.addAction ( new TransactionSolutionAction (item, UNLOCK));       
00061         return true;
00062     }
00063 };
00064 
00065         
00066 ProblemSolutionUnlock::ProblemSolutionUnlock( ResolverProblem_Ptr parent,
00067                                               const ResPool & pool)
00068     : ProblemSolution (parent, "", "")
00069 {
00070     _description = _("unlock all resolvables");
00071     LockReset lockReset (*this);
00072 
00073     invokeOnEach ( pool.begin(), pool.end(),
00074                    resfilter::ByLock( ),
00075                    functor::functorRef<bool,PoolItem>(lockReset));
00076 }
00077         
00078 ProblemSolutionUnlock::ProblemSolutionUnlock( ResolverProblem_Ptr parent,
00079                                               PoolItem_Ref item)
00080     : ProblemSolution (parent, "", "")
00081 {
00082     // TranslatorExplanation %s = name of package, patch, selection ... 
00083     _description = str::form (_("unlock %s"), item->name().c_str() );
00084 
00085     addAction ( new TransactionSolutionAction (item, UNLOCK));
00086 }
00087 
00088 ProblemSolutionUnlock::ProblemSolutionUnlock( ResolverProblem_Ptr parent,
00089                                               PoolItemList & itemlist)
00090     : ProblemSolution (parent, "", "")
00091 {
00092     _description = _("Unlock these resolvables");
00093 
00094     for (PoolItemList::iterator iter = itemlist.begin();
00095          iter != itemlist.end(); iter++) {
00096         PoolItem item = *iter;
00097         addAction ( new TransactionSolutionAction (item, UNLOCK));
00098     }
00099     
00100     ostringstream details;
00101     details << _actions;    
00102     _details = details.str();
00103 }
00104 
00106     };// namespace detail
00109   };// namespace solver
00112 };// namespace zypp

Generated on Tue Sep 25 19:23:07 2007 for libzypp by  doxygen 1.5.3