Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 #ifndef UNITY_SCOPES_RESULT_H
20 #define UNITY_SCOPES_RESULT_H
21 
22 #include <unity/scopes/Variant.h>
23 #include <unity/util/DefinesPtrs.h>
24 #include <unity/scopes/ScopeProxyFwd.h>
25 #include <string>
26 #include <memory>
27 
28 namespace unity
29 {
30 
31 namespace scopes
32 {
33 
34 class CategorisedResult;
35 
36 namespace internal
37 {
38 class ResultImpl;
39 class ScopeImpl;
40 }
41 
51 class Result
52 {
53 public:
55  UNITY_DEFINES_PTRS(Result);
57 
61  //{@
62  Result(Result const& other);
63  Result(Result&&);
64 
65  Result& operator=(Result const& other);
66  Result& operator=(Result&&);
68 
72  virtual ~Result();
73 
85  void store(Result const& other, bool intercept_activation = false);
86 
91  bool has_stored_result() const;
92 
98  Result retrieve() const;
99 
103  void set_uri(std::string const& uri);
104 
110  void set_title(std::string const& title);
116  void set_art(std::string const& image);
117 
123  void set_dnd_uri(std::string const& dnd_uri);
124 
138 
144  bool direct_activation() const;
145 
155 
166  Variant& operator[](std::string const& key);
167 
177  Variant const& operator[](std::string const& key) const;
178 
185  std::string uri() const noexcept;
186 
193  std::string title() const noexcept;
194 
201  std::string art() const noexcept;
202 
209  std::string dnd_uri() const noexcept;
210 
216  bool contains(std::string const& key) const;
217 
225  Variant const& value(std::string const& key) const;
226 
231  VariantMap serialize() const;
232 
233 protected:
235  explicit Result(const VariantMap &variant_map);
236  explicit Result(internal::ResultImpl* impl);
238 
239 private:
240  std::unique_ptr<internal::ResultImpl> p;
241 
242  friend class internal::ResultImpl;
243  friend class internal::ScopeImpl;
244  friend class CategorisedResult;
245 };
246 
247 } // namespace scopes
248 
249 } // namespace unity
250 
251 #endif
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:35
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:58
void set_intercept_activation()
Indicates to the receiver that this scope should intercept activation requests for this 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:51
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.
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:39
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