489d595d23cfb8cadfd55e773f558799b1b778f9
[platform/upstream/libzypp.git] / zypp / PoolQuery.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ui/PoolQuery.h
10  *
11 */
12 #ifndef QUERY_H_
13 #define QUERY_H_
14
15 #include "zypp/ui/Selectable.h"
16 #include "zypp/sat/SolvAttr.h"
17
18 #include "zypp/base/Function.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23   ///////////////////////////////////////////////////////////////////
24
25   /**
26    * Meta-data query API for user interfaces.
27    * 
28    * TODO: details, examples.
29    */
30   class PoolQuery
31   {
32   public:
33     
34     //typedef SelectableSet::iterator      ResultIterator;
35     //typedef constSelectableSet::iterator constResultIterator;
36
37     typedef function<bool( const ResObject::Ptr & )> ProcessResolvable;
38
39     PoolQuery(PoolQuery::ProcessResolvable fnc);
40     ~PoolQuery();
41
42   public:
43
44     /**
45      * executes the query with the current settings
46      * results are yielded on the callback passed on
47      * construction
48      */
49     void execute(const std::string &term) const;
50
51     /**
52      * Filter by selectable kind.
53      * 
54      * By default, all kinds will be returned. If addKind() is used,
55      * only the specified kinds will be returned (multiple kinds will be ORed).
56      * 
57      * Pass ResTraits<T>::kind to this method, where T is one of the
58      * \ref Resolvable child classes (e.g. ResTraits<Pattern>::kind).
59      */
60     void addKind(const Resolvable::Kind &kind);
61
62     /**
63      * Filter by selectable name.
64      * 
65      * \param name   what to search for
66      * \param isRegex is the value a regex?
67      */
68     //void addName(const std::string & name, bool isRegex = false);
69
70
71     /**
72      * Filter by the \a value of any available attribute of selectables.
73      * 
74      * \note Selectables of a kind not supporting the specified attribute will
75      * <b>not</b> be returned.
76      * 
77      * \param attrid  attribute identfier (sat::SolvAttr or cache::Attribute
78      *                or something implementation independent)
79      * \param value   what to search for
80      * \param isRegex is the value a regex?
81      */
82     //void addAttribute(const solv::SolvAttr & attrid,
83     //                  const std::string & value,
84     //                  bool isRegex = false);
85
86     /**
87      * Filter by Selectable status.
88      * 
89      * This should cover also plain 'is installed' and 'not installed' statuses.
90      *
91      * \param status Selectable status (zypp::ui::Status enum)
92      */
93     //void addStatus(const Status status);
94     
95
96     /**
97      * Add dependency filter.
98      *
99      * \param dtype   depenedcy type
100      * \param name    depenency name
101      * \param edition edition for a versioned dependency
102      * \param rel     operand for a versioned dependency
103      *
104      * \todo maybe a isRegexp bool as in addName() for the name parameter would
105      *       be handy here as well.
106      * \todo add more addDependecy() variants
107      */
108     //void addDependency(const Dep & dtype,
109     //                   const std::string & name,
110     //                   const Edition & edition = Edition(),
111     //                   const Rel & rel = Rel::EQ);
112
113     /** \name Text Attributes Matching Options */
114     //@{
115     /**
116      * Set case sentitive on
117      * ( disables \ref SEARCH_NOCASE flag )
118      */
119     void setCaseSensitive(const bool value = true);
120
121     /**
122      * Free function to set the satsolver repo search
123        flags.
124
125        \see SEARCH_STRINGMASK
126        \see SEARCH_STRING
127        \see SEARCH_SUBSTRING
128        \see SEARCH_GLOB
129        \see SEARCH_REGEX
130        \see SEARCH_NOCASE
131        \see SEARCH_NO_STORAGE_SOLVABLE
132     */
133     void setFlags(int flags);
134     //void setLocale(const Locale & locale);
135     //@}
136
137     //void setRequireAll(const bool require_all = true);
138
139     /** selectable iterator over the result */
140     //ResultIterator resultBegin() const;
141     //ResultIterator resultEnd() const; 
142
143     /** Returns the size of the query result. */
144     //size_t resultSize() const;
145
146     /** Low-cost empty query result checker */
147     //bool resultEmpty() const;
148     
149     // a forEach method consuming a functor can be added here, too
150
151   public:
152     class Impl;
153   private:
154     /** Pointer to implementation */
155     RW_pointer<Impl> _pimpl;
156   };
157
158
159 /////////////////////////////////////////////////////////////////
160 } // namespace zypp
161 ///////////////////////////////////////////////////////////////////
162
163 #endif /*QUERY_H_*/