libzypp 17.37.17
SolverQueueItem.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* QueueItem.h
3 *
4 * Copyright (C) 2008 SUSE Linux Products GmbH
5 *
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.
9 *
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.
14 *
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
18 * 02111-1307, USA.
19 */
20
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!
25#else
26
27#include <iosfwd>
28#include <list>
29#include <string>
30
31#include <zypp/Globals.h>
34#include <zypp/base/PtrTypes.h>
35#include <zypp/ResPool.h>
36
38namespace zypp
39{
41 namespace solver
42 {
44 namespace detail
45 {
46
47DEFINE_PTR_TYPE(SolverQueueItem);
48
54
55
56typedef enum {
57 QUEUE_ITEM_TYPE_UNKNOWN = 0,
58 QUEUE_ITEM_TYPE_UPDATE,
59 QUEUE_ITEM_TYPE_INSTALL,
60 QUEUE_ITEM_TYPE_DELETE,
61 QUEUE_ITEM_TYPE_INSTALL_ONE_OF,
62 QUEUE_ITEM_TYPE_LOCK
63} SolverQueueItemType;
64
65
66typedef std::list<SolverQueueItem_Ptr> SolverQueueItemList;
67
68#define CMP(a,b) (((a) < (b)) - ((b) < (a)))
69
71//
72// CLASS NAME : SolverQueueItem
73
74class SolverQueueItem : public base::ReferenceCounted, private base::NonCopyable {
75
76 private:
77
78 SolverQueueItemType _type;
79 ResPool _pool;
80
81 protected:
82
83 SolverQueueItem (SolverQueueItemType type, ResPool pool);
84
85 public:
86
87 virtual ~SolverQueueItem();
88
89 // ---------------------------------- I/O
90
91 virtual std::ostream & dumpOn( std::ostream & str ) const;
92
93 friend std::ostream& operator<<(std::ostream & str, const SolverQueueItem & obj)
94 { return obj.dumpOn (str); }
95 friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemList & itemlist);
96
97 // ---------------------------------- accessors
98
99 ResPool pool (void) const { return _pool; }
100
101 // ---------------------------------- methods
102
103 void copy (const SolverQueueItem *from);
104
105 bool isDelete (void) const { return _type == QUEUE_ITEM_TYPE_DELETE; }
106 bool isInstall (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL; }
107 bool isUpdate (void) const { return _type == QUEUE_ITEM_TYPE_UPDATE; }
108 bool isLock (void) const { return _type == QUEUE_ITEM_TYPE_LOCK; }
109 bool isInstallOneOf (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL_ONE_OF; }
110
111
112 virtual SolverQueueItem_Ptr copy (void) const = 0;
113 virtual bool addRule (sat::detail::CQueue & q) =0 ;
114 virtual int cmp (SolverQueueItem_constPtr item) const = 0;
115 int compare (SolverQueueItem_constPtr item) const { return CMP(_type, item->_type); }
116
117};
118
120 };// namespace detail
123 };// namespace solver
126};// namespace zypp
128#endif // ZYPP_USE_RESOLVER_INTERNALS
129#endif // ZYPP_SOLVER_DETAIL_QUEUEITEM_H
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
SetCompare compare(const SetRelationMixin< Derived > &src, const SetRelationMixin< Derived > &trg)
Compare sets.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
Definition IOStream.h:51
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition Types.h:45
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639