Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
QueryBase.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_QUERYBASE_H
20 #define UNITY_SCOPES_QUERYBASE_H
21 
22 #include <unity/scopes/QueryCtrlProxyFwd.h>
23 #include <unity/scopes/ReplyProxyFwd.h>
24 #include <unity/scopes/ScopeProxyFwd.h>
25 #include <unity/scopes/Variant.h>
26 
27 #include <unity/util/DefinesPtrs.h>
28 #include <unity/util/NonCopyable.h>
29 
30 namespace unity
31 {
32 
33 namespace scopes
34 {
35 
36 class SearchMetadata;
37 
38 namespace internal
39 {
40 
41 class QueryBaseImpl;
42 class QueryObject;
43 class ScopeObject;
44 
45 namespace smartscopes
46 {
47 
48 class SSQueryObject;
49 class SSScopeObject;
50 
51 } // namespace smartscopes
52 
53 } // namespace internal
54 
55 
61 class QueryBase
62 {
63 public:
65  NONCOPYABLE(QueryBase);
66  UNITY_DEFINES_PTRS(QueryBase);
68 
79  virtual void cancelled() = 0; // Originator cancelled the query
80 
96  bool valid() const;
97 
112 
114  virtual ~QueryBase();
116 
117 protected:
119  QueryBase(internal::QueryBaseImpl* impl);
120  void cancel();
121  std::unique_ptr<internal::QueryBaseImpl> p;
123 
124 private:
125  friend class internal::QueryObject; // So QueryObject can call cancel()
126  friend class internal::smartscopes::SSQueryObject; // So SSQueryObject can call cancel()
127  friend class internal::ScopeObject; // So ScopeObject can call set_metadata() and set_department_id()
128  friend class internal::smartscopes::SSScopeObject; // So SSQueryObject can call set_department_id()
129 };
130 
131 } // namespace scopes
132 
133 } // namespace unity
134 
135 #endif
virtual void cancelled()=0
Called by the scopes run time when the query originator cancels a query.
Abstract server-side base interface for a query that is executed inside a scope.
Definition: QueryBase.h:61
unity::scopes::VariantMap settings() const
Returns a dictionary with the scope's current settings.
Definition: QueryBase.cpp:53
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:39
bool valid() const
Check whether this query is still valid.
Definition: QueryBase.cpp:48