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
28 #include "zypp/base/ReferenceCounted.h"
29 #include "zypp/base/NonCopyable.h"
30 #include "zypp/base/PtrTypes.h"
31 #include "zypp/ResPool.h"
33 /////////////////////////////////////////////////////////////////////////
35 { ///////////////////////////////////////////////////////////////////////
36 ///////////////////////////////////////////////////////////////////////
38 { /////////////////////////////////////////////////////////////////////
39 /////////////////////////////////////////////////////////////////////
41 { ///////////////////////////////////////////////////////////////////
44 QUEUE_ITEM_TYPE_UNKNOWN = 0,
45 QUEUE_ITEM_TYPE_UPDATE,
46 QUEUE_ITEM_TYPE_INSTALL,
47 QUEUE_ITEM_TYPE_DELETE,
48 QUEUE_ITEM_TYPE_INSTALL_ONE_OF,
49 } SolverQueueItemType;
51 DEFINE_PTR_TYPE(SolverQueueItem);
53 typedef std::list<SolverQueueItem_Ptr> SolverQueueItemList;
55 #define CMP(a,b) (((a) < (b)) - ((b) < (a)))
57 ///////////////////////////////////////////////////////////////////
59 // CLASS NAME : SolverQueueItem
61 class SolverQueueItem : public base::ReferenceCounted, private base::NonCopyable {
65 SolverQueueItemType _type;
70 SolverQueueItem (SolverQueueItemType type, const ResPool & pool);
74 virtual ~SolverQueueItem();
76 // ---------------------------------- I/O
78 virtual std::ostream & dumpOn( std::ostream & str ) const;
80 friend std::ostream& operator<<(std::ostream & str, const SolverQueueItem & obj)
81 { return obj.dumpOn (str); }
82 friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemList & itemlist);
84 // ---------------------------------- accessors
86 ResPool pool (void) const { return _pool; }
88 // ---------------------------------- methods
90 void copy (const SolverQueueItem *from);
92 bool isDelete (void) const { return _type == QUEUE_ITEM_TYPE_DELETE; }
93 bool isInstall (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL; }
94 bool isUpdate (void) const { return _type == QUEUE_ITEM_TYPE_UPDATE; }
95 bool isInstallOneOf (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL_ONE_OF; }
98 virtual SolverQueueItem_Ptr copy (void) const = 0;
99 virtual int cmp (SolverQueueItem_constPtr item) const = 0;
100 int compare (SolverQueueItem_constPtr item) const { return CMP(_type, item->_type); }
105 ///////////////////////////////////////////////////////////////////
106 };// namespace detail
107 /////////////////////////////////////////////////////////////////////
108 /////////////////////////////////////////////////////////////////////
109 };// namespace solver
110 ///////////////////////////////////////////////////////////////////////
111 ///////////////////////////////////////////////////////////////////////
113 /////////////////////////////////////////////////////////////////////////
115 #endif // ZYPP_SOLVER_DETAIL_QUEUEITEM_H