libzypp
10.5.0
|
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ 00002 /* QueueItem.h 00003 * 00004 * Copyright (C) 2008 SUSE Linux Products GmbH 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License, 00008 * version 2, as published by the Free Software Foundation. 00009 * 00010 * This program is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00018 * 02111-1307, USA. 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 // CLASS NAME : SolverQueueItem 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 // ---------------------------------- I/O 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 // ---------------------------------- accessors 00091 00092 ResPool pool (void) const { return _pool; } 00093 00094 // ---------------------------------- methods 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 };// namespace detail 00116 };// namespace solver 00119 };// namespace zypp 00121 00122 #endif // ZYPP_SOLVER_DETAIL_QUEUEITEM_H