libzypp: zypp/solver/detail/SolverQueueItem.h Source File

libzypp 17.36.6

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>
32#include <zypp/base/ReferenceCounted.h>
33#include <zypp/base/NonCopyable.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
47 DEFINE_PTR_TYPE(SolverQueueItem);
48
49 DEFINE_PTR_TYPE(SolverQueueItemUpdate);
50 DEFINE_PTR_TYPE(SolverQueueItemDelete);
51 DEFINE_PTR_TYPE(SolverQueueItemInstall);
52 DEFINE_PTR_TYPE(SolverQueueItemInstallOneOf);
53 DEFINE_PTR_TYPE(SolverQueueItemLock);
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
operator<<
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
Definition LookupAttr.cc:808
ResPool.h
zypp::base::SetRelationMixin::compare
SetCompare compare(const SetRelationMixin< Derived > &src, const SetRelationMixin< Derived > &trg)
Compare sets.
Definition SetRelationMixin.h:182
zypp::solver::detail::SolverQueueItemDelete
Definition SolverQueueItemDelete.h:45
zypp::solver::detail::SolverQueueItemInstallOneOf
Definition SolverQueueItemInstallOneOf.h:43
zypp::solver::detail::SolverQueueItemInstall
Definition SolverQueueItemInstall.h:44
zypp::solver::detail::SolverQueueItemLock
Definition SolverQueueItemLock.h:44
zypp::solver::detail::SolverQueueItemUpdate
Definition SolverQueueItemUpdate.h:44
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp::iostr::copy
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
Definition IOStream.h:51
zypp::solver::detail
Definition PoolImpl.h:110
zypp::solver::detail::SolverQueueItemList
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition Types.h:45
zypp::solver
Definition PoolImpl.h:109
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition Capability.cc:580
DEFINE_PTR_TYPE
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639
Globals.h
NonCopyable.h
PtrTypes.h
ReferenceCounted.h