libzypp  17.23.5
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 
17 using std::endl;
18 
20 namespace 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
zypp::ResStatus::isBySolver
bool isBySolver() const
Definition: ResStatus.h:290
zypp::ResStatus::isUnneeded
bool isUnneeded() const
Definition: ResStatus.h:191
zypp::ResStatus::isByApplHigh
bool isByApplHigh() const
Definition: ResStatus.h:296
zypp::ResStatus::INSTALLED
Definition: ResStatus.h:91
zypp::ResStatus::isNonRelevant
bool isNonRelevant() const
Definition: ResStatus.h:225
zypp::ResStatus::isInstalled
bool isInstalled() const
Definition: ResStatus.h:240
zypp::ResStatus::ValidateValue
ValidateValue
Definition: ResStatus.h:93
zypp::ResStatus::toBeInstalled
static const ResStatus toBeInstalled
Definition: ResStatus.h:662
OUTS
#define OUTS(X)
Definition: ResStatus.cc:130
zypp::ResStatus::SATISFIED
Definition: ResStatus.h:97
zypp::ResStatus::StateValue
StateValue
Definition: ResStatus.h:88
zypp::ResStatus::TransactByValue
TransactByValue
Definition: ResStatus.h:106
zypp::ResStatus::isBroken
bool isBroken() const
Definition: ResStatus.h:222
zypp::ResStatus::isToBeUninstalledDueToObsolete
bool isToBeUninstalledDueToObsolete() const
Definition: ResStatus.h:315
zypp::ResStatus::validateValueAsString
std::string validateValueAsString() const
Definition: ResStatus.h:228
zypp::ResStatus::isRecommended
bool isRecommended() const
Definition: ResStatus.h:182
zypp::ResStatus::TransactValue
TransactValue
Definition: ResStatus.h:100
zypp::ResStatus::NONRELEVANT
Definition: ResStatus.h:98
zypp::ResStatus::toBeUninstalledDueToUpgrade
static const ResStatus toBeUninstalledDueToUpgrade
Definition: ResStatus.h:664
zypp::ResStatus::TRANSACT
Definition: ResStatus.h:104
zypp::ResStatus::toBeUninstalledDueToObsolete
static const ResStatus toBeUninstalledDueToObsolete
Definition: ResStatus.h:665
zypp::ResStatus::isSatisfied
bool isSatisfied() const
Definition: ResStatus.h:219
zypp::ResStatus::InstallDetailValue
InstallDetailValue
Definition: ResStatus.h:119
zypp::ResStatus::RemoveDetailValue
RemoveDetailValue
Definition: ResStatus.h:124
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::ResStatus::isOrphaned
bool isOrphaned() const
Definition: ResStatus.h:188
zypp::ResStatus::~ResStatus
~ResStatus()
Dtor.
Definition: ResStatus.cc:50
zypp::ResStatus::isSuggested
bool isSuggested() const
Definition: ResStatus.h:185
zypp::ResStatus::isByApplLow
bool isByApplLow() const
Definition: ResStatus.h:293
zypp::ResStatus::isByUser
bool isByUser() const
Definition: ResStatus.h:299
zypp::ResStatus::isToBeInstalledSoft
bool isToBeInstalledSoft() const
Definition: ResStatus.h:321
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
zypp::ResStatus
Status bitfield.
Definition: ResStatus.h:53
zypp::ResStatus::isLocked
bool isLocked() const
Definition: ResStatus.h:264
zypp::ResStatus::UNDETERMINED
Definition: ResStatus.h:95
zypp::ResStatus::BROKEN
Definition: ResStatus.h:96
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::toBeUninstalled
static const ResStatus toBeUninstalled
Definition: ResStatus.h:663
str
String related utilities and Regular expression matching.
zypp::ResStatus::isToBeUninstalledDueToUpgrade
bool isToBeUninstalledDueToUpgrade() const
Definition: ResStatus.h:318
zypp::ResStatus::ResStatus
ResStatus()
Default ctor.
Definition: ResStatus.cc:33
zypp::ResStatus::transacts
bool transacts() const
Definition: ResStatus.h:276
ResStatus.h