Unity Scopes API
Result.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: Pawel Stolowski <pawel.stolowski@canonical.com>
17  */
18 
19 #pragma once
20 
21 #include <unity/scopes/Variant.h>
22 #include <unity/util/DefinesPtrs.h>
23 #include <unity/scopes/ScopeProxyFwd.h>
24 #include <string>
25 #include <memory>
26 
27 namespace unity
28 {
29 
30 namespace scopes
31 {
32 
33 class CategorisedResult;
34 
35 namespace internal
36 {
37 class ResultImpl;
38 class ScopeImpl;
39 }
40 
50 class Result
51 {
52 public:
54  UNITY_DEFINES_PTRS(Result);
56 
60  //{@
61  Result(Result const& other);
62  Result(Result&&);
63 
64  Result& operator=(Result const& other);
65  Result& operator=(Result&&);
67 
71  virtual ~Result();
72 
84  void store(Result const& other, bool intercept_activation = false);
85 
90  bool has_stored_result() const;
91 
97  Result retrieve() const;
98 
102  void set_uri(std::string const& uri);
103 
109  void set_title(std::string const& title);
115  void set_art(std::string const& image);
116 
122  void set_dnd_uri(std::string const& dnd_uri);
123 
137 
143  bool direct_activation() const;
144 
154 
165  Variant& operator[](std::string const& key);
166 
176  Variant const& operator[](std::string const& key) const;
177 
184  std::string uri() const noexcept;
185 
192  std::string title() const noexcept;
193 
200  std::string art() const noexcept;
201 
208  std::string dnd_uri() const noexcept;
209 
215  bool contains(std::string const& key) const;
216 
229  Variant const& value(std::string const& key) const;
230 
235  VariantMap serialize() const;
236 
241  bool is_account_login_result() const;
242 
244 protected:
245  explicit Result(const VariantMap &variant_map);
246  explicit Result(internal::ResultImpl* impl);
247 
248 private:
249  std::unique_ptr<internal::ResultImpl> p;
250 
251  friend class internal::ResultImpl;
252  friend class internal::ScopeImpl;
253  friend class CategorisedResult;
255 };
256 
257 } // namespace scopes
258 
259 } // namespace unity
void set_uri(std::string const &uri)
Set the "uri" attribute of this result.
std::shared_ptr< Scope > ScopeProxy
Convenience type definition.
Definition: ScopeProxyFwd.h:34
void set_art(std::string const &image)
Set the "art" attribute of this result.
void set_dnd_uri(std::string const &dnd_uri)
Set the "dnd_uri" attribute of this result.
std::string art() const noexcept
Get the "art" property of this Result.
std::string title() const noexcept
Get the "title" property of this Result.
Simple variant class that can hold an integer, boolean, string, double, dictionary, array or null value.
Definition: Variant.h:57
void set_intercept_activation()
Indicates to the receiver that this scope should intercept activation requests for this result...
bool is_account_login_result() const
Check if this result is an online account login result.
Result retrieve() const
Get a stored result.
ScopeProxy target_scope_proxy() const
Get the proxy of a scope that handles activation and preview of this result.
Variant const & value(std::string const &key) const
Get the value of an attribute.
The attributes of a result returned by a Scope.
Definition: Result.h:50
std::string dnd_uri() const noexcept
Get the "dnd_uri" property of this Result.
bool contains(std::string const &key) const
Check if this Result has an attribute.
std::string uri() const noexcept
Get the "uri" property of this Result.
VariantMap serialize() const
Returns a dictionary of all attributes of this Result instance.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
bool has_stored_result() const
Check if this Result instance has a stored result.
void set_title(std::string const &title)
Set the "title" attribute of this result.
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:38
Definition: ActionMetadata.h:31
void store(Result const &other, bool intercept_activation=false)
Stores a Result inside this Result instance.
Variant & operator[](std::string const &key)
Returns reference of a Result attribute.
bool direct_activation() const
Check if this result should be activated directly by the shell because the scope doesn't handle activ...
A result, including the category it belongs to.
Definition: CategorisedResult.h:41