libzypp: zypp/ResStatus.cc Source File

libzypp 17.38.14

ResStatus.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13//#include <zypp-core/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 //
33 ResStatus::ResStatus()
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 //
50 ResStatus::~ResStatus()
51 {}
52
53
54 ResStatus::ResStatus (enum StateValue s, enum ValidateValue v, enum TransactValue t, enum InstallDetailValue i, enum RemoveDetailValue r)
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
75 std::string ResStatus::validateValueAsString( ValidateValue val_r )
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
88 ResStatus::ValidateValue ResStatus::stringToValidateValue( const std::string & str_r )
89 {
90 ValidateValue ret = UNDETERMINED;
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
OUTS
#define OUTS(VAL)
ResStatus.h
zypp::ResStatus
Status bitfield.
Definition ResStatus.h:55
zypp::ResStatus::_bitfield
BitFieldType _bitfield
Definition ResStatus.h:705
zypp::ResStatus::toBeInstalled
static const ResStatus toBeInstalled
Definition ResStatus.h:667
zypp::ResStatus::isToBeInstalledSoft
bool isToBeInstalledSoft() const
Definition ResStatus.h:327
zypp::ResStatus::~ResStatus
~ResStatus()
Dtor.
Definition ResStatus.cc:50
zypp::ResStatus::toBeUninstalledDueToObsolete
static const ResStatus toBeUninstalledDueToObsolete
Definition ResStatus.h:670
zypp::ResStatus::isSuggested
bool isSuggested() const
Definition ResStatus.h:191
zypp::ResStatus::isByApplLow
bool isByApplLow() const
Definition ResStatus.h:299
zypp::ResStatus::stringToValidateValue
static ValidateValue stringToValidateValue(const std::string &str_r)
ValidateValue from string used in the history file.
Definition ResStatus.cc:88
zypp::ResStatus::operator<<
friend std::ostream & operator<<(std::ostream &str, const ResStatus &obj)
relates: ResStatus Stream output
Definition ResStatus.cc:102
zypp::ResStatus::isBroken
bool isBroken() const
Definition ResStatus.h:228
zypp::ResStatus::isByApplHigh
bool isByApplHigh() const
Definition ResStatus.h:302
zypp::ResStatus::isNonRelevant
bool isNonRelevant() const
Definition ResStatus.h:231
zypp::ResStatus::isLocked
bool isLocked() const
Definition ResStatus.h:270
zypp::ResStatus::ValidateValue
ValidateValue
Definition ResStatus.h:95
zypp::ResStatus::NONRELEVANT
@ NONRELEVANT
Definition ResStatus.h:99
zypp::ResStatus::SATISFIED
@ SATISFIED
Definition ResStatus.h:98
zypp::ResStatus::UNDETERMINED
@ UNDETERMINED
Definition ResStatus.h:96
zypp::ResStatus::BROKEN
@ BROKEN
Definition ResStatus.h:97
zypp::ResStatus::toBeUninstalledDueToUpgrade
static const ResStatus toBeUninstalledDueToUpgrade
Definition ResStatus.h:669
zypp::ResStatus::InstallDetailValue
InstallDetailValue
Definition ResStatus.h:121
zypp::ResStatus::TransactByValue
TransactByValue
Definition ResStatus.h:108
zypp::ResStatus::isToBeUninstalledDueToObsolete
bool isToBeUninstalledDueToObsolete() const
Definition ResStatus.h:321
zypp::ResStatus::isByUser
bool isByUser() const
Definition ResStatus.h:305
zypp::ResStatus::toBeUninstalled
static const ResStatus toBeUninstalled
Definition ResStatus.h:668
zypp::ResStatus::transacts
bool transacts() const
Definition ResStatus.h:282
zypp::ResStatus::ResStatus
ResStatus()
Default ctor.
Definition ResStatus.cc:33
zypp::ResStatus::isRecommended
bool isRecommended() const
Definition ResStatus.h:188
zypp::ResStatus::isInstalled
bool isInstalled() const
Definition ResStatus.h:246
zypp::ResStatus::isOrphaned
bool isOrphaned() const
Definition ResStatus.h:194
zypp::ResStatus::validateValueAsString
std::string validateValueAsString() const
Definition ResStatus.h:234
zypp::ResStatus::isToBeUninstalledDueToUpgrade
bool isToBeUninstalledDueToUpgrade() const
Definition ResStatus.h:324
zypp::ResStatus::StateValue
StateValue
Definition ResStatus.h:90
zypp::ResStatus::UNINSTALLED
@ UNINSTALLED
Definition ResStatus.h:91
zypp::ResStatus::INSTALLED
@ INSTALLED
Definition ResStatus.h:92
zypp::ResStatus::RemoveDetailValue
RemoveDetailValue
Definition ResStatus.h:126
zypp::ResStatus::isSatisfied
bool isSatisfied() const
Definition ResStatus.h:225
zypp::ResStatus::isBySolver
bool isBySolver() const
Definition ResStatus.h:296
zypp::ResStatus::isUnneeded
bool isUnneeded() const
Definition ResStatus.h:197
zypp::ResStatus::fieldValueAssign
void fieldValueAssign(FieldType val_r)
Set the corresponding Field to value val_r.
Definition ResStatus.h:690
zypp::ResStatus::TransactValue
TransactValue
Definition ResStatus.h:102
zypp::ResStatus::TRANSACT
@ TRANSACT
Definition ResStatus.h:105
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Definition Capabilities.cc:65