Unity Scopes API
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 #pragma once
20 
21 #include <unity/scopes/QueryBase.h>
22 #include <unity/scopes/QueryCtrlProxyFwd.h>
23 #include <unity/scopes/ScopeProxyFwd.h>
24 #include <unity/scopes/SearchReplyProxyFwd.h>
25 #include <unity/scopes/Variant.h>
26 #include <unity/scopes/SearchListenerBase.h>
27 
28 #include <unity/util/DefinesPtrs.h>
29 #include <unity/util/NonCopyable.h>
30 
31 namespace unity
32 {
33 
34 namespace scopes
35 {
36 
37 class SearchMetadata;
38 
39 namespace internal
40 {
41 
42 class SearchQueryBaseImpl;
43 
44 namespace smartscopes
45 {
46 
47 class SSScopeObject;
48 class SSQueryObject;
49 
50 }
51 
52 } // namespace internal
53 
63 class SearchQueryBase : public QueryBase
64 {
65 public:
67  NONCOPYABLE(SearchQueryBase);
68  UNITY_DEFINES_PTRS(SearchQueryBase);
70 
88  virtual void run(SearchReplyProxy const& reply) = 0;
89 
101  //{@
102  QueryCtrlProxy subsearch(ScopeProxy const& scope,
103  std::string const& query_string,
104  SearchListenerBase::SPtr const& reply);
105  QueryCtrlProxy subsearch(ScopeProxy const& scope,
106  std::string const& query_string,
107  FilterState const& filter_state,
108  SearchListenerBase::SPtr const& reply);
109  QueryCtrlProxy subsearch(ScopeProxy const& scope,
110  std::string const& query_string,
111  std::string const& department_id,
112  FilterState const& filter_state,
113  SearchListenerBase::SPtr const& reply);
114  QueryCtrlProxy subsearch(ScopeProxy const& scope,
115  std::string const& query_string,
116  std::string const& department_id,
117  FilterState const& filter_state,
118  SearchMetadata const& hints,
119  SearchListenerBase::SPtr const& reply);
121 
128  CannedQuery query() const;
129 
136 
138  virtual ~SearchQueryBase();
140 
141 protected:
143  SearchQueryBase(CannedQuery const& query, SearchMetadata const& metadata);
145 
146 private:
147  internal::SearchQueryBaseImpl* fwd() const;
148 
149  void set_department_id(std::string const& department_id);
150  std::string department_id() const;
151 
152  friend class internal::QueryObject; // So QueryObject can call cancel() and set_department_id()
153  friend class internal::ScopeObject; // So ScopeObject can set department and query context
154  friend class internal::smartscopes::SSQueryObject; // So SSQueryObject can call cancel()
155  friend class internal::smartscopes::SSScopeObject; // So SSScopeObject can call set_department_id()
156 };
157 
158 } // namespace scopes
159 
160 } // namespace unity
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:34
Abstract server-side base interface for a query that is executed inside a scope.
Definition: QueryBase.h:60
Metadata passed with search requests.
Definition: SearchMetadata.h:43
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31
Parameters of a search query.
Definition: CannedQuery.h:45
Captures state of multiple filters.
Definition: FilterState.h:46
Abstract base class to represent a particular query.
Definition: SearchQueryBase.h:63
std::shared_ptr< QueryCtrl > QueryCtrlProxy
Convenience type definition.
Definition: QueryCtrlProxyFwd.h:33
std::shared_ptr< SearchReply > SearchReplyProxy
Convenience type definition.
Definition: SearchReplyProxyFwd.h:34
CannedQuery query() const
Get a canned query for this search request.
SearchMetadata search_metadata() const
Get metadata for this search request.