Unity Scopes API
QScopeBaseAPI.h
1 /*
2  * Copyright (C) 2015 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: Xavi Garcia <xavi.garcia.mena@canonical.com>
17  */
18 
19 #pragma once
20 
21 #include <unity/scopes/ScopeBase.h>
22 #include <unity/scopes/QueryBase.h>
23 #include <unity/scopes/ReplyProxyFwd.h>
24 #include <unity/scopes/QueryBase.h>
25 #include <unity/scopes/PreviewQueryBase.h>
26 
28 
29 #include <memory>
30 #include <thread>
31 
32 namespace unity
33 {
34 
35 namespace scopes
36 {
37 
38 namespace qt
39 {
40 
41 class QScopeBase;
42 
43 namespace internal
44 {
45 class QScopeBaseAPIImpl;
46 }
47 
57 {
58 public:
60  using FactoryFunc = std::function<QScopeBase*()>;
61 
62  NONCOPYABLE(QScopeBaseAPI);
63  UNITY_DEFINES_PTRS(QScopeBaseAPI);
64 
65  QScopeBaseAPI(FactoryFunc const& creator);
66  virtual ~QScopeBaseAPI() = default;
68 
78  virtual void start(std::string const& scope_id);
79 
91  virtual void stop();
92 
96  virtual unity::scopes::PreviewQueryBase::UPtr preview(const unity::scopes::Result&,
97  const unity::scopes::ActionMetadata&) override;
98 
102  virtual unity::scopes::SearchQueryBase::UPtr search(unity::scopes::CannedQuery const& q,
103  unity::scopes::SearchMetadata const&) override;
104 
105 private:
107  std::unique_ptr<internal::QScopeBaseAPIImpl> p;
108  friend class internal::QScopeBaseAPIImpl;
110 };
111 
112 } // namespace qt
113 
114 } // namespace scopes
115 
116 } // namespace unity
Definition: HttpAsyncReader.h:45
Metadata passed with search requests.
Definition: SearchMetadata.h:43
virtual unity::scopes::SearchQueryBase::UPtr search(unity::scopes::CannedQuery const &q, unity::scopes::SearchMetadata const &) override
Base class for a scope implementation.
Definition: ScopeBase.h:139
Metadata passed to scopes for preview and activation.
Definition: ActionMetadata.h:41
The attributes of a result returned by a Scope.
Definition: Result.h:50
virtual unity::scopes::PreviewQueryBase::UPtr preview(const unity::scopes::Result &, const unity::scopes::ActionMetadata &) override
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: QScopeBaseAPI.h:56
Definition: ActionMetadata.h:31
virtual void stop()
Called by the scopes run time when the scope should shut down.
Parameters of a search query.
Definition: CannedQuery.h:45
virtual void start(std::string const &scope_id)
Called by the scopes run time after the create function completes.