PoolItem.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #include <iostream>
00013 //#include "zypp/base/Logger.h"
00014 
00015 #include "zypp/PoolItem.h"
00016 
00017 using std::endl;
00018 
00020 namespace zypp
00021 { 
00022 
00024   //
00025   //    CLASS NAME : PoolItem_Ref::Impl
00026   //
00028   struct PoolItem_Ref::Impl
00029   {
00030     Impl()
00031     {}
00032 
00033     Impl( ResObject::constPtr res_r,
00034           const ResStatus & status_r = ResStatus() )
00035     : _status( status_r )
00036     , _resolvable( res_r )
00037     {}
00038 
00039     ResStatus & status() const
00040     { return _status; }
00041 
00042     ResObject::constPtr resolvable() const
00043     { return _resolvable; }
00044 
00045   private:
00046     mutable ResStatus   _status;
00047     ResObject::constPtr _resolvable;
00048 
00053   public:
00054     void saveState() const
00055     { _savedStatus = _status; }
00056     void restoreState() const
00057     { _status = _savedStatus; }
00058     bool sameState() const
00059     {
00060       if (    _status.getTransactValue() != _savedStatus.getTransactValue()
00061            && !_status.isBySolver() )
00062         return false;
00063       if ( _status.isLicenceConfirmed() != _savedStatus.isLicenceConfirmed() )
00064         return false;
00065       return true;
00066     }
00067   private:
00068     mutable ResStatus _savedStatus;
00070 
00071   public:
00073     static shared_ptr<Impl> nullimpl()
00074     {
00075       static shared_ptr<Impl> _nullimpl( new Impl );
00076       return _nullimpl;
00077     }
00078   };
00080 
00082   inline std::ostream & operator<<( std::ostream & str, const PoolItem_Ref::Impl & obj )
00083   {
00084     str << obj.status();
00085     if (obj.resolvable())
00086         str << *obj.resolvable();
00087     else
00088         str << "(NULL)";
00089     return str;
00090   }
00091 
00093   //
00094   //    CLASS NAME : PoolItem_Ref
00095   //
00097 
00099   //
00100   //    METHOD NAME : PoolItem_Ref::PoolItem_Ref
00101   //    METHOD TYPE : Ctor
00102   //
00103   PoolItem_Ref::PoolItem_Ref()
00104   : _pimpl( Impl::nullimpl() )
00105   {}
00106 
00108   //
00109   //    METHOD NAME : PoolItem_Ref::PoolItem_Ref
00110   //    METHOD TYPE : Ctor
00111   //
00112   PoolItem_Ref::PoolItem_Ref( ResObject::constPtr res_r )
00113   : _pimpl( new Impl( res_r ) )
00114   {}
00115 
00117   //
00118   //    METHOD NAME : PoolItem_Ref::PoolItem_Ref
00119   //    METHOD TYPE : Ctor
00120   //
00121   PoolItem_Ref::PoolItem_Ref( ResObject::constPtr res_r, const ResStatus & status_r )
00122   : _pimpl( new Impl( res_r, status_r ) )
00123   {}
00124 
00126   //
00127   //    METHOD NAME : PoolItem_Ref::~PoolItem_Ref
00128   //    METHOD TYPE : Dtor
00129   //
00130   PoolItem_Ref::~PoolItem_Ref()
00131   {}
00132 
00134   //
00135   //    Forward to Impl:
00136   //
00138 
00139   ResStatus & PoolItem_Ref::status() const
00140   { return _pimpl->status(); }
00141 
00142   ResObject::constPtr PoolItem_Ref::resolvable() const
00143   { return _pimpl->resolvable(); }
00144 
00145   void PoolItem_Ref::saveState() const
00146   { _pimpl->saveState(); }
00147 
00148   void PoolItem_Ref::restoreState() const
00149   { _pimpl->restoreState(); }
00150 
00151   bool PoolItem_Ref::sameState() const
00152   { return _pimpl->sameState(); }
00153 
00154   /******************************************************************
00155    **
00156    **   FUNCTION NAME : operator<<
00157    **   FUNCTION TYPE : std::ostream &
00158   */
00159   std::ostream & operator<<( std::ostream & str, const PoolItem_Ref & obj )
00160   {
00161     return str << *obj._pimpl;
00162   }
00163 
00165 } // namespace zypp

Generated on Thu May 4 16:03:24 2006 for zypp by  doxygen 1.4.6