Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / ResStatus.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ResStatus.h
10  *
11 */
12 #ifndef ZYPP_RESSTATUS_H
13 #define ZYPP_RESSTATUS_H
14
15 #include <inttypes.h>
16 #include <iosfwd>
17 #include "zypp/Bit.h"
18
19 ///////////////////////////////////////////////////////////////////
20 namespace zypp
21 { /////////////////////////////////////////////////////////////////
22
23   namespace resstatus
24   {
25     class UserLockQueryManip;
26     class StatusBackup;
27   }
28
29   ///////////////////////////////////////////////////////////////////
30   //
31   //    CLASS NAME : ResStatus
32   //
33   /** Status bitfield.
34    *
35    * \li \c StateField Whether the resolvable is or uninstalled (available).
36    * \li \c ValidateField Validate status computed by the solver as
37    *        nonrelevant: it is unimportant for the user
38    *        satisfied: it important nothing has to be done
39    *        broken: it is incomplete. So e.g. an update is needed
40    * \li \c TransactField Whether to transact this resolvable
41    *        (delete if installed install if uninstalled).
42    *        In case the resolvable is locked, only USER may modify the
43    *        transact bit.
44    * \li \c TransactByField Who triggered the transaction. Transaction
45    *        bit may be reset by higer levels only.
46    * \li \c TransactDetailField Reason why the Resolvable transacts.
47    *        Splitted into \c InstallDetailValue and \c RemoveDetailValue
48    *        dependent on the kind of transaction.
49    * \li \c WeakField The solvable will be recommended/suggested by
50    *        a to be installed/deleted solvable.
51    *
52   */
53   class ResStatus
54   {
55     friend std::ostream & operator<<( std::ostream & str, const ResStatus & obj );
56     friend bool operator==( const ResStatus & lhs, const ResStatus & rhs );
57
58   public:
59     /** \name BitField range definitions.
60      *
61      * \note Enlarge FieldType if more bit's needed. It's not yet
62      * checked by the compiler.
63      */
64     //@{
65     typedef uint16_t FieldType;
66     typedef bit::BitField<FieldType> BitFieldType;
67     // Bit Ranges within FieldType defined by 1st bit and size:
68     typedef bit::Range<FieldType,0,                          1> StateField;
69     typedef bit::Range<FieldType,StateField::end,            2> ValidateField;
70     typedef bit::Range<FieldType,ValidateField::end,         2> TransactField;
71     typedef bit::Range<FieldType,TransactField::end,         2> TransactByField;
72     typedef bit::Range<FieldType,TransactByField::end,       2> TransactDetailField;
73     typedef bit::Range<FieldType,TransactDetailField::end,   1> LicenceConfirmedField;
74     typedef bit::Range<FieldType,LicenceConfirmedField::end, 4> WeakField;
75     typedef bit::Range<FieldType,WeakField::end,             1> UserLockQueryField; // internal
76     // enlarge FieldType if more bit's needed. It's not yet
77     // checked by the compiler.
78     //@}
79   public:
80
81     /** \name Status values.
82      *
83      * Each enum corresponds to a BitField range.
84      * \note Take care that enumerator values actually fit into
85      * the corresponding field. It's not yet checked by the compiler.
86      */
87     //@{
88     enum StateValue
89       {
90         UNINSTALLED = bit::RangeValue<StateField,0>::value,
91         INSTALLED   = bit::RangeValue<StateField,1>::value
92       };
93     enum ValidateValue
94       {
95         UNDETERMINED = bit::RangeValue<ValidateField,0>::value,
96         BROKEN       = bit::RangeValue<ValidateField,1>::value,
97         SATISFIED    = bit::RangeValue<ValidateField,2>::value,
98         NONRELEVANT  = bit::RangeValue<ValidateField,3>::value
99       };
100     enum TransactValue
101       {
102         KEEP_STATE = bit::RangeValue<TransactField,0>::value,
103         LOCKED     = bit::RangeValue<TransactField,1>::value, // locked, must not transact
104         TRANSACT   = bit::RangeValue<TransactField,2>::value  // transact according to state
105       };
106     enum TransactByValue
107       {
108         SOLVER    = bit::RangeValue<TransactByField,0>::value,
109         APPL_LOW  = bit::RangeValue<TransactByField,1>::value,
110         APPL_HIGH = bit::RangeValue<TransactByField,2>::value,
111         USER      = bit::RangeValue<TransactByField,3>::value
112       };
113
114     enum DetailValue
115       {
116         /** Detail for no transact, i.e. reset any Install/RemoveDetailValue. */
117         NO_DETAIL = bit::RangeValue<TransactDetailField,0>::value,
118       };
119     enum InstallDetailValue
120       {
121         EXPLICIT_INSTALL = bit::RangeValue<TransactDetailField,0>::value,
122         SOFT_INSTALL     = bit::RangeValue<TransactDetailField,1>::value
123       };
124     enum RemoveDetailValue
125       {
126         EXPLICIT_REMOVE = bit::RangeValue<TransactDetailField,0>::value,
127         SOFT_REMOVE     = bit::RangeValue<TransactDetailField,1>::value,
128         DUE_TO_OBSOLETE = bit::RangeValue<TransactDetailField,2>::value,
129         DUE_TO_UPGRADE  = bit::RangeValue<TransactDetailField,3>::value
130       };
131
132     enum LicenceConfirmedValue
133       {
134         LICENCE_UNCONFIRMED = bit::RangeValue<LicenceConfirmedField,0>::value,
135         LICENCE_CONFIRMED   = bit::RangeValue<LicenceConfirmedField,1>::value
136       };
137
138     enum WeakValue      // Unlike the other fields those are BITS that may be or'ed!
139       {
140         NO_WEAK                 = bit::RangeValue<WeakField,0>::value,
141         SUGGESTED               = bit::RangeValue<WeakField,1<<0>::value,
142         RECOMMENDED             = bit::RangeValue<WeakField,1<<1>::value,
143         ORPHANED                = bit::RangeValue<WeakField,1<<2>::value,
144         UNNEEDED                = bit::RangeValue<WeakField,1<<3>::value
145       };
146
147     enum UserLockQuery // internal
148       {
149         USERLOCK_NOMATCH        = bit::RangeValue<UserLockQueryField,0>::value,
150         USERLOCK_MATCH          = bit::RangeValue<UserLockQueryField,1>::value
151       };
152     //@}
153
154   public:
155
156     /** Default ctor. */
157     ResStatus();
158
159     /** Ctor setting the initial . */
160     ResStatus( bool isInstalled_r );
161
162     /** Dtor. */
163     ~ResStatus();
164
165     /** Debug helper returning the bitfield.
166      * It's save to expose the bitfield, as it can't be used to
167      * recreate a ResStatus. So it is not possible to bypass
168      * transition rules.
169     */
170     BitFieldType bitfield() const
171     { return _bitfield; }
172
173   public:
174
175     bool isLicenceConfirmed() const
176     { return fieldValueIs<LicenceConfirmedField>( LICENCE_CONFIRMED ); }
177
178     void setLicenceConfirmed( bool toVal_r = true )
179     { fieldValueAssign<LicenceConfirmedField>( toVal_r ? LICENCE_CONFIRMED : LICENCE_UNCONFIRMED ); }
180
181   public:
182     bool isRecommended() const
183     { return _bitfield.test( RECOMMENDED ); }
184
185     bool isSuggested() const
186     { return _bitfield.test( SUGGESTED ); }
187
188     bool isOrphaned() const
189     { return _bitfield.test( ORPHANED ); }
190
191     bool isUnneeded() const
192     { return _bitfield.test( UNNEEDED ); }
193
194     void resetWeak()
195     { return fieldValueAssign<WeakField>( NO_WEAK ); }
196
197     void setRecommended( bool toVal_r = true )
198     { _bitfield.set( RECOMMENDED, toVal_r ); }
199
200     void setSuggested( bool toVal_r = true )
201     { _bitfield.set( SUGGESTED, toVal_r ); }
202
203     void setOrphaned( bool toVal_r = true )
204     { _bitfield.set( ORPHANED, toVal_r ); }
205
206     void setUnneeded( bool toVal_r = true )
207     { _bitfield.set( UNNEEDED, toVal_r ); }
208
209   public:
210     ValidateValue validate() const
211     { return (ValidateValue)_bitfield.value<ValidateField>(); }
212
213     bool isUndetermined() const
214     { return fieldValueIs<ValidateField>( UNDETERMINED ); }
215
216     bool isSatisfied() const
217     { return fieldValueIs<ValidateField>( SATISFIED ); }
218
219     bool isBroken() const
220     { return fieldValueIs<ValidateField>( BROKEN ); }
221
222     bool isNonRelevant() const
223     { return fieldValueIs<ValidateField>( NONRELEVANT ); }
224
225   public:
226     // These two are IMMUTABLE!
227
228     bool isInstalled() const
229     { return fieldValueIs<StateField>( INSTALLED ); }
230
231     bool isUninstalled() const
232     { return fieldValueIs<StateField>( UNINSTALLED ); }
233
234   public:
235
236     bool staysInstalled() const
237     { return isInstalled() && !transacts(); }
238
239     bool wasInstalled() const { return staysInstalled(); }      //for old status
240
241     bool isToBeInstalled() const
242     { return isUninstalled() && transacts(); }
243
244     bool staysUninstalled() const
245     { return isUninstalled() && !transacts(); }
246
247     bool wasUninstalled() const { return staysUninstalled(); }  // for old status
248
249     bool isToBeUninstalled() const
250     { return isInstalled() && transacts(); }
251
252     bool isLocked() const
253     { return fieldValueIs<TransactField>( LOCKED ); }
254
255     bool isUserLocked() const
256     { return isLocked() && isByUser(); }
257
258     bool isSoftLocked() const
259     { return isKept() && ( isByApplLow() || isByUser() ); }
260
261     bool isKept() const
262     { return fieldValueIs<TransactField>( KEEP_STATE ); }
263
264     bool transacts() const
265     { return fieldValueIs<TransactField>( TRANSACT ); }
266
267     TransactValue getTransactValue() const
268     { return (TransactValue)_bitfield.value<TransactField>(); }
269
270     /** True if would be on system after commit. */
271     bool onSystem() const
272     { return( isInstalled() != transacts() ); }
273
274     /** True if would be off system after commit. */
275     bool offSystem() const
276     { return ! onSystem(); }
277
278     bool isBySolver() const
279     { return fieldValueIs<TransactByField>( SOLVER ); }
280
281     bool isByApplLow() const
282     { return fieldValueIs<TransactByField>( APPL_LOW ); }
283
284     bool isByApplHigh() const
285     { return fieldValueIs<TransactByField>( APPL_HIGH ); }
286
287     bool isByUser() const
288     { return fieldValueIs<TransactByField>( USER ); }
289
290     TransactByValue getTransactByValue() const
291     { return (TransactByValue)_bitfield.value<TransactByField>(); }
292
293     bool setTransactByValue(TransactByValue causer)
294     {
295         if ( isLessThan<TransactByField>( causer ) ) {
296             fieldValueAssign<TransactByField>( causer );
297             return true;
298         } else {
299             return false;
300         }
301     }
302
303     bool isToBeUninstalledDueToObsolete () const
304     { return isToBeUninstalled() && fieldValueIs<TransactDetailField>( DUE_TO_OBSOLETE ); }
305
306     bool isToBeUninstalledDueToUpgrade() const
307     { return isToBeUninstalled() && fieldValueIs<TransactDetailField>( DUE_TO_UPGRADE ); }
308
309     bool isToBeInstalledSoft () const
310     { return isToBeInstalled() && fieldValueIs<TransactDetailField>( SOFT_INSTALL ); }
311
312     bool isToBeInstalledNotSoft () const
313     { return isToBeInstalled() && !fieldValueIs<TransactDetailField>( SOFT_INSTALL ); }
314
315     bool isToBeUninstalledSoft () const
316     { return isToBeUninstalled() && fieldValueIs<TransactDetailField>( SOFT_REMOVE ); }
317
318   private:
319
320     /** \name Internal hard lock maintainance */
321     //@{
322     friend class resstatus::UserLockQueryManip;
323
324     bool isUserLockQueryMatch() const
325     { return fieldValueIs<UserLockQueryField>( USERLOCK_MATCH ); }
326
327     void setUserLockQueryMatch( bool match_r )
328     { fieldValueAssign<UserLockQueryField>( match_r ? USERLOCK_MATCH : USERLOCK_NOMATCH ); }
329     //@}
330
331   public:
332
333     //------------------------------------------------------------------------
334     // get/set functions, returnig \c true if requested status change
335     // was successfull (i.e. leading to the desired transaction).
336     // If a lower level (e.g.SOLVER) wants to transact, but it's
337     // already set by a higher level, \c true should be returned.
338     // Removing a higher levels transaction bit should fail.
339     //
340     // The may functions checks only, if the action would return true
341     // if it is called.
342
343     /** Set TransactValue.
344      * Convenience to set TransactValue from enum.
345      */
346     bool setTransactValue( TransactValue newVal_r, TransactByValue causer_r )
347     {
348       switch ( newVal_r )
349         {
350         case KEEP_STATE:
351           return setTransact( false, causer_r );
352           break;
353         case LOCKED:
354           return setLock( true, causer_r );
355           break;
356         case TRANSACT:
357           return setTransact( true, causer_r );
358           break;
359         }
360       return false;
361     }
362
363     bool maySetTransactValue( TransactValue newVal_r, TransactByValue causer_r )
364     {
365         bit::BitField<FieldType> savBitfield = _bitfield;
366         bool ret = setTransactValue( newVal_r, causer_r );
367         _bitfield = savBitfield;
368         return ret;
369     }
370
371     /** Apply a lock (prevent transaction).
372      * Currently by USER or APPL_HIGH only, but who knows...
373      * Set LOCKED from KEEP_STATE to be shure all transaction
374      * details were reset properly.
375     */
376     bool setLock( bool toLock_r, TransactByValue causer_r )
377     {
378       if ( toLock_r == isLocked() )
379         {
380           // we're already in the desired state, but in case of
381           // LOCKED, remember a superior causer.
382           if ( isLocked() && isLessThan<TransactByField>( causer_r ) )
383             fieldValueAssign<TransactByField>( causer_r );
384            return true;
385         }
386       // Here: Lock status is to be changed:
387       if ( causer_r != USER && causer_r != APPL_HIGH )
388         return false;
389       if ( toLock_r ) {
390         // We're in unlocked state, which includes TRANSACT.
391         // Causer must be allowed to reset this. But from
392         // KEEP_STATE every causer is allowed to set the lock.
393         if ( ! setTransact( false, causer_r ) )
394           return false;
395         fieldValueAssign<TransactField>( LOCKED );
396         fieldValueAssign<TransactByField>( causer_r );
397       } else {
398         // To leave Locked state it needs a superior causer.
399         if ( isGreaterThan<TransactByField>( causer_r ) )
400           return false;
401         fieldValueAssign<TransactField>( KEEP_STATE );
402         fieldValueAssign<TransactByField>( SOLVER ); // reset to lowest causer
403                                                      // in order to distinguish from keep_state_by_user
404       }
405       return true;
406     }
407
408     bool maySetLock( bool to_r, TransactByValue causer_r )
409     {
410         bit::BitField<FieldType> savBitfield = _bitfield;
411         bool ret = setLock( to_r, causer_r );
412         _bitfield = savBitfield;
413         return ret;
414     }
415
416     /** Toggle between TRANSACT and KEEP_STATE.
417      * LOCKED state means KEEP_STATE. But in contrary to KEEP_STATE,
418      * LOCKED state is immutable for \a causer_r less than TransactByValue.
419      * KEEP_STATE may be canged by any \a causer_r.
420     */
421     bool setTransact( bool toTansact_r, TransactByValue causer_r )
422     {
423       if ( toTansact_r == transacts() )
424         {
425           // we're already in the desired state, but in case of
426           // TRANSACT, remember a superior causer.
427           if ( transacts() && isLessThan<TransactByField>( causer_r ) )
428               fieldValueAssign<TransactByField>( causer_r );
429
430           fieldValueAssign<TransactDetailField>( NO_DETAIL ); // Details has to be set again
431           return true;
432         }
433       // Here: transact status is to be changed:
434       if (    ! fieldValueIs<TransactField>( KEEP_STATE )
435               && isGreaterThan<TransactByField>( causer_r ) ) {
436         return false;
437       }
438
439       if ( toTansact_r )
440       {
441           fieldValueAssign<TransactField>( TRANSACT );
442       }
443       else
444       {
445           fieldValueAssign<TransactField>( KEEP_STATE );
446       }
447       fieldValueAssign<TransactDetailField>( NO_DETAIL ); // Details has to be set again
448       fieldValueAssign<TransactByField>( causer_r );
449       return true;
450     }
451
452     bool maySetTransact( bool val_r, TransactByValue causer )
453     {
454         bit::BitField<FieldType> savBitfield = _bitfield;
455         bool ret = setTransact (val_r, causer);
456         _bitfield = savBitfield;
457         return ret;
458     }
459
460     /** */
461     bool setSoftLock( TransactByValue causer_r )
462     {
463       if ( ! setTransact( false, causer_r ) )
464         return false;
465       if ( fieldValueIs<TransactField>( KEEP_STATE )
466            && isLessThan<TransactByField>( causer_r ) )
467         fieldValueAssign<TransactByField>( causer_r );
468       return true;
469     }
470
471     /** Not the same as setTransact( false ).
472      */
473     bool resetTransact( TransactByValue causer_r )
474     {
475       if ( ! setTransact( false, causer_r ) )
476         return false;
477       if ( fieldValueIs<TransactField>( KEEP_STATE ) )
478         fieldValueAssign<TransactByField>( SOLVER );
479       return true;
480     }
481
482     /** Soft toggle between TRANSACT and KEEP_STATE.
483      * Similar to setTransact, but leaving KEEP_STATE also requires
484      * a superior \a causerLimit_r. So this is a kind of soft lock.
485      * \code
486      * // SOLVER wants to set TRANSACT, iff KEEP_STATE is
487      * // not superior to APPL_LOW.
488      * setSoftTransact( true, SOLVER, APPL_LOW );
489      * \endcode
490     */
491     bool setSoftTransact( bool toTansact_r, TransactByValue causer_r,
492                           TransactByValue causerLimit_r )
493     {
494       if ( fieldValueIs<TransactField>( KEEP_STATE )
495            && toTansact_r != transacts()
496            && isGreaterThan<TransactByField>( causerLimit_r ) )
497         {
498           // any transact status change requires a superior causer.
499           return false;
500         }
501       return setTransact( toTansact_r, causer_r );
502     }
503
504     bool setSoftTransact( bool toTansact_r, TransactByValue causer_r )
505     { return setSoftTransact( toTansact_r, causer_r, causer_r ); }
506
507     bool maySetSoftTransact( bool val_r, TransactByValue causer,
508                              TransactByValue causerLimit_r )
509     {
510         bit::BitField<FieldType> savBitfield = _bitfield;
511         bool ret = setSoftTransact( val_r, causer, causerLimit_r );
512         _bitfield = savBitfield;
513         return ret;
514     }
515
516     bool maySetSoftTransact( bool val_r, TransactByValue causer )
517     { return maySetSoftTransact( val_r, causer, causer ); }
518
519     bool setToBeInstalled (TransactByValue causer)
520     {
521       if (isInstalled()) return false;
522       return setTransact (true, causer);
523     }
524
525     bool maySetToBeInstalled (TransactByValue causer)
526     {
527         bit::BitField<FieldType> savBitfield = _bitfield;
528         bool ret = setToBeInstalled (causer);
529         _bitfield = savBitfield;
530         return ret;
531     }
532
533     bool setToBeUninstalled (TransactByValue causer)
534     {
535       if (!isInstalled()) return false;
536       return setTransact (true, causer);
537     }
538
539     bool maySetToBeUninstalled (TransactByValue causer)
540     {
541         bit::BitField<FieldType> savBitfield = _bitfield;
542         bool ret = setToBeUninstalled (causer);
543         _bitfield = savBitfield;
544         return ret;
545     }
546
547     //------------------------------------------------------------------------
548     // *** These are only for the Resolver ***
549
550     bool setToBeUninstalledDueToObsolete ( )
551     {
552       if (!setToBeUninstalled (SOLVER)) return false;
553       fieldValueAssign<TransactDetailField>(DUE_TO_OBSOLETE);
554       return true;
555     }
556
557     bool setToBeUninstalledDueToUpgrade ( TransactByValue causer )
558     {
559       if (!setToBeUninstalled (causer)) return false;
560       fieldValueAssign<TransactDetailField>(DUE_TO_UPGRADE);
561       return true;
562     }
563
564     bool setToBeInstalledSoft ( )
565     {
566       if (isInstalled()
567           || !setSoftTransact (true, SOLVER))
568           return false;
569
570       fieldValueAssign<TransactDetailField>(SOFT_INSTALL);
571       return true;
572     }
573
574     bool setToBeUninstalledSoft ( )
575     {
576       if (!isInstalled()
577           || !setSoftTransact (true, SOLVER))
578           return false;
579
580       fieldValueAssign<TransactDetailField>(SOFT_REMOVE);
581       return true;
582     }
583
584     bool maySetToBeUninstalledSoft ()
585     {
586         bit::BitField<FieldType> savBitfield = _bitfield;
587         bool ret = setToBeUninstalledSoft ();
588         _bitfield = savBitfield;
589         return ret;
590     }
591
592     bool isSoftInstall () {
593         return fieldValueIs<TransactDetailField> (SOFT_INSTALL);
594     }
595
596     bool isSoftUninstall () {
597         return fieldValueIs<TransactDetailField> (SOFT_REMOVE);
598     }
599
600     bool setSoftInstall (bool flag) {
601         fieldValueAssign<TransactDetailField>(flag?SOFT_INSTALL:0);
602         return true;
603     }
604
605     bool setSoftUninstall (bool flag) {
606         fieldValueAssign<TransactDetailField>(flag?SOFT_REMOVE:0);
607         return true;
608     }
609
610     bool setUndetermined ()
611     {
612       fieldValueAssign<ValidateField>(UNDETERMINED);
613       return true;
614     }
615
616     bool setSatisfied ()
617     {
618       fieldValueAssign<ValidateField>(SATISFIED);
619       return true;
620     }
621
622     bool setBroken ()
623     {
624       fieldValueAssign<ValidateField>(BROKEN);
625       return true;
626     }
627
628     bool setNonRelevant ()
629     {
630       fieldValueAssign<ValidateField>(NONRELEVANT);
631       return true;
632     }
633
634     bool setStatus( ResStatus newStatus_r )
635     {
636       // State field is immutable!
637       if ( _bitfield.value<StateField>() != newStatus_r._bitfield.value<StateField>() )
638         return false;
639       // Transaction state change allowed?
640       if ( ! setTransactValue( newStatus_r.getTransactValue(), newStatus_r.getTransactByValue() ) )
641         return false;
642
643       // Ok, we take it all..
644       _bitfield = newStatus_r._bitfield;
645       return true;
646     }
647
648     /** \name Builtin ResStatus constants. */
649     //@{
650     static const ResStatus toBeInstalled;
651     static const ResStatus toBeUninstalled;
652     static const ResStatus toBeUninstalledDueToUpgrade;
653     static const ResStatus toBeUninstalledDueToObsolete;
654     //@}
655
656   private:
657     /** Ctor for intialization of builtin constants. */
658     ResStatus( StateValue s,
659                ValidateValue v      = UNDETERMINED,
660                TransactValue t      = KEEP_STATE,
661                InstallDetailValue i = EXPLICIT_INSTALL,
662                RemoveDetailValue r  = EXPLICIT_REMOVE );
663
664     /** Return whether the corresponding Field has value \a val_r.
665     */
666     template<class _Field>
667       bool fieldValueIs( FieldType val_r ) const
668     { return _bitfield.isEqual<_Field>( val_r ); }
669
670     /** Set the corresponding Field to value \a val_r.
671     */
672     template<class _Field>
673       void fieldValueAssign( FieldType val_r )
674     { _bitfield.assign<_Field>( val_r ); }
675
676     /** compare two values.
677     */
678     template<class _Field>
679       bool isGreaterThan( FieldType val_r )
680     { return _bitfield.value<_Field>() > val_r; }
681
682     template<class _Field>
683       bool isLessThan( FieldType val_r )
684     { return _bitfield.value<_Field>() < val_r; }
685
686   private:
687     friend class resstatus::StatusBackup;
688     BitFieldType _bitfield;
689   };
690   ///////////////////////////////////////////////////////////////////
691
692   /** \relates ResStatus Stream output */
693   std::ostream & operator<<( std::ostream & str, const ResStatus & obj );
694
695   /** \relates ResStatus Stream output */
696   std::ostream & operator<<( std::ostream & str, ResStatus::TransactValue obj );
697
698   /** \relates ResStatus Stream output */
699   std::ostream & operator<<( std::ostream & str, ResStatus::TransactByValue obj );
700
701   /** \relates ResStatus */
702   inline bool operator==( const ResStatus & lhs, const ResStatus & rhs )
703   { return lhs._bitfield == rhs._bitfield; }
704
705   /** \relates ResStatus */
706   inline bool operator!=( const ResStatus & lhs, const ResStatus & rhs )
707   { return ! (lhs == rhs); }
708
709   ///////////////////////////////////////////////////////////////////
710
711   namespace resstatus
712   {
713     class StatusBackup
714     {
715       public:
716         StatusBackup()
717         : _status( 0 )
718         {}
719
720         StatusBackup( ResStatus & status_r )
721         : _status( &status_r )
722         , _bitfield( _status->_bitfield )
723         {}
724
725         void replay()
726         { if ( _status ) _status->_bitfield = _bitfield; }
727
728       private:
729         ResStatus *             _status;
730         ResStatus::BitFieldType _bitfield;
731     };
732   }
733
734  /////////////////////////////////////////////////////////////////
735 } // namespace zypp
736 ///////////////////////////////////////////////////////////////////
737 #endif // ZYPP_RESSTATUS_H