Importance.cc

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* Importance.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 #include <iostream>
00022 #include "zypp/solver/detail/Importance.h"
00023 #include "zypp/base/Logger.h"
00024 
00026 namespace zypp
00027 { 
00028 
00029   namespace solver
00030   { 
00031 
00032     namespace detail
00033     { 
00034 
00035 using namespace std;
00036 
00037 const Importance Importance::Undefined (IMPORTANCE_UNDEFINED);
00038 const Importance Importance::Invalid (IMPORTANCE_INVALID);
00039 const Importance Importance::Necessary (IMPORTANCE_NECESSARY);
00040 const Importance Importance::Urgent (IMPORTANCE_URGENT);
00041 const Importance Importance::Suggested (IMPORTANCE_SUGGESTED);
00042 const Importance Importance::Feature (IMPORTANCE_FEATURE);
00043 const Importance Importance::Minor (IMPORTANCE_MINOR);
00044 
00045 //---------------------------------------------------------------------------
00046 string
00047 Importance::asString ( void ) const
00048 {
00049     return toString (*this);
00050 }
00051 
00052 
00053 string
00054 Importance::toString ( const Importance & importance )
00055 {
00056     string res;
00057 
00058     switch (importance.importance()) {
00059         case IMPORTANCE_UNDEFINED:      res = "undefined"; break;
00060         case IMPORTANCE_INVALID:        res = "invalid"; break;
00061         case IMPORTANCE_NECESSARY:      res = "necessary"; break;
00062         case IMPORTANCE_URGENT:         res = "urgent"; break;
00063         case IMPORTANCE_SUGGESTED:      res = "suggested"; break;
00064         case IMPORTANCE_FEATURE:        res = "feature"; break;
00065         case IMPORTANCE_MINOR:          res = "minor"; break;
00066         default:
00067             WAR << "invalid importance "<< importance.importance() << endl;
00068             res = "invalid";
00069     }
00070     return res;
00071 }
00072 
00073 
00074 ostream &
00075 Importance::dumpOn( ostream & str ) const
00076 {
00077     str << asString();
00078     return str;
00079 }
00080 
00081 
00082 ostream&
00083 operator<<( ostream& os, const Importance& importance)
00084 {
00085     return os << importance.asString();
00086 }
00087 
00088 //---------------------------------------------------------------------------
00089 
00090 const Importance
00091 Importance::parse(const string & str)
00092 {
00093     Importance importance = Invalid;
00094     if (str == "feature") {
00095         importance = Feature;
00096     }
00097     else if (str == "minor") {
00098         importance = Minor;
00099     }
00100     else if (str == "necessary") {
00101         importance = Necessary;
00102     }
00103     if (str == "suggested") {
00104         importance = Suggested;
00105     }
00106     if (str == "urgent") {
00107         importance = Urgent;
00108     }
00109     else if (str == "undefined") {
00110         importance = Undefined;
00111     }
00112 
00113     if (importance == Invalid)
00114         WAR << "invalid importance '" << str << "'" << endl;
00115 
00116     return importance;
00117 }
00118 
00119 
00120 Importance::Importance(importance_t importance)
00121     : _importance (importance)
00122 {
00123 }
00124 
00125 Importance::~Importance()
00126 {
00127 }
00128 
00130     };// namespace detail
00133   };// namespace solver
00136 };// namespace zypp
00138 
00139 

Generated on Thu Jul 6 00:07:22 2006 for zypp by  doxygen 1.4.6