libzypp  13.10.6
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 
66  /******************************************************************
67  **
68  ** FUNCTION NAME : operator<<
69  ** FUNCTION TYPE : std::ostream &
70  */
71  std::ostream & operator<<( std::ostream & str, const ResStatus & obj )
72  {
73  str << (obj.isInstalled() ? "I" : "U");
74 
75  str << (obj.isBroken() ? "B" :
76  ( obj.isSatisfied() ? "S" :
77  ( obj.isNonRelevant() ? "N" : "_") ) );
78 
79  str << (obj.transacts () ? "T"
80  : (obj.isLocked() ? "L" : "_") );
81 
82  if (obj.isBySolver()) str << "s";
83  else if (obj.isByApplLow()) str << "l";
84  else if (obj.isByApplHigh()) str << "h";
85  else if (obj.isByUser()) str << "u";
86 
87  str << (obj.isToBeUninstalledDueToObsolete() ? "O" :
88  ( obj.isToBeUninstalledDueToUpgrade() ? "U" :
89  ( obj.isToBeInstalledSoft() ? "S" : "_" ) ) );
90 
91  str << (obj.isRecommended() ? "r" : "" );
92  str << (obj.isSuggested() ? "s" : "" );
93  str << (obj.isOrphaned() ? "o" : "" );
94  str << (obj.isUnneeded() ? "u" : "" );
95 
96  return str;
97  }
98 
99 
100 #define OUTS(X) case ResStatus::X: return str << #X; break
101 
102  std::ostream & operator<<( std::ostream & str, ResStatus::TransactValue obj )
103  {
104  switch ( obj )
105  {
106  OUTS( KEEP_STATE );
107  OUTS( LOCKED );
108  OUTS( TRANSACT );
109  }
110  return str;
111  }
112 
113  std::ostream & operator<<( std::ostream & str, ResStatus::TransactByValue obj )
114  {
115  switch ( obj )
116  {
117  OUTS( SOLVER );
118  OUTS( APPL_LOW );
119  OUTS( APPL_HIGH );
120  OUTS( USER );
121  }
122  return str;
123  }
124 
126 } // namespace zypp
bool isByApplLow() const
Definition: ResStatus.h:281
bool isSuggested() const
Definition: ResStatus.h:185
bool transacts() const
Definition: ResStatus.h:264
bool isToBeUninstalledDueToUpgrade() const
Definition: ResStatus.h:306
bool isNonRelevant() const
Definition: ResStatus.h:222
bool isUnneeded() const
Definition: ResStatus.h:191
bool isToBeInstalledSoft() const
Definition: ResStatus.h:309
static const ResStatus toBeInstalled
Definition: ResStatus.h:650
bool isLocked() const
Definition: ResStatus.h:252
bool isSatisfied() const
Definition: ResStatus.h:216
bool isInstalled() const
Definition: ResStatus.h:228
static const ResStatus toBeUninstalledDueToUpgrade
Definition: ResStatus.h:652
bool isByUser() const
Definition: ResStatus.h:287
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
static const ResStatus toBeUninstalledDueToObsolete
Definition: ResStatus.h:653
bool isByApplHigh() const
Definition: ResStatus.h:284
~ResStatus()
Dtor.
Definition: ResStatus.cc:50
bool isBroken() const
Definition: ResStatus.h:219
bool isToBeUninstalledDueToObsolete() const
Definition: ResStatus.h:303
Status bitfield.
Definition: ResStatus.h:53
bool isOrphaned() const
Definition: ResStatus.h:188
bool isBySolver() const
Definition: ResStatus.h:278
ResStatus()
Default ctor.
Definition: ResStatus.cc:33
static const ResStatus toBeUninstalled
Definition: ResStatus.h:651
#define OUTS(X)
Definition: ResStatus.cc:100
bool isRecommended() const
Definition: ResStatus.h:182