Unity Scopes API
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 #pragma once
20 
21 #include <unity/scopes/QueryMetadata.h>
22 #include <unity/scopes/Variant.h>
23 #include <unity/util/DefinesPtrs.h>
24 
25 namespace unity
26 {
27 
28 namespace scopes
29 {
30 
31 namespace internal
32 {
33 class ActionMetadataImpl;
34 }
35 
42 {
43 public:
45  UNITY_DEFINES_PTRS(ActionMetadata);
46 
47  ~ActionMetadata();
49 
55  ActionMetadata(std::string const& locale, std::string const& form_factor);
56 
61  void set_scope_data(Variant const& data);
62 
67  Variant scope_data() const;
68 
72  //{@
73  ActionMetadata(ActionMetadata const& other);
75 
76  ActionMetadata& operator=(ActionMetadata const& other);
77  ActionMetadata& operator=(ActionMetadata&&);
79 
86  void set_hint(std::string const& key, Variant const& value);
87 
94  VariantMap hints() const;
95 
101  bool contains_hint(std::string const& key) const;
102 
112  Variant& operator[](std::string const& key);
113 
123  Variant const& operator[](std::string const& key) const;
124 
125 private:
126  ActionMetadata(internal::ActionMetadataImpl* impl);
127  friend class internal::ActionMetadataImpl;
128 };
129 
130 } // namespace scopes
131 
132 } // namespace unity
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:57
std::string locale() const
Get the locale string.
Definition: QueryMetadata.cpp:56
Metadata passed to scopes for preview and activation.
Definition: ActionMetadata.h:41
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:49
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:38
Definition: ActionMetadata.h:31
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