Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SearchMetadata.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_SEARCHMETADATA_H
20 #define UNITY_SCOPES_SEARCHMETADATA_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 SearchMetadataImpl;
34 class ScopeObject;
35 }
36 
41 class SearchMetadata final
42 {
43 public:
45  UNITY_DEFINES_PTRS(SearchMetadata);
47 
53  SearchMetadata(std::string const& locale, std::string const& form_factor);
54 
61  SearchMetadata(int cardinality, std::string const& locale, std::string const& form_factor);
62 
66  //{@
67  SearchMetadata(SearchMetadata const& other);
69 
70  SearchMetadata& operator=(SearchMetadata const &other);
71  SearchMetadata& operator=(SearchMetadata&&);
73 
75  ~SearchMetadata();
77 
82  std::string locale() const;
83 
88  std::string form_factor() const;
89 
94  void set_cardinality(int cardinality);
95 
100  int cardinality() const;
101 
108  void set_hint(std::string const& key, Variant const& value);
109 
115  VariantMap hints() const;
116 
122  bool contains_hint(std::string const& key) const;
123 
133  Variant& operator[](std::string const& key);
134 
144  Variant const& operator[](std::string const& key) const;
145 
147  VariantMap serialize() const;
149 
150 private:
151  std::unique_ptr<internal::SearchMetadataImpl> p;
152 
153  SearchMetadata(internal::SearchMetadataImpl *impl);
154  friend class internal::SearchMetadataImpl;
155 };
156 
157 } // namespace scopes
158 
159 } // namespace unity
160 
161 #endif
VariantMap hints() const
Get all hints.
Definition: SearchMetadata.cpp:97
Simple variant class that can hold an integer, boolean, string, double, dictionary, array or null value.
Definition: Variant.h:58
Metadata passed with search requests.
Definition: SearchMetadata.h:41
SearchMetadata(std::string const &locale, std::string const &form_factor)
Create SearchMetadata with given locale and form factor.
Definition: SearchMetadata.cpp:29
void set_hint(std::string const &key, Variant const &value)
Sets a hint.
Definition: SearchMetadata.cpp:92
int cardinality() const
Get cardinality.
Definition: SearchMetadata.cpp:87
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:39
bool contains_hint(std::string const &key) const
Check if this SearchMetadata has a hint.
Definition: SearchMetadata.cpp:113
std::string form_factor() const
Get the form factor string.
Definition: SearchMetadata.cpp:77
std::string locale() const
Get the locale string.
Definition: SearchMetadata.cpp:72
void set_cardinality(int cardinality)
Set cardinality.
Definition: SearchMetadata.cpp:82
Variant & operator[](std::string const &key)
Returns a reference to a hint.
Definition: SearchMetadata.cpp:102