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/QueryMetadata.h>
23 #include <unity/scopes/Location.h>
24 #include <unity/scopes/Variant.h>
25 #include <unity/util/DefinesPtrs.h>
26 
27 namespace unity
28 {
29 
30 namespace scopes
31 {
32 
33 namespace internal
34 {
35 class SearchMetadataImpl;
36 class ScopeObject;
37 }
38 
44 {
45 public:
47  UNITY_DEFINES_PTRS(SearchMetadata);
49 
55  SearchMetadata(std::string const& locale, std::string const& form_factor);
56 
63  SearchMetadata(int cardinality, std::string const& locale, std::string const& form_factor);
64 
68  //{@
69  SearchMetadata(SearchMetadata const& other);
71 
72  SearchMetadata& operator=(SearchMetadata const& other);
73  SearchMetadata& operator=(SearchMetadata&&);
75 
77  ~SearchMetadata();
79 
84  void set_cardinality(int cardinality);
85 
90  int cardinality() const;
91 
96  void set_location(Location const& location);
97 
103  Location location() const;
104 
109  bool has_location() const;
110 
117  void set_hint(std::string const& key, Variant const& value);
118 
125  VariantMap hints() const;
126 
132  bool contains_hint(std::string const& key) const;
133 
143  Variant& operator[](std::string const& key);
144 
154  Variant const& operator[](std::string const& key) const;
155 
156 private:
157  SearchMetadata(internal::SearchMetadataImpl* impl);
158  friend class internal::SearchMetadataImpl;
159 };
160 
161 } // namespace scopes
162 
163 } // namespace unity
164 
165 #endif
VariantMap hints() const
Get all hints.
Definition: SearchMetadata.cpp:97
std::string form_factor() const
Get the form factor string.
Definition: QueryMetadata.cpp:61
Location location() const
Get location.
Definition: SearchMetadata.cpp:82
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 with search requests.
Definition: SearchMetadata.h:43
void set_location(Location const &location)
Set location.
Definition: SearchMetadata.cpp:77
SearchMetadata(std::string const &locale, std::string const &form_factor)
Create SearchMetadata with the 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:72
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
Base class for extra metadata passed to scopes as a part of a request.
Definition: QueryMetadata.h:41
void set_cardinality(int cardinality)
Set cardinality.
Definition: SearchMetadata.cpp:67
bool has_location() const
Does the SearchMetadata have a location.
Definition: SearchMetadata.cpp:87
Variant & operator[](std::string const &key)
Returns a reference to a hint.
Definition: SearchMetadata.cpp:102
Holds location attributes such as latitude, longitude, etc.
Definition: Location.h:40