libzypp  15.28.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 
32 #include "zypp/base/NonCopyable.h"
33 #include "zypp/base/PtrTypes.h"
34 #include "zypp/ResPool.h"
35 
37 namespace zypp
38 {
39  namespace solver
41  {
42  namespace detail
44  {
45 
47 
48 DEFINE_PTR_TYPE(SolverQueueItemUpdate);
49 DEFINE_PTR_TYPE(SolverQueueItemDelete);
50 DEFINE_PTR_TYPE(SolverQueueItemInstall);
51 DEFINE_PTR_TYPE(SolverQueueItemInstallOneOf);
52 DEFINE_PTR_TYPE(SolverQueueItemLock);
53 
54 
55 typedef enum {
56  QUEUE_ITEM_TYPE_UNKNOWN = 0,
57  QUEUE_ITEM_TYPE_UPDATE,
58  QUEUE_ITEM_TYPE_INSTALL,
59  QUEUE_ITEM_TYPE_DELETE,
60  QUEUE_ITEM_TYPE_INSTALL_ONE_OF,
61  QUEUE_ITEM_TYPE_LOCK
62 } SolverQueueItemType;
63 
64 
65 typedef std::list<SolverQueueItem_Ptr> SolverQueueItemList;
66 
67 #define CMP(a,b) (((a) < (b)) - ((b) < (a)))
68 
70 //
71 // CLASS NAME : SolverQueueItem
72 
73 class SolverQueueItem : public base::ReferenceCounted, private base::NonCopyable {
74 
75  private:
76 
77  SolverQueueItemType _type;
78  ResPool _pool;
79 
80  protected:
81 
82  SolverQueueItem (SolverQueueItemType type, const ResPool & pool);
83 
84  public:
85 
86  virtual ~SolverQueueItem();
87 
88  // ---------------------------------- I/O
89 
90  virtual std::ostream & dumpOn( std::ostream & str ) const;
91 
92  friend std::ostream& operator<<(std::ostream & str, const SolverQueueItem & obj)
93  { return obj.dumpOn (str); }
94  friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemList & itemlist);
95 
96  // ---------------------------------- accessors
97 
98  ResPool pool (void) const { return _pool; }
99 
100  // ---------------------------------- methods
101 
102  void copy (const SolverQueueItem *from);
103 
104  bool isDelete (void) const { return _type == QUEUE_ITEM_TYPE_DELETE; }
105  bool isInstall (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL; }
106  bool isUpdate (void) const { return _type == QUEUE_ITEM_TYPE_UPDATE; }
107  bool isLock (void) const { return _type == QUEUE_ITEM_TYPE_LOCK; }
108  bool isInstallOneOf (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL_ONE_OF; }
109 
110 
111  virtual SolverQueueItem_Ptr copy (void) const = 0;
112  virtual bool addRule (sat::detail::CQueue & q) =0 ;
113  virtual int cmp (SolverQueueItem_constPtr item) const = 0;
114  int compare (SolverQueueItem_constPtr item) const { return CMP(_type, item->_type); }
115 
116 };
117 
119  };// namespace detail
122  };// namespace solver
125 };// namespace zypp
127 #endif // ZYPP_USE_RESOLVER_INTERNALS
128 #endif // ZYPP_SOLVER_DETAIL_QUEUEITEM_H
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition: Types.h:45
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
DEFINE_PTR_TYPE(HelixResolvable)
ostream & operator<<(ostream &os, const SolutionActionList &actionlist)
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:446
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
Definition: IOStream.h:50
::_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:87