Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ActionMetadata.h
1 /*
2  * Copyright (C) 2014 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_ACTIONMETADATA_H
20 #define UNITY_SCOPES_ACTIONMETADATA_H
21 
22 #include <unity/scopes/QueryMetadata.h>
23 #include <unity/scopes/Variant.h>
24 #include <unity/util/DefinesPtrs.h>
25 
26 namespace unity
27 {
28 
29 namespace scopes
30 {
31 
32 namespace internal
33 {
34 class ActionMetadataImpl;
35 }
36 
43 {
44 public:
46  UNITY_DEFINES_PTRS(ActionMetadata);
47 
48  ~ActionMetadata();
50 
56  ActionMetadata(std::string const& locale, std::string const& form_factor);
57 
62  void set_scope_data(Variant const& data);
63 
68  Variant scope_data() const;
69 
73  //{@
74  ActionMetadata(ActionMetadata const& other);
76 
77  ActionMetadata& operator=(ActionMetadata const& other);
78  ActionMetadata& operator=(ActionMetadata&&);
80 
87  void set_hint(std::string const& key, Variant const& value);
88 
95  VariantMap hints() const;
96 
102  bool contains_hint(std::string const& key) const;
103 
113  Variant& operator[](std::string const& key);
114 
124  Variant const& operator[](std::string const& key) const;
125 
126 private:
127  ActionMetadata(internal::ActionMetadataImpl* impl);
128  friend class internal::ActionMetadataImpl;
129 };
130 
131 } // namespace scopes
132 
133 } // namespace unity
134 
135 #endif
bool contains_hint(std::string const &key) const
Check if this SearchMetadata has a hint.
Definition: ActionMetadata.cpp:95
std::string form_factor() const
Get the form factor string.
Definition: QueryMetadata.cpp:61
Simple variant class that can hold an integer, boolean, string, double, dictionary, array or null value.
Definition: Variant.h:58
std::string locale() const
Get the locale string.
Definition: QueryMetadata.cpp:56
Metadata passed to scopes for preview and activation.
Definition: ActionMetadata.h:42
ActionMetadata(std::string const &locale, std::string const &form_factor)
Create ActionMetadata with the given locale and form factor.
Definition: ActionMetadata.cpp:29
Variant & operator[](std::string const &key)
Returns a reference to a hint.
Definition: ActionMetadata.cpp:84
Top-level namespace for all things Unity-related.
Definition: Version.h:50
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:39
Definition: ActionMetadata.h:32
Variant scope_data() const
Get data attached to this ActionMetadata.
Definition: ActionMetadata.cpp:69
void set_hint(std::string const &key, Variant const &value)
Sets a hint.
Definition: ActionMetadata.cpp:74
Base class for extra metadata passed to scopes as a part of a request.
Definition: QueryMetadata.h:41
void set_scope_data(Variant const &data)
Attach arbitrary data to this ActionMetadata.
Definition: ActionMetadata.cpp:64
VariantMap hints() const
Get all hints.
Definition: ActionMetadata.cpp:79