libzypp  10.5.0
ProblemSolutionCombi.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 
00030 #include "zypp/solver/detail/ProblemSolutionCombi.h"
00031 
00032 using namespace std;
00033 
00035 namespace zypp
00036 { 
00037 
00038   namespace solver
00039   { 
00040 
00041     namespace detail
00042     { 
00043 
00044 IMPL_PTR_TYPE(ProblemSolutionCombi);
00045 
00046 //---------------------------------------------------------------------------
00047 
00048 ProblemSolutionCombi::ProblemSolutionCombi( ResolverProblem_Ptr parent)
00049     : ProblemSolution (parent, "", "")
00050       , actNumber(0)
00051 {
00052     _description = "";
00053     _details = "";
00054 }
00055 
00056 void ProblemSolutionCombi::addSingleAction( Capability capability, const TransactionKind action)
00057 {
00058     addAction (new TransactionSolutionAction(capability, action));
00059     actNumber++;
00060 }
00061 
00062 void ProblemSolutionCombi::addSingleAction( PoolItem item, const TransactionKind action)
00063 {
00064     addAction (new TransactionSolutionAction(item, action));
00065     actNumber++;
00066 }
00067 
00068 void ProblemSolutionCombi::addSingleAction( SolverQueueItem_Ptr item, const TransactionKind action)
00069 {
00070     addAction (new TransactionSolutionAction(item, action));
00071     actNumber++;
00072 }
00073 
00074 void ProblemSolutionCombi::addDescription( const std::string description)
00075 {
00076     if ( _description.size() == 0
00077          && _details.size() == 0) {
00078          // first entry
00079         _description = description;
00080     } else {
00081         if ( _description.size() > 0
00082              && _details.size() == 0) {
00083             // second entry
00084             _details = _description;
00085             _description = _("Following actions will be done:");
00086         }
00087         // all other
00088         _details += "\n";
00089         _details += description;
00090     }
00091 }
00092 
00093 void ProblemSolutionCombi::addFrontDescription( const std::string & description )
00094 {
00095     if ( _description.size() == 0
00096          && _details.size() == 0) {
00097          // first entry
00098         _description = description;
00099     } else {
00100         if ( _description.size() > 0
00101              && _details.size() == 0) {
00102             // second entry
00103             _details = _description;
00104             _description = _("Following actions will be done:");
00105         }
00106         // all other
00107         std::string tmp( _details );
00108         _details = description;
00109         _details += "\n";
00110         _details += tmp;
00111     }
00112 }
00113 
00115     };// namespace detail
00118   };// namespace solver
00121 };// namespace zypp