Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SearchQueryBase.h
1 /*
2  * Copyright (C) 2013 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Michi Henning <michi.henning@canonical.com>
17  */
18 
19 #ifndef UNITY_SCOPES_SEARCHQUERYBASE_H
20 #define UNITY_SCOPES_SEARCHQUERYBASE_H
21 
22 #include <unity/scopes/QueryBase.h>
23 #include <unity/scopes/QueryCtrlProxyFwd.h>
24 #include <unity/scopes/ScopeProxyFwd.h>
25 #include <unity/scopes/SearchReplyProxyFwd.h>
26 #include <unity/scopes/Variant.h>
27 #include <unity/scopes/SearchListenerBase.h>
28 
29 #include <unity/util/DefinesPtrs.h>
30 #include <unity/util/NonCopyable.h>
31 
32 namespace unity
33 {
34 
35 namespace scopes
36 {
37 
38 class SearchMetadata;
39 
40 namespace internal
41 {
42 
43 class SearchQueryBaseImpl;
44 
45 namespace smartscopes
46 {
47 
48 class SSScopeObject;
49 class SSQueryObject;
50 
51 }
52 
53 } // namespace internal
54 
64 class SearchQueryBase : public QueryBase
65 {
66 public:
68  NONCOPYABLE(SearchQueryBase);
69  UNITY_DEFINES_PTRS(SearchQueryBase);
71 
89  virtual void run(SearchReplyProxy const& reply) = 0;
90 
102  //{@
103  QueryCtrlProxy subsearch(ScopeProxy const& scope,
104  std::string const& query_string,
105  SearchListenerBase::SPtr const& reply);
106  QueryCtrlProxy subsearch(ScopeProxy const& scope,
107  std::string const& query_string,
108  FilterState const& filter_state,
109  SearchListenerBase::SPtr const& reply);
110  QueryCtrlProxy subsearch(ScopeProxy const& scope,
111  std::string const& query_string,
112  std::string const& department_id,
113  FilterState const& filter_state,
114  SearchListenerBase::SPtr const& reply);
115  QueryCtrlProxy subsearch(ScopeProxy const& scope,
116  std::string const& query_string,
117  std::string const& department_id,
118  FilterState const& filter_state,
119  SearchMetadata const& hints,
120  SearchListenerBase::SPtr const& reply);
122 
129  CannedQuery query() const;
130 
137 
139  virtual ~SearchQueryBase();
141 
142 protected:
144  SearchQueryBase(CannedQuery const& query, SearchMetadata const& metadata);
146 
147 private:
148  internal::SearchQueryBaseImpl* fwd() const;
149 
150  void set_department_id(std::string const& department_id);
151  std::string department_id() const;
152 
153  friend class internal::QueryObject; // So QueryObject can call cancel() and set_department_id()
154  friend class internal::ScopeObject; // So ScopeObject can call set_metadata() and set_department_id()
155  friend class internal::smartscopes::SSQueryObject; // So SSQueryObject can call cancel()
156  friend class internal::smartscopes::SSScopeObject; // So SSQueryObject can call set_department_id()
157 };
158 
159 } // namespace scopes
160 
161 } // namespace unity
162 
163 #endif
virtual void run(SearchReplyProxy const &reply)=0
Called by scopes run time to start the query.
std::shared_ptr< Scope > ScopeProxy
Convenience type definition.
Definition: ScopeProxyFwd.h:35
Abstract server-side base interface for a query that is executed inside a scope.
Definition: QueryBase.h:61
Metadata passed with search requests.
Definition: SearchMetadata.h:41
Parameters of a search query.
Definition: CannedQuery.h:46
Captures state of multiple filters.
Definition: FilterState.h:47
Abstract base class to represent a particular query.
Definition: SearchQueryBase.h:64
std::shared_ptr< QueryCtrl > QueryCtrlProxy
Convenience type definition.
Definition: QueryCtrlProxyFwd.h:34
std::shared_ptr< SearchReply > SearchReplyProxy
Convenience type definition.
Definition: SearchReplyProxyFwd.h:35
CannedQuery query() const
Get canned query of this search request.
SearchMetadata search_metadata() const
Get metadata for this search request.