00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 };
00133 };
00136 };
00138
00139