libzypp 17.37.17
ResStatus.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13//#include <zypp/base/Logger.h>
14
15#include <zypp/ResStatus.h>
16
17using std::endl;
18
20namespace zypp
21{
22
23 const ResStatus ResStatus::toBeInstalled (UNINSTALLED, UNDETERMINED, TRANSACT);
24 const ResStatus ResStatus::toBeUninstalled (INSTALLED, UNDETERMINED, TRANSACT);
25 const ResStatus ResStatus::toBeUninstalledDueToUpgrade (INSTALLED, UNDETERMINED, TRANSACT, EXPLICIT_INSTALL, DUE_TO_UPGRADE);
26 const ResStatus ResStatus::toBeUninstalledDueToObsolete(INSTALLED, UNDETERMINED, TRANSACT, EXPLICIT_INSTALL, DUE_TO_OBSOLETE);
27
29 //
30 // METHOD NAME : ResStatus::ResStatus
31 // METHOD TYPE : Ctor
32 //
35
37 //
38 // METHOD NAME : ResStatus::ResStatus
39 // METHOD TYPE : Ctor
40 //
41 ResStatus::ResStatus( bool isInstalled_r )
42 : _bitfield( isInstalled_r ? INSTALLED : UNINSTALLED )
43 {}
44
46 //
47 // METHOD NAME : ResStatus::~ResStatus
48 // METHOD TYPE : Dtor
49 //
52
53
64
65 namespace
66 {
67 // NOTE: Strings defined here are written to the history file
68 // and used by zypper. Do not change them!
69 static const char* strBROKEN = "needed";
70 static const char* strSATISFIED = "applied";
71 static const char* strNONRELEVANT = "not-needed";
72 static const char* strUNDETERMINED = "undetermined";
73 }
74
76 {
77 const char* ret = strUNDETERMINED;
78 switch ( val_r )
79 {
80 case BROKEN: ret = strBROKEN; break;
81 case SATISFIED: ret = strSATISFIED; break;
82 case NONRELEVANT: ret = strNONRELEVANT; break;
83 case UNDETERMINED:break;// to avoid default:
84 }
85 return ret;
86 }
87
89 {
91 if ( str_r == strBROKEN ) ret = BROKEN;
92 else if ( str_r == strSATISFIED ) ret = SATISFIED;
93 else if ( str_r == strNONRELEVANT ) ret = NONRELEVANT;
94 return ret;
95 }
96
97 /******************************************************************
98 **
99 ** FUNCTION NAME : operator<<
100 ** FUNCTION TYPE : std::ostream &
101 */
102 std::ostream & operator<<( std::ostream & str, const ResStatus & obj )
103 {
104 str << (obj.isInstalled() ? "I" : "U");
105
106 str << (obj.isBroken() ? "B" :
107 ( obj.isSatisfied() ? "S" :
108 ( obj.isNonRelevant() ? "N" : "_") ) );
109
110 str << (obj.transacts () ? "T"
111 : (obj.isLocked() ? "L" : "_") );
112
113 if (obj.isBySolver()) str << "s";
114 else if (obj.isByApplLow()) str << "l";
115 else if (obj.isByApplHigh()) str << "h";
116 else if (obj.isByUser()) str << "u";
117
118 str << (obj.isToBeUninstalledDueToObsolete() ? "O" :
119 ( obj.isToBeUninstalledDueToUpgrade() ? "U" :
120 ( obj.isToBeInstalledSoft() ? "S" : "_" ) ) );
121
122 str << (obj.isRecommended() ? "r" : "" );
123 str << (obj.isSuggested() ? "s" : "" );
124 str << (obj.isOrphaned() ? "o" : "" );
125 str << (obj.isUnneeded() ? "u" : "" );
126
127 return str;
128 }
129
130
131#define OUTS(X) case ResStatus::X: return str << #X; break
132
133 std::ostream & operator<<( std::ostream & str, ResStatus::TransactValue obj )
134 {
135 switch ( obj )
136 {
137 OUTS( KEEP_STATE );
138 OUTS( LOCKED );
139 OUTS( TRANSACT );
140 }
141 return str;
142 }
143
144 std::ostream & operator<<( std::ostream & str, ResStatus::TransactByValue obj )
145 {
146 switch ( obj )
147 {
148 OUTS( SOLVER );
149 OUTS( APPL_LOW );
150 OUTS( APPL_HIGH );
151 OUTS( USER );
152 }
153 return str;
154 }
155
157} // namespace zypp
#define OUTS(V)
Status bitfield.
Definition ResStatus.h:55
BitFieldType _bitfield
Definition ResStatus.h:705
static const ResStatus toBeInstalled
Definition ResStatus.h:667
bool isToBeInstalledSoft() const
Definition ResStatus.h:327
~ResStatus()
Dtor.
Definition ResStatus.cc:50
static const ResStatus toBeUninstalledDueToObsolete
Definition ResStatus.h:670
bool isSuggested() const
Definition ResStatus.h:191
bool isByApplLow() const
Definition ResStatus.h:299
static ValidateValue stringToValidateValue(const std::string &str_r)
ValidateValue from string used in the history file.
Definition ResStatus.cc:88
bool isBroken() const
Definition ResStatus.h:228
bool isByApplHigh() const
Definition ResStatus.h:302
bool isNonRelevant() const
Definition ResStatus.h:231
bool isLocked() const
Definition ResStatus.h:270
static const ResStatus toBeUninstalledDueToUpgrade
Definition ResStatus.h:669
bool isToBeUninstalledDueToObsolete() const
Definition ResStatus.h:321
bool isByUser() const
Definition ResStatus.h:305
static const ResStatus toBeUninstalled
Definition ResStatus.h:668
bool transacts() const
Definition ResStatus.h:282
ResStatus()
Default ctor.
Definition ResStatus.cc:33
bool isRecommended() const
Definition ResStatus.h:188
bool isInstalled() const
Definition ResStatus.h:246
bool isOrphaned() const
Definition ResStatus.h:194
std::string validateValueAsString() const
Definition ResStatus.h:234
bool isToBeUninstalledDueToUpgrade() const
Definition ResStatus.h:324
bool isSatisfied() const
Definition ResStatus.h:225
bool isBySolver() const
Definition ResStatus.h:296
bool isUnneeded() const
Definition ResStatus.h:197
void fieldValueAssign(FieldType val_r)
Set the corresponding Field to value val_r.
Definition ResStatus.h:690
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)