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 #ifndef _ENABLE_QT_EXPERIMENTAL_
22 #error You should define _ENABLE_QT_EXPERIMENTAL_ in order to use this experimental header file.
23 #endif
24 
25 #include <unity/scopes/ScopeBase.h>
26 #include <unity/scopes/QueryBase.h>
27 #include <unity/scopes/ReplyProxyFwd.h>
28 #include <unity/scopes/QueryBase.h>
29 #include <unity/scopes/PreviewQueryBase.h>
30 
32 
33 #include <memory>
34 #include <thread>
35 
36 namespace unity
37 {
38 
39 namespace scopes
40 {
41 
42 namespace qt
43 {
44 
45 class QScopeBase;
46 
47 namespace internal
48 {
49 class QScopeBaseAPIImpl;
50 }
51 
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) override;
79 
91  virtual void stop() override;
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;
109 };
110 
111 } // namespace qt
112 
113 } // namespace scopes
114 
115 } // namespace unity
Metadata passed with search requests.
Definition: SearchMetadata.h:45
virtual unity::scopes::SearchQueryBase::UPtr search(unity::scopes::CannedQuery const &q, unity::scopes::SearchMetadata const &) override
virtual void stop() override
Called by the scopes run time when the scope should shut down.
Base class for a scope implementation.
Definition: ScopeBase.h:138
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
virtual void start(std::string const &scope_id) override
Called by the scopes run time after the create function completes.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: QScopeBaseAPI.h:56
Definition: ActionMetadata.h:31
Parameters of a search query.
Definition: CannedQuery.h:49