Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / Pattern.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/Pattern.h
10  *
11 */
12 #ifndef ZYPP_PATTERN_H
13 #define ZYPP_PATTERN_H
14
15 #include "zypp/ResObject.h"
16 #include "zypp/Pathname.h"
17
18 ///////////////////////////////////////////////////////////////////
19 namespace zypp
20 { /////////////////////////////////////////////////////////////////
21
22   DEFINE_PTR_TYPE(Pattern);
23
24   ///////////////////////////////////////////////////////////////////
25   //
26   //    CLASS NAME : Pattern
27   //
28   /** Pattern interface.
29   */
30   class Pattern : public ResObject
31   {
32     public:
33       typedef Pattern                  Self;
34       typedef ResTraits<Self>          TraitsType;
35       typedef TraitsType::PtrType      Ptr;
36       typedef TraitsType::constPtrType constPtr;
37
38     public:
39       typedef sat::ArrayAttr<IdString,IdString> NameList;
40       typedef sat::SolvableSet                  Contents;
41
42     public:
43       /** */
44       bool isDefault() const;
45       /** */
46       bool userVisible() const;
47       /** */
48       std::string category( const Locale & lang_r = Locale() ) const;
49       /** */
50       Pathname icon() const;
51       /** */
52       Pathname script() const;
53       /** */
54       std::string order() const;
55
56     public:
57       /** \name Auto pattens (libyzpp-14)
58        * Patterns are no longer defined by separate metadate files, but via
59        * special dependencies provided by a corresponding patterns- package.
60        * The pattern itself requires only it's patterns- package, the package
61        * contains all further dependencies.
62        * This way pattens are no longer pseudo installed objects with a computed
63        * status, but installed, iff the corresponding patterns- package is
64        * installed.
65        */
66       //@{
67       /** This patterns is auto-defined by a patterns- package. */
68       bool isAutoPattern() const;
69       /** The corresponding patterns- package if \ref isAutoPattern. */
70       sat::Solvable autoPackage() const;
71       //@}
72     public:
73       /** Ui hint: included patterns. */
74       NameList includes() const;
75
76       /** Ui hint: patterns this one extends. */
77       NameList extends() const;
78
79       /** Ui hint: Required Packages. */
80       Contents core() const;
81
82       /** Ui hint: Dependent packages.
83        * This also includes recommended and suggested (optionally exclude) packages.
84       */
85       Contents depends( bool includeSuggests_r = true ) const;
86       /** \overload Without SUGGESTS. */
87       Contents dependsNoSuggests() const
88       { return depends( false ); }
89
90       /** The collection of packages associated with this pattern.
91        * This also evaluates the patterns includes/extends relation.
92        * Optionally exclude \c SUGGESTED packages.
93        */
94       Contents contents( bool includeSuggests_r = true ) const;
95       /** \overload Without SUGGESTS. */
96       Contents contentsNoSuggests() const
97       { return contents( false ); }
98
99     public:
100       struct ContentsSet
101       {
102         Contents req;   ///< required content set
103         Contents rec;   ///< recommended content set
104         Contents sug;   ///< suggested content set
105       };
106       /** Dependency based content set (does not evaluate includes/extends relation).
107        * If \a recursively_r, required and recommended
108        * patterns are recursively expanded.
109        */
110       void contentsSet( ContentsSet & collect_r, bool recursively_r = false ) const;
111       /** \overload Convenience for recursively expanded contentsSet */
112       void fullContentsSet( ContentsSet & collect_r ) const
113       { return contentsSet( collect_r, /*recursively_r*/true ); }
114
115     protected:
116       friend Ptr make<Self>( const sat::Solvable & solvable_r );
117       /** Ctor */
118       Pattern( const sat::Solvable & solvable_r );
119       /** Dtor */
120       virtual ~Pattern();
121   };
122   ///////////////////////////////////////////////////////////////////
123
124   /////////////////////////////////////////////////////////////////
125 } // namespace zypp
126 ///////////////////////////////////////////////////////////////////
127 #endif // ZYPP_PATTERN_H