libzypp 17.31.23
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 //
34 {}
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 //
51 {}
52
53
55 : _bitfield (s)
56 {
57 fieldValueAssign<ValidateField>(v);
58 fieldValueAssign<TransactField>(t);
59 if (t == TRANSACT) {
60 if (s == INSTALLED) fieldValueAssign<TransactDetailField>(r);
61 else fieldValueAssign<TransactDetailField>(i);
62 }
63 }
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:54
static const ResStatus toBeInstalled
Definition: ResStatus.h:661
bool isToBeInstalledSoft() const
Definition: ResStatus.h:321
~ResStatus()
Dtor.
Definition: ResStatus.cc:50
static const ResStatus toBeUninstalledDueToObsolete
Definition: ResStatus.h:664
bool isSuggested() const
Definition: ResStatus.h:185
bool isByApplLow() const
Definition: ResStatus.h:293
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:222
bool isByApplHigh() const
Definition: ResStatus.h:296
bool isNonRelevant() const
Definition: ResStatus.h:225
bool isLocked() const
Definition: ResStatus.h:264
static const ResStatus toBeUninstalledDueToUpgrade
Definition: ResStatus.h:663
bool isToBeUninstalledDueToObsolete() const
Definition: ResStatus.h:315
bool isByUser() const
Definition: ResStatus.h:299
static const ResStatus toBeUninstalled
Definition: ResStatus.h:662
bool transacts() const
Definition: ResStatus.h:276
ResStatus()
Default ctor.
Definition: ResStatus.cc:33
bool isRecommended() const
Definition: ResStatus.h:182
bool isInstalled() const
Definition: ResStatus.h:240
bool isOrphaned() const
Definition: ResStatus.h:188
std::string validateValueAsString() const
Definition: ResStatus.h:228
bool isToBeUninstalledDueToUpgrade() const
Definition: ResStatus.h:318
bool isSatisfied() const
Definition: ResStatus.h:219
bool isBySolver() const
Definition: ResStatus.h:290
bool isUnneeded() const
Definition: ResStatus.h:191
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52