SolverQueueItem.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ZYPP_SOLVER_DETAIL_QUEUEITEM_H
00022 #define ZYPP_SOLVER_DETAIL_QUEUEITEM_H
00023
00024 #include <iosfwd>
00025 #include <list>
00026 #include <string>
00027
00028 #include "zypp/solver/detail/Types.h"
00029 #include "zypp/base/ReferenceCounted.h"
00030 #include "zypp/base/NonCopyable.h"
00031 #include "zypp/base/PtrTypes.h"
00032 #include "zypp/ResPool.h"
00033
00034 extern "C" {
00035 struct _Queue;
00036 }
00037
00038
00040 namespace zypp
00041 {
00042
00043 namespace solver
00044 {
00045
00046 namespace detail
00047 {
00048
00049 typedef enum {
00050 QUEUE_ITEM_TYPE_UNKNOWN = 0,
00051 QUEUE_ITEM_TYPE_UPDATE,
00052 QUEUE_ITEM_TYPE_INSTALL,
00053 QUEUE_ITEM_TYPE_DELETE,
00054 QUEUE_ITEM_TYPE_INSTALL_ONE_OF,
00055 QUEUE_ITEM_TYPE_LOCK
00056 } SolverQueueItemType;
00057
00058
00059 typedef std::list<SolverQueueItem_Ptr> SolverQueueItemList;
00060
00061 #define CMP(a,b) (((a) < (b)) - ((b) < (a)))
00062
00064
00065
00066
00067 class SolverQueueItem : public base::ReferenceCounted, private base::NonCopyable {
00068
00069 private:
00070
00071 SolverQueueItemType _type;
00072 ResPool _pool;
00073
00074 protected:
00075
00076 SolverQueueItem (SolverQueueItemType type, const ResPool & pool);
00077
00078 public:
00079
00080 virtual ~SolverQueueItem();
00081
00082
00083
00084 virtual std::ostream & dumpOn( std::ostream & str ) const;
00085
00086 friend std::ostream& operator<<(std::ostream & str, const SolverQueueItem & obj)
00087 { return obj.dumpOn (str); }
00088 friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemList & itemlist);
00089
00090
00091
00092 ResPool pool (void) const { return _pool; }
00093
00094
00095
00096 void copy (const SolverQueueItem *from);
00097
00098 bool isDelete (void) const { return _type == QUEUE_ITEM_TYPE_DELETE; }
00099 bool isInstall (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL; }
00100 bool isUpdate (void) const { return _type == QUEUE_ITEM_TYPE_UPDATE; }
00101 bool isLock (void) const { return _type == QUEUE_ITEM_TYPE_LOCK; }
00102 bool isInstallOneOf (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL_ONE_OF; }
00103
00104
00105 virtual SolverQueueItem_Ptr copy (void) const = 0;
00106 virtual bool addRule (_Queue & q) =0 ;
00107 virtual int cmp (SolverQueueItem_constPtr item) const = 0;
00108 int compare (SolverQueueItem_constPtr item) const { return CMP(_type, item->_type); }
00109
00110 };
00111
00113 };
00116 };
00119 };
00121
00122 #endif // ZYPP_SOLVER_DETAIL_QUEUEITEM_H