- merge 3728:3847 in trunk.
[platform/upstream/libzypp.git] / zypp / solver / detail / Helper.h
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* Helper.h
3  *
4  * Static helpers
5  *
6  * Copyright (C) 2000-2002 Ximian, Inc.
7  * Copyright (C) 2005 SUSE Linux Products GmbH
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License,
11  * version 2, as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21  * 02111-1307, USA.
22  */
23
24 #ifndef ZYPP_SOLVER_DETAIL_HELPER_H
25 #define ZYPP_SOLVER_DETAIL_HELPER_H
26
27 #include <iosfwd>
28
29 #include "zypp/ResPool.h"
30 #include "zypp/PoolItem.h"
31 #include "zypp/CapSet.h"
32
33 #include "zypp/solver/detail/Types.h"
34
35 /////////////////////////////////////////////////////////////////////////
36 namespace zypp
37 { ///////////////////////////////////////////////////////////////////////
38   ///////////////////////////////////////////////////////////////////////
39   namespace solver
40   { /////////////////////////////////////////////////////////////////////
41     /////////////////////////////////////////////////////////////////////
42     namespace detail
43     { ///////////////////////////////////////////////////////////////////
44
45 ///////////////////////////////////////////////////////////////////
46 //
47 //      CLASS NAME : Helper
48
49 class Helper {
50   public:
51
52     // for name, find installed item which has same name
53     // does *NOT* check edition
54     //  FIXME: should probably take provides/obsoletes into account for
55     //         renamed upgrades
56     static PoolItem_Ref findInstalledByNameAndKind (const ResPool & pool, const std::string & name, const Resolvable::Kind & kind);
57
58     // for name, find uninstalled item which has same name
59     static PoolItem_Ref findUninstalledByNameAndKind (const ResPool & pool, const std::string & name, const Resolvable::Kind & kind);
60
61     // for item, find installed item which has same name -> calls findInstalledByNameAndKind()
62     // does *NOT* check edition
63     //  FIXME: should probably take provides/obsoletes into account for
64     //         renamed upgrades
65     static PoolItem_Ref findInstalledItem (const ResPool & pool, PoolItem_Ref item);
66
67     // for item, find uninstalled item which has same name and higher edition
68     static PoolItem_Ref findUninstalledItem (const ResPool & pool, PoolItem_Ref item);
69
70     // for item, find uninstalled item which has same name and equal edition
71     static PoolItem_Ref findReinstallItem (const ResPool & pool, PoolItem_Ref item);
72
73     static PoolItem_Ref findUpdateItem (const ResPool & pool, PoolItem_Ref item);
74
75     // for item, check if this is the 'best' uninstalled (best arch, best version) item
76     static bool isBestUninstalledItem (const ResPool & pool, PoolItem_Ref item);
77
78     friend std::ostream& operator<<(std::ostream&, const PoolItemList & itemlist);
79
80 };
81
82 ///////////////////////////////////////////////////////////////////
83     };// namespace detail
84     /////////////////////////////////////////////////////////////////////
85     /////////////////////////////////////////////////////////////////////
86   };// namespace solver
87   ///////////////////////////////////////////////////////////////////////
88   ///////////////////////////////////////////////////////////////////////
89 };// namespace zypp
90 /////////////////////////////////////////////////////////////////////////
91
92 #endif // ZYPP_SOLVER_DETAIL_HELPER_H