Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CannedQuery.h
1 /*
2  * Copyright (C) 2013 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_CANNEDQUERY_H
20 #define UNITY_SCOPES_CANNEDQUERY_H
21 
22 #include <unity/util/DefinesPtrs.h>
23 #include <string>
24 #include <memory>
25 #include <unity/scopes/FilterState.h>
26 #include <unity/scopes/Variant.h>
27 
28 namespace unity
29 {
30 
31 namespace scopes
32 {
33 
34 namespace internal
35 {
36 class CannedQueryImpl;
37 }
38 
46 class CannedQuery final
47 {
48 public:
50  UNITY_DEFINES_PTRS(CannedQuery);
52 
56  explicit CannedQuery(std::string const& scope_id);
57 
61  CannedQuery(std::string const& scope_id, std::string const& query_str, std::string const& department_id);
62 
66  //{@
67  CannedQuery(CannedQuery const &other);
69  CannedQuery& operator=(CannedQuery const& other);
70  CannedQuery& operator=(CannedQuery&&);
72 
74  ~CannedQuery();
76 
80  void set_department_id(std::string const& dep_id);
81 
85  void set_query_string(std::string const& query_str);
86 
91 
96  std::string scope_id() const;
97 
102  std::string department_id() const;
103 
108  std::string query_string() const;
109 
111  VariantMap serialize() const;
113 
118  std::string to_string() const;
119 
127  FilterState filter_state() const;
128 
135  static CannedQuery from_string();
136 
137 private:
138  CannedQuery(internal::CannedQueryImpl *impl);
139  std::unique_ptr<internal::CannedQueryImpl> p;
140  friend class internal::CannedQueryImpl;
141 };
142 
143 } // namespace scopes
144 
145 } // namespace unity
146 
147 #endif
CannedQuery(std::string const &scope_id)
Creates a query for given scope with empty query string.
Definition: CannedQuery.cpp:29
void set_department_id(std::string const &dep_id)
Sets or updates the department.
Definition: CannedQuery.cpp:71
std::string query_string() const
Returns the query string of this CannedQuery.
Definition: CannedQuery.cpp:96
void set_query_string(std::string const &query_str)
Sets or updates the query string.
Definition: CannedQuery.cpp:76
FilterState filter_state() const
Get state of the filters for this CannedQuery.
Definition: CannedQuery.cpp:101
std::string department_id() const
Returns the department id of this CannedQuery.
Definition: CannedQuery.cpp:91
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:39
std::string scope_id() const
Returns the scope identifier of this CannedQuery.
Definition: CannedQuery.cpp:86
void set_filter_state(FilterState const &filter_state)
Sets filter state.
Definition: CannedQuery.cpp:81
Parameters of a search query.
Definition: CannedQuery.h:46
Captures state of multiple filters.
Definition: FilterState.h:47
std::string to_string() const
Returns a string representation of this CannedQuery object as a URI using scope:// schema...
Definition: CannedQuery.cpp:106
static CannedQuery from_string()
Recreates a CannedQuery object from a scope:// URI.
Definition: CannedQuery.cpp:111