Selectable.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_UI_SELECTABLE_H
00013 #define ZYPP_UI_SELECTABLE_H
00014 
00015 #include <iosfwd>
00016 
00017 #include "zypp/base/ReferenceCounted.h"
00018 #include "zypp/base/NonCopyable.h"
00019 #include "zypp/base/PtrTypes.h"
00020 #include "zypp/base/Iterator.h"
00021 
00022 #include "zypp/ui/SelectableTraits.h"
00023 #include "zypp/ui/Status.h"
00024 
00026 namespace zypp
00027 { 
00028 
00029   namespace ui
00030   { 
00031 
00033     //
00034     //  CLASS NAME : Selectable
00035     //
00048     class Selectable : public base::ReferenceCounted, private base::NonCopyable
00049     {
00050       friend std::ostream & operator<<( std::ostream & str, const Selectable & obj );
00051 
00052     public:
00053       typedef intrusive_ptr<Selectable>        Ptr;
00054       typedef intrusive_ptr<const Selectable>  constPtr;
00055 
00057       typedef SelectableTraits::available_iterator      available_iterator;
00058       typedef SelectableTraits::availableItem_size_type size_type;
00059 
00060     public:
00062       ResObject::Kind kind() const;
00063 
00065       const std::string & name() const;
00066 
00068       ResObject::constPtr installedObj() const;
00069 
00073       ResObject::constPtr candidateObj() const;
00074 
00080       ResObject::constPtr setCandidate( ResObject::constPtr byUser_r );
00081 
00083       ResObject::constPtr theObj() const;
00084 
00086       size_type availableObjs() const;
00087 
00089       available_iterator availableBegin() const;
00090 
00092       available_iterator availableEnd() const;
00093 
00094     public:
00099       bool hasObject() const
00100       { return installedObj() || candidateObj(); }
00101 
00103       bool hasInstalledObj() const
00104       { return installedObj(); }
00105 
00107       bool hasCandidateObj() const
00108       { return candidateObj(); }
00109 
00111       bool hasBothObjects() const
00112       { return installedObj() && candidateObj(); }
00113 
00115       bool hasInstalledObjOnly() const
00116       { return installedObj() && ! candidateObj(); }
00117 
00119       bool hasCandidateObjOnly() const
00120       { return ! installedObj() && candidateObj(); }
00122 
00123      public:
00127       enum Fate {
00128         TO_DELETE  = -1,
00129         UNMODIFIED = 0,
00130         TO_INSTALL = 1
00131       };
00133       Fate fate() const;
00134 
00136       bool unmodified() const
00137       { return fate() == UNMODIFIED; }
00138 
00140       bool toModify() const
00141       { return fate() != UNMODIFIED; }
00142 
00144       bool toDelete() const
00145       { return fate() == TO_DELETE; }
00146 
00148       bool toInstall() const
00149       { return fate() == TO_INSTALL; }
00151 
00152     public:
00161       Status status() const;
00165       bool set_status( const Status state_r );
00166 
00168       ResStatus::TransactByValue modifiedBy() const;
00169 
00171       bool hasLicenceConfirmed() const;
00172 
00174       void setLicenceConfirmed( bool val_r = true );
00176 
00177     public:
00179       class Impl;
00180       typedef shared_ptr<Impl> Impl_Ptr;
00182       Selectable( Impl_Ptr pimpl_r );
00183     private:
00185       ~Selectable();
00186     private:
00188       RW_pointer<Impl> _pimpl;
00189     };
00191 
00193     std::ostream & operator<<( std::ostream & str, const Selectable & obj );
00194 
00196   } // namespace ui
00199 } // namespace zypp
00201 #endif // ZYPP_UI_SELECTABLE_H

Generated on Thu Jul 6 00:07:28 2006 for zypp by  doxygen 1.4.6