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/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 
41 class ActionMetadata final
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  std::string locale() const;
62 
67  std::string form_factor() const;
68 
73  void set_scope_data(Variant const& data);
74 
79  Variant scope_data() const;
80 
84  //{@
85  ActionMetadata(ActionMetadata const& other);
87 
88  ActionMetadata& operator=(ActionMetadata const &other);
89  ActionMetadata& operator=(ActionMetadata&&);
91 
93  VariantMap serialize() const;
95 
96 private:
97  std::unique_ptr<internal::ActionMetadataImpl> p;
98 
99  ActionMetadata(internal::ActionMetadataImpl *impl);
100  friend class internal::ActionMetadataImpl;
101 };
102 
103 } // namespace scopes
104 
105 } // namespace unity
106 
107 #endif
std::string form_factor() const
Get the form factor string.
Definition: ActionMetadata.cpp:75
Simple variant class that can hold an integer, boolean, string, double, dictionary, array or null value.
Definition: Variant.h:58
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 given locale and form factor.
Definition: ActionMetadata.cpp:29
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:39
Variant scope_data() const
Get data attached to this ActionMetadata.
Definition: ActionMetadata.cpp:85
void set_scope_data(Variant const &data)
Attach arbitrary data to this ActionMetadata.
Definition: ActionMetadata.cpp:80
std::string locale() const
Get the locale string.
Definition: ActionMetadata.cpp:70