ResolverInfoNeededBy.cc

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* ResolverInfoNeededBy.cc
00003  *
00004  * Copyright (C) 2000-2002 Ximian, Inc.
00005  * Copyright (C) 2005 SUSE Linux Products GmbH
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License,
00009  * version 2, as published by the Free Software Foundation.
00010  *
00011  * This program is distributed in the hope that it will be useful, but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019  * 02111-1307, USA.
00020  */
00021 
00022 #include <map>
00023 #include <sstream>
00024 
00025 #include "zypp/solver/detail/ResolverInfo.h"
00026 #include "zypp/solver/detail/ResolverInfoNeededBy.h"
00027 #include "zypp/base/String.h"
00028 #include "zypp/base/Gettext.h"
00029 #include "zypp/Dep.h"
00030 
00032 namespace zypp 
00033 { 
00034 
00035   namespace solver
00036   { 
00037 
00038     namespace detail
00039     { 
00040 
00041 using namespace std;
00042 
00043 IMPL_PTR_TYPE(ResolverInfoNeededBy);
00044 
00045 //---------------------------------------------------------------------------
00046 
00047 
00048 std::ostream &
00049 ResolverInfoNeededBy::dumpOn( std::ostream & os ) const
00050 {
00051     ResolverInfo::dumpOn (os);
00052 
00053     ostringstream affected_str;
00054     affected_str << ResolverInfo::toString (affected());
00055 
00056     switch ( _capKind.inSwitch() )
00057     {
00058         case Dep::RECOMMENDS_e:
00059             // Translator: all.%s = name of package,patch,...
00060             os << str::form (_("%s is recommended by %s"),
00061                              affected_str.str().c_str(),
00062                              itemsToString(true).c_str());
00063             break;
00064         case Dep::SUGGESTS_e:
00065             // Translator: all.%s = name of package,patch,...
00066             os << str::form (_("%s is suggested by %s"),
00067                              affected_str.str().c_str(),
00068                              itemsToString(true).c_str());
00069             break;
00070         case Dep::FRESHENS_e:
00071             // Translator: all.%s = name of package,patch,...
00072             os << str::form (_("%s will be evaluated for installation (freshened) by %s"),
00073                              affected_str.str().c_str(),
00074                              itemsToString(true).c_str());
00075             break;
00076         case Dep::ENHANCES_e:
00077             // Translator: all.%s = name of package,patch,...
00078             os << str::form (_("%s is enhanced by %s"),
00079                              affected_str.str().c_str(),
00080                              itemsToString(true).c_str());
00081             break;
00082         case Dep::SUPPLEMENTS_e:
00083             // Translator: all.%s = name of package,patch,...
00084             os << str::form (_("%s is supplemented by %s"),
00085                              affected_str.str().c_str(),
00086                              itemsToString(true).c_str());
00087             break;                                  
00088         default:
00089             // Translator: all.%s = name of package,patch,...
00090             os << str::form (_("%s is needed by %s"),
00091                              affected_str.str().c_str(),
00092                              itemsToString(true).c_str());
00093     }
00094     if (_cap != Capability::noCap)
00095         os << " (" << _cap << ")";
00096 
00097     return os;
00098 }
00099 
00100 string
00101 ResolverInfoNeededBy::message( ) const
00102 {
00103     string affected_str = ResolverInfo::toString(affected());
00104     string ret;
00105     
00106     switch ( _capKind.inSwitch() )
00107     {
00108         case Dep::RECOMMENDS_e:
00109             // Translator: all.%s = name of package,patch,...
00110             ret = str::form (_("%s is recommended by %s"),
00111                              affected_str.c_str(),
00112                              itemsToString(false).c_str());
00113             break;
00114         case Dep::SUGGESTS_e:
00115             // Translator: all.%s = name of package,patch,...
00116             ret = str::form (_("%s is suggested by %s"),
00117                              affected_str.c_str(),
00118                              itemsToString(false).c_str());
00119             break;
00120         case Dep::FRESHENS_e:
00121             // Translator: all.%s = name of package,patch,...
00122             ret = str::form (_("%s will be evaluated for installation (freshened) by %s"),
00123                              affected_str.c_str(),
00124                              itemsToString(false).c_str());
00125             break;
00126         case Dep::ENHANCES_e:
00127             // Translator: all.%s = name of package,patch,...
00128             ret = str::form (_("%s is enhanced by %s"),
00129                              affected_str.c_str(),
00130                              itemsToString(false).c_str());
00131             break;
00132         case Dep::SUPPLEMENTS_e:
00133             // Translator: all.%s = name of package,patch,...
00134             ret = str::form (_("%s is supplemented by %s"),
00135                              affected_str.c_str(),
00136                              itemsToString(false).c_str());
00137             break;                                  
00138         default:
00139             // Translator: all.%s = name of package,patch,...
00140             ret = str::form (_("%s is needed by %s"),
00141                              affected_str.c_str(),
00142                              itemsToString(false).c_str());
00143     }
00144     if (_cap != Capability::noCap)
00145         ret += " (" + _cap.asString() + ")";
00146 
00147     return ret;
00148 }
00149 
00150 //---------------------------------------------------------------------------
00151 
00152 ResolverInfoNeededBy::ResolverInfoNeededBy (PoolItem_Ref item)
00153     : ResolverInfoContainer (RESOLVER_INFO_TYPE_NEEDED_BY, item, RESOLVER_INFO_PRIORITY_USER)
00154     , _cap(Capability::noCap)
00155     , _capKind(Dep::REQUIRES)
00156     , _initialInstallation(false)
00157 {
00158 }
00159 
00160 
00161 ResolverInfoNeededBy::~ResolverInfoNeededBy ()
00162 {
00163 }
00164 
00165 //---------------------------------------------------------------------------
00166 
00167 ResolverInfo_Ptr
00168 ResolverInfoNeededBy::copy (void) const
00169 {
00170     ResolverInfoNeededBy_Ptr cpy = new ResolverInfoNeededBy(affected());
00171 
00172     ((ResolverInfoContainer_Ptr)cpy)->copy (this);
00173 
00174     return cpy;
00175 }
00176 
00178     };// namespace detail
00181   };// namespace solver
00184 };// namespace zypp
00186 

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