1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Copyright (C) 2008 SUSE Linux Products GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 #ifndef ZYPP_SOLVER_DETAIL_QUEUEITEM_H
22 #define ZYPP_SOLVER_DETAIL_QUEUEITEM_H
23 #ifndef ZYPP_USE_RESOLVER_INTERNALS
24 #error Do not directly include this file!
31 #include "zypp/base/ReferenceCounted.h"
32 #include "zypp/base/NonCopyable.h"
33 #include "zypp/base/PtrTypes.h"
34 #include "zypp/ResPool.h"
40 /////////////////////////////////////////////////////////////////////////
42 { ///////////////////////////////////////////////////////////////////////
43 ///////////////////////////////////////////////////////////////////////
45 { /////////////////////////////////////////////////////////////////////
46 /////////////////////////////////////////////////////////////////////
48 { ///////////////////////////////////////////////////////////////////
50 DEFINE_PTR_TYPE(SolverQueueItem);
52 DEFINE_PTR_TYPE(SolverQueueItemUpdate);
53 DEFINE_PTR_TYPE(SolverQueueItemDelete);
54 DEFINE_PTR_TYPE(SolverQueueItemInstall);
55 DEFINE_PTR_TYPE(SolverQueueItemInstallOneOf);
56 DEFINE_PTR_TYPE(SolverQueueItemLock);
60 QUEUE_ITEM_TYPE_UNKNOWN = 0,
61 QUEUE_ITEM_TYPE_UPDATE,
62 QUEUE_ITEM_TYPE_INSTALL,
63 QUEUE_ITEM_TYPE_DELETE,
64 QUEUE_ITEM_TYPE_INSTALL_ONE_OF,
66 } SolverQueueItemType;
69 typedef std::list<SolverQueueItem_Ptr> SolverQueueItemList;
71 #define CMP(a,b) (((a) < (b)) - ((b) < (a)))
73 ///////////////////////////////////////////////////////////////////
75 // CLASS NAME : SolverQueueItem
77 class SolverQueueItem : public base::ReferenceCounted, private base::NonCopyable {
81 SolverQueueItemType _type;
86 SolverQueueItem (SolverQueueItemType type, const ResPool & pool);
90 virtual ~SolverQueueItem();
92 // ---------------------------------- I/O
94 virtual std::ostream & dumpOn( std::ostream & str ) const;
96 friend std::ostream& operator<<(std::ostream & str, const SolverQueueItem & obj)
97 { return obj.dumpOn (str); }
98 friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemList & itemlist);
100 // ---------------------------------- accessors
102 ResPool pool (void) const { return _pool; }
104 // ---------------------------------- methods
106 void copy (const SolverQueueItem *from);
108 bool isDelete (void) const { return _type == QUEUE_ITEM_TYPE_DELETE; }
109 bool isInstall (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL; }
110 bool isUpdate (void) const { return _type == QUEUE_ITEM_TYPE_UPDATE; }
111 bool isLock (void) const { return _type == QUEUE_ITEM_TYPE_LOCK; }
112 bool isInstallOneOf (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL_ONE_OF; }
115 virtual SolverQueueItem_Ptr copy (void) const = 0;
116 virtual bool addRule (_Queue & q) =0 ;
117 virtual int cmp (SolverQueueItem_constPtr item) const = 0;
118 int compare (SolverQueueItem_constPtr item) const { return CMP(_type, item->_type); }
122 ///////////////////////////////////////////////////////////////////
123 };// namespace detail
124 /////////////////////////////////////////////////////////////////////
125 /////////////////////////////////////////////////////////////////////
126 };// namespace solver
127 ///////////////////////////////////////////////////////////////////////
128 ///////////////////////////////////////////////////////////////////////
130 /////////////////////////////////////////////////////////////////////////
131 #endif // ZYPP_USE_RESOLVER_INTERNALS
132 #endif // ZYPP_SOLVER_DETAIL_QUEUEITEM_H