Unity Scopes API
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 #pragma once
20 
21 #include <unity/util/DefinesPtrs.h>
22 #include <string>
23 #include <memory>
24 #include <unity/scopes/FilterState.h>
25 #include <unity/scopes/Variant.h>
26 
27 namespace unity
28 {
29 
30 namespace scopes
31 {
32 
33 namespace internal
34 {
35 class CannedQueryImpl;
36 }
37 
45 class CannedQuery final
46 {
47 public:
49  UNITY_DEFINES_PTRS(CannedQuery);
51 
55  explicit CannedQuery(std::string const& scope_id);
56 
60  CannedQuery(std::string const& scope_id, std::string const& query_str, std::string const& department_id);
61 
65  //{@
66  CannedQuery(CannedQuery const &other);
68  CannedQuery& operator=(CannedQuery const& other);
69  CannedQuery& operator=(CannedQuery&&);
71 
73  ~CannedQuery();
75 
79  void set_department_id(std::string const& dep_id);
80 
84  void set_query_string(std::string const& query_str);
85 
90 
95  std::string scope_id() const;
96 
101  std::string department_id() const;
102 
107  std::string query_string() const;
108 
110  VariantMap serialize() const;
112 
117  std::string to_uri() const;
118 
126  FilterState filter_state() const;
127 
134  static CannedQuery from_uri(std::string const& uri);
135 
136 private:
137  CannedQuery(internal::CannedQueryImpl *impl);
138  std::unique_ptr<internal::CannedQueryImpl> p;
139  friend class internal::CannedQueryImpl;
140 };
141 
142 } // namespace scopes
143 
144 } // namespace unity
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
static CannedQuery from_uri(std::string const &uri)
Recreates a CannedQuery object from a scope:// URI.
Definition: CannedQuery.cpp:111
std::string department_id() const
Returns the department id of this CannedQuery.
Definition: CannedQuery.cpp:91
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
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:45
Captures state of multiple filters.
Definition: FilterState.h:46
std::string to_uri() const
Returns a string representation of this CannedQuery object as a URI using scope:// schema...
Definition: CannedQuery.cpp:106