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_iterator availablePoolItem_iterator; 00059 typedef SelectableTraits::availableItem_size_type size_type; 00060 00061 public: 00063 ResObject::Kind kind() const; 00064 00066 const std::string & name() const; 00067 00069 ResObject::constPtr installedObj() const; 00070 00072 PoolItem installedPoolItem() const; 00073 00077 ResObject::constPtr candidateObj() const; 00078 00080 PoolItem candidatePoolItem() const; 00081 00087 ResObject::constPtr setCandidate( ResObject::constPtr byUser_r ); 00088 00090 ResObject::constPtr theObj() const; 00091 00093 size_type availableObjs() const; 00094 00096 available_iterator availableBegin() const; 00097 00099 available_iterator availableEnd() const; 00100 00102 availablePoolItem_iterator availablePoolItemBegin() const; 00103 00105 availablePoolItem_iterator availablePoolItemEnd() const; 00106 00107 public: 00112 bool hasObject() const 00113 { return installedObj() || candidateObj(); } 00114 00116 bool hasInstalledObj() const 00117 { return installedObj(); } 00118 00120 bool hasCandidateObj() const 00121 { return candidateObj(); } 00122 00124 bool hasBothObjects() const 00125 { return installedObj() && candidateObj(); } 00126 00128 bool hasInstalledObjOnly() const 00129 { return installedObj() && ! candidateObj(); } 00130 00132 bool hasCandidateObjOnly() const 00133 { return ! installedObj() && candidateObj(); } 00135 00136 public: 00140 enum Fate { 00141 TO_DELETE = -1, 00142 UNMODIFIED = 0, 00143 TO_INSTALL = 1 00144 }; 00146 Fate fate() const; 00147 00149 bool unmodified() const 00150 { return fate() == UNMODIFIED; } 00151 00153 bool toModify() const 00154 { return fate() != UNMODIFIED; } 00155 00157 bool toDelete() const 00158 { return fate() == TO_DELETE; } 00159 00161 bool toInstall() const 00162 { return fate() == TO_INSTALL; } 00164 00165 public: 00174 Status status() const; 00178 bool set_status( const Status state_r ); 00179 00181 ResStatus::TransactByValue modifiedBy() const; 00182 00184 bool hasLicenceConfirmed() const; 00185 00187 void setLicenceConfirmed( bool val_r = true ); 00189 00190 public: 00192 class Impl; 00193 typedef shared_ptr<Impl> Impl_Ptr; 00195 Selectable( Impl_Ptr pimpl_r ); 00196 private: 00198 ~Selectable(); 00199 private: 00201 RW_pointer<Impl> _pimpl; 00202 }; 00204 00206 std::ostream & operator<<( std::ostream & str, const Selectable & obj ); 00207 00209 } // namespace ui 00212 } // namespace zypp 00214 #endif // ZYPP_UI_SELECTABLE_H
1.5.3